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}