Freitag, 28. August 2015

.gitignore file for latex

*.aux
*.glo
*.idx
*.log
*.toc
*.ist
*.acn
*.acr
*.alg
*.bbl
*.blg
*.dvi
*.glg
*.gls
*.ilg
*.ind
*.lof
*.lot
*.maf
*.mtc
*.mtc1
*.out
auto

Donnerstag, 16. Juli 2015

cut out part of figure in tikz

To cut out a figure (here i used a rule instead) you can use a node shape as a cut out mask as shown in the following:

\begin{tikzpicture}
\node[regular polygon, path picture={
  \node at (path picture bounding box.center)
  { \rule{4cm}{3cm} };
}
,minimum width=2.5cm,minimum height=2cm] {};
\end{tikzpicture}

instead of \rule{width}{height} you can use a \includegraphics command.

For a rectangle be aware that you have to set the minimum width and minimum height the same size as the picture otherwise a white border will remain.


Mittwoch, 15. Juli 2015

3d plots in tikz

To plot a 3d plot with latex in tikz you should use the tikz3dplot package:
\usepackage{tikz-3dplot}

 you can define the coordinate system by using:
\tdplotsetmaincoords{70}{110}

after that you can use 3d coordinate definitions:
\begin{tikzpicture}[tdplot_main_coords]
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
\end{tikzpicture}

shift in nodes in tikz

for a shift in one direction use the option:

yshift=LENGTH
xshift=LENGTH

for a shift in both directions use:

shift=({XSHIFT,YSHIFT})

Example:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,4);
\node (A) at (2,1) {A};
\path ([yshift=2cm]A) node {B};
\node (C) at ([yshift=1cm]A) {C};
\node (D) at ([shift=({1cm,1cm})]A) {D};
\end{tikzpicture}

\end{document}

horizontal and vertical centering in subfigures

subfigures in a figure environment:

\begin{figure}
\end{figure}


adding centered graphics with different heights:

\begin{figure}
  \rule{3cm}{5cm}
  \begin{minipage}[b][5cm][c]{2.5cm}
    \color{red}{\rule{2.5cm}{2cm}}
    \vfill
    \color{blue}{\rule{2.5cm}{2cm}}
  \end{minipage}
\end{figure}



Change separation length in itemize latex

\setlength\itemsep{1em}

abbreviations/acronyms via the acro package in latex

The best package for acronyms in latex documents is

\usepackage{acro}

To define acronyms you use the following commands:

\DeclareAcronym{command}{short=shortform,long=longform}

You can use the acronyms in a text via

\ac{command}

changing \ac into

\Ac     -capital initial
\acp   -plural
\ac*    -without marking it as already present
\acl     - long form
\acs    - short form

for follow reading:

http://mirror.unl.edu/ctan/macros/latex/contrib/acro/acro_en.pdf

formulas in latex

For a single line of equation:

 \begin{equation}
\end{equation}

For a multiline equation, which can be aligned:

 \begin{align}
\end{align}

For a multiline equation:

 \begin{gather}
\end{gather}

Dienstag, 21. April 2015

Barrier for floats

If you want to create a barrier for floats created via the
\begin{figure}
\end{figure}
or
\begin{table}
\end{table}
environments you can use the floatbarrier function when using the placeins-package
\usepackage{placeins}
\Floatbarrier

Mittwoch, 4. März 2015

plot an image transparently with gnuplot

The standard way to plot a image in gnuplot is the following:
plot x
plot 'test.png' binary filetype=png with rgbimage 



with several filetypes, like jpg, png and so on. But if you want to have this image transparent you need to choose rgbalpha instead of rgbimage and use u 1:2:3:(alpha-value) with the alpha-value ranging between 0:255 as follows:

plot x
replot 'test.png' u 1:2:3:($4*0.5) binary filetype=png with rgbalpha 


Mittwoch, 25. Februar 2015

group of transparent objects tikz

if you have a group of overlaying objects and want them to be transparent, a standard procedure is that you set the transparency for each object.
But this may lead to a overlap of these transparent object and that you see the underlying whereas you actually just want to have the full combined object transparent.

You can simply solve that by placing the group of objects in a scope and set the group properties to transparent in the following way:

\begin{scope}[transparency group, opacity=0.5]
% group of objects
% more objects
\end{scope} 

Samstag, 17. Januar 2015

plot color of data point with z-value

To plot a x,y,z data file with the z-value being the color value of the x,y data point use "with linespoints palette" as following:

plot 'test.dat' u 1:2:3 with linespoints palette 

An example is shown below:

Donnerstag, 15. Januar 2015

gnuplot use figure with alpha channel

Sometimes it is desirable to plot data on top of a figure or a figure on top of a graph. In the latter case the figure has to be transparent so that the plotted data is still shown. This can be achieved via the "with rgbalpha" option as shown in the following:
plot "partly_transparent_figure.png" binary filetype=png  with rgbalpha

round numbers in tikz with pgfmath

To round numbers using pgfplots in the tikzpicture environment use \pgfmathparse to calculate the desired value and then print it to with \pgfmathprintnumber or print it to a variable with \pgfmathprintnumberto and use the optional parameter precision, as shown in the following:
\pgfmathparse{10.042/1.54}
\pgfmathprintnumberto[precision=2]{\pgfmathresult}{\value}
\value