4

I have the following image

enter image description here

that was created with this code:

\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}

\begin{document}
\usetkzobj{all}
\begin{tikzpicture}
    \tkzSetUpPoint[shape=circle,size=10,color=black,fill=black]
    \tkzSetUpLine[line width=1]
    \tkzDefPoints{0/0/A, 3/0/B', 2/2/C, 4/4/C'}
    \tkzDefLine[parallel=through C](B',C') \tkzGetPoint{Phelper}
    \tkzInterLL(A,B')(C,Phelper) \tkzGetPoint{B}
    \tkzDrawLine[add=0 and 0.2](A,B')
    \tkzDrawLine[add=0 and 0.2](A,C')
    \tkzDrawSegment(B',C')

    \node at ($(A)+(-0.1,-0.2)$)  {$A$};
    \node at ($(B')+(0.2,-0.2)$)  {$B'$};
    \node at ($(C')+(0,0.4)$)  {$C'$};
    \node at ($(B)+(0.2,-0.2)$)  {$B$};
    \node at ($(C)+(0.28,0.5)$)  {$C$};
    \tkzDrawPolygon[ultra thick,color=blue,fill=blue!20](A,B',C') 
    \tkzDrawPolygon[line width=0.3pt,color=red,fill=red!20](A,B,C) 
    \tkzDrawPoints(A,B',C',B,C)
    \tkzLabelSegment[below,red](A,B){$c$}
    \tkzLabelSegment[left,red](A,C){$b$}
    \tkzLabelSegment[right,red](B,C){$a$}
    \tkzLabelSegment[below,blue,pos=0.8](A,B'){$c'$}
    \tkzLabelSegment[left,blue,pos=0.8](A,C'){$b'$}
    \tkzLabelSegment[right,blue](B',C'){$a'$}
\end{tikzpicture}
\end{document}

As you might notice, the space above C' is bigger than necessary. This is because of Phelper. I need Phelper for the construction, but it should not influence the image size in any way. I've tried to get Phelper closer to C, but that seems not to be possible.

How can I stop defined (but not visible) points from influencing image size?

Please note: I wrap code like this in a figure. So images like the one above are only a part of the whole document. So working with standalone does not solve my problem.

4

Add the key /tikz/overlay to the command that defines the coordinate Phelpher (which is actually the \tkzDefLine command). This key says "Don't use this construction when computing the bounding box.". It's the single-key version of pgfinterruptboundingbox that Torbjørn refers to in his comment. As tkz macros use their own keys, and don't pass unknown keys on to tikz, you need the /tikz/ prefix.

\documentclass[varwidth=true, border=2pt]{standalone}
%\url{http://tex.stackexchange.com/q/155343/86}
\usepackage{tikz}
\usepackage{tkz-euclide}

\begin{document}
\usetkzobj{all}
\begin{tikzpicture}
    \tkzSetUpPoint[shape=circle,size=10,color=black,fill=black]
    \tkzSetUpLine[line width=1]
    \tkzDefPoints{0/0/A, 3/0/B', 2/2/C, 4/4/C'}
    \tkzDefLine[parallel=through C,/tikz/overlay](B',C') \tkzGetPoint{Phelper}
    \tkzInterLL(A,B')(C,Phelper) \tkzGetPoint{B}
    \tkzDrawLine[add=0 and 0.2](A,B')
    \tkzDrawLine[add=0 and 0.2](A,C')
    \tkzDrawSegment(B',C')

    \node at ($(A)+(-0.1,-0.2)$)  {$A$};
    \node at ($(B')+(0.2,-0.2)$)  {$B'$};
    \node at ($(C')+(0,0.4)$)  {$C'$};
    \node at ($(B)+(0.2,-0.2)$)  {$B$};
    \node at ($(C)+(0.28,0.5)$)  {$C$};
    \tkzDrawPolygon[ultra thick,color=blue,fill=blue!20](A,B',C') 
    \tkzDrawPolygon[line width=0.3pt,color=red,fill=red!20](A,B,C) 
    \tkzDrawPoints(A,B',C',B,C)
    \tkzLabelSegment[below,red](A,B){$c$}
    \tkzLabelSegment[left,red](A,C){$b$}
    \tkzLabelSegment[right,red](B,C){$a$}
    \tkzLabelSegment[below,blue,pos=0.8](A,B'){$c'$}
    \tkzLabelSegment[left,blue,pos=0.8](A,C'){$b'$}
    \tkzLabelSegment[right,blue](B',C'){$a'$}
\end{tikzpicture}
\end{document}

before and after shots

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.