PGF/TikZ: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
Line 38: Line 38:
};
};


</source>

== TKZ-Euclide ==

In this example [http://tex.stackexchange.com/questions/204479/how-can-i-label-points-in-tkz-euclide-without-serifes],
* Clip image to a circle using <code>\tkzClipCircle(O,Z)</code>
* Label angles using <code>\tkzLabelAngle[pos=0.2](B,A,C){$\alpha$}</code>
* Label points, with positioning, using <code>\tkzLabelPoints[below left](B)</code>
* Change text style globally, using <code>label style/.append style={font=\sansmath}</code>
* Change drawing scale, using <code>scale=3</code>
* Draw points, with style, using <code>\tkzDrawPoints[color=black,fill=red,size=5](A,B,C)</code>.

<source lang=latex>
\begin{tikzpicture}[scale=3,label style/.append style={font=\sansmath}]
\tkzDefPoint(0,0){O}
\tkzDefPoint(1,0){Z}

% Define points
\tkzDefPoint(-0.7,-0.1){A}
\tkzDefPoint(0.4,-0.3){B}
\tkzDefPoint(0.1,0.4){C}

% Draw big circle
\tkzDrawCircle[fill=white](O,Z)

% I have no idea what this does,
% but when I remove it the rest of the image (the big circles)
% get visible. So it seems to crop the image to the size of the circle
\tkzClipCircle(O,Z)

% Draw angles
\tkzMarkAngles[fill= orange,size=0.3cm,opacity=.3](B,A,C)
\tkzLabelAngle[pos=0.2](B,A,C){$\alpha$}

\tkzMarkAngles[fill= orange,size=0.3cm,opacity=.3](C,B,A)
\tkzLabelAngle[pos=0.2](C,B,A){$\beta$}

\tkzMarkAngles[fill= orange,size=0.3cm,opacity=.3](A,C,B)
\tkzLabelAngle[pos=0.2](A,C,B){$\gamma$}


% "Clip" angles
\tkzDrawCircle[fill,orthogonal through=A and B,color=white](O,Z)
\tkzDrawCircle[fill,orthogonal through=A and C,color=white](O,Z)
\tkzDrawCircle[fill,orthogonal through=B and C,color=white](O,Z)

% Draw big circle
\tkzDrawCircle(O,Z)

% Draw lines
\tkzDrawCircle[orthogonal through=A and B,color=green](O,Z)
\tkzDrawCircle[orthogonal through=A and C,color=blue](O,Z)
\tkzDrawCircle[orthogonal through=B and C,color=red](O,Z)

% Draw points and label them
\tkzDrawPoints[color=black,fill=red,size=5](A,B,C)
\tkzLabelPoints[below](A)
\tkzLabelPoints[below left](B)
\tkzLabelPoints[above left](C)
\end{tikzpicture}
</source>
</source>

Revision as of 09:11, 28 October 2014

PGF/TikZ is a powerful drawing package that can be used to produce professional-looking graphics. In particular PGF/TikZ interpreter can be used from LaTeX documents.

Links

Packages
  • tkz-euclide An extremely simple and powerful drawing package for drawing geometry figures.

Reference

To be completed.

Troubleshoot

markings decoration not show in curved path

Setting a decoration at position 1 does not work when using curved paths. An easy fix is to use 0.999 instead (see also bug, [1]).

\begin{tikzpicture}[node distance=1cm,
    decoration={markings, mark=at position 0.999 with {\arrow[scale=2]{stealth}}}]
  \node (c) {C};
  \node [below=5pt of c] (d) {D};
  \draw[postaction={decorate}] (c) to [out=0,in=0,looseness=3] (d);
\end{tikzpicture}
Trouble in labels

Better enclose label text in curly braces:

% ...
\node[mult]                   (m)   [label=right:{$\rsam$}] {};
% ...
\matrix [matrix of math nodes]
{
  |(m1) [label=left:{\dagnode_1=1}]| {} \\
};

TKZ-Euclide

In this example [2],

  • Clip image to a circle using \tkzClipCircle(O,Z)
  • Label angles using \tkzLabelAngle[pos=0.2](B,A,C){$\alpha$}
  • Label points, with positioning, using \tkzLabelPoints[below left](B)
  • Change text style globally, using label style/.append style={font=\sansmath}
  • Change drawing scale, using scale=3
  • Draw points, with style, using \tkzDrawPoints[color=black,fill=red,size=5](A,B,C).
\begin{tikzpicture}[scale=3,label style/.append style={font=\sansmath}]
    \tkzDefPoint(0,0){O}
    \tkzDefPoint(1,0){Z}

    % Define points
    \tkzDefPoint(-0.7,-0.1){A}
    \tkzDefPoint(0.4,-0.3){B}
    \tkzDefPoint(0.1,0.4){C}

    % Draw big circle
    \tkzDrawCircle[fill=white](O,Z)

    % I have no idea what this does,
    % but when I remove it the rest of the image (the big circles)
    % get visible. So it seems to crop the image to the size of the circle
    \tkzClipCircle(O,Z)

    % Draw angles
    \tkzMarkAngles[fill= orange,size=0.3cm,opacity=.3](B,A,C)
    \tkzLabelAngle[pos=0.2](B,A,C){$\alpha$}

    \tkzMarkAngles[fill= orange,size=0.3cm,opacity=.3](C,B,A)
    \tkzLabelAngle[pos=0.2](C,B,A){$\beta$}

    \tkzMarkAngles[fill= orange,size=0.3cm,opacity=.3](A,C,B)
    \tkzLabelAngle[pos=0.2](A,C,B){$\gamma$}


    % "Clip" angles
    \tkzDrawCircle[fill,orthogonal through=A and B,color=white](O,Z)
    \tkzDrawCircle[fill,orthogonal through=A and C,color=white](O,Z)
    \tkzDrawCircle[fill,orthogonal through=B and C,color=white](O,Z)

    % Draw big circle
    \tkzDrawCircle(O,Z)

    % Draw lines
    \tkzDrawCircle[orthogonal through=A and B,color=green](O,Z)
    \tkzDrawCircle[orthogonal through=A and C,color=blue](O,Z)
    \tkzDrawCircle[orthogonal through=B and C,color=red](O,Z)

    % Draw points and label them
    \tkzDrawPoints[color=black,fill=red,size=5](A,B,C)
    \tkzLabelPoints[below](A)
    \tkzLabelPoints[below left](B)
    \tkzLabelPoints[above left](C)
\end{tikzpicture}