# tikz euclide \tkzMarkAngle causing error in bounding box?

I am experiencing strange behaviour with tkz-euclide.

The \tkzMarkAngle[size=2](P,R,S) command in the code below seems to mess up the bounding box.

\documentclass{minimal}

\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=.3]
\tkzDefPoint(0,0){S}
\tkzDefPoint(42:20){P}
\tkzDefPoint(0:21.1){R}
\tkzDrawSegments[thick](S,P P,R R,S)
\tkzLabelPoints[left](S)
\tkzLabelPoints[above](P)
\tkzLabelPoints[right](R)
\tkzMarkAngle[size=2](P,R,S)
\tkzLabelAngle[pos = 3.5](P,R,S){$65^{\circ}$}
\tkzMarkAngle[size=2](R,S,P)
\tkzLabelAngle[pos = 3.5](R,S,P){$42^{\circ}$}
\tkzLabelSegment[above left](S,P){$20$ m}
\end{tikzpicture}
\end{center}

\end{document}


This above code produces the correct picture but not centered, whereas the following code (with a single line commented out) produces a picture that does get centered.

\documentclass{minimal}

\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=.3]
\tkzDefPoint(0,0){S}
\tkzDefPoint(42:20){P}
\tkzDefPoint(0:21.1){R}
\tkzDrawSegments[thick](S,P P,R R,S)
\tkzLabelPoints[left](S)
\tkzLabelPoints[above](P)
\tkzLabelPoints[right](R)
%\tkzMarkAngle[size=2](P,R,S)
\tkzLabelAngle[pos = 3.5](P,R,S){$65^{\circ}$}
\tkzMarkAngle[size=2](R,S,P)
\tkzLabelAngle[pos = 3.5](R,S,P){$42^{\circ}$}
\tkzLabelSegment[above left](S,P){$20$ m}
\end{tikzpicture}
\end{center}

\end{document}


Does anyone have any idea why this is happening and how I can get my picture centered?

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. — In fact, I get an Undefined control sequence at \tkzMarkAngle and \tkzLabelAngle. Which package do provide these commands? – Qrrbrbirlbel May 13 '13 at 17:22
@Qrrbrbirlbel, it comes from a library to tikz, to be used for Euclidean geometry. – Sigur May 13 '13 at 17:25
I've edited my code above. – user959560 May 13 '13 at 18:27
The label (which is empty in this case) is placed at the wrong position. This updates the bounding box and thus creates a wider TikZ picture with a flush-left triangle and a lot of white space. – Qrrbrbirlbel May 13 '13 at 18:34

The empty but still used label is set at the wrong position.

\node[shift=<somewhere>] at (<somewhere else>) …


doesn't work but

\node at ([shift=<somewhere>] <somewhere else>) …


or

\path[shift=<somewhere>] node at (<somewhere else>) …


does.

With the help of etoolbox and its \patchcmd macro one can fix this without any hassle.

I took the liberty to include the \tkzLabelAngle right into the \tkzMarkAngle command.

I also included the \tkzMarkAngle between S,P,R which would have had a misplaced label also.

## Code

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\usepackage{etoolbox}
\makeatletter
\patchcmd\tkz@MarkAngle{\node[lbstyle,shift={(\tkz@ax,\tkz@ay)}] at (\labelangle:\tkz@dist ){\tkz@mklabel};}
{\node[lbstyle] at ([shift={(\tkz@ax,\tkz@ay)}]\labelangle:\tkz@dist ){\tkz@mklabel};}% or \path[shift=…] node[lbstyle] at …;
{}{}
\makeatother
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=.3]
\tkzDefPoint(0,0){S}
\tkzDefPoint(42:20){P}
\tkzDefPoint(0:21.1){R}
\tkzDrawSegments[thick](S,P P,R R,S)
\tkzLabelPoints[left](S)
\tkzLabelPoints[above](P)
\tkzLabelPoints[right](R)
\tkzMarkAngle[label=$65^{\circ}$, dist=3.5, size=2](P,R,S)
\tkzMarkAngle[label=$42^{\circ}$, dist=3.5, size=2](R,S,P)
\tkzMarkAngle[size=2](S,P,R)
\tkzLabelSegment[above left](S,P){$20$ m}
\end{tikzpicture}
\end{center}
\end{document}


## Output

-
Wow, that's great! Thank you so much. – user959560 May 13 '13 at 19:30