# Does tikz have meaningful whitespace?

This latex compiles for me perfectly:

\documentclass[12pt,a4paper]{book}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[level/.style={sibling distance = 5cm/#1,text width=1cm, level distance = 1.2cm}]
\node[text width=2.5cm]  {A}
child{ node  {A}
child{ node  {A} }
}
;
\end{tikzpicture}
\end{document}


It produces this:

However this latex:

\documentclass[12pt,a4paper]{book}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[level/.style={sibling distance = 5cm/#1,text width=1cm, level distance = 1.2cm}]
\node[text width=2.5cm]  {A}
child{ node  {A}
child{ node  {A}

}
}
;
\end{tikzpicture}
\end{document}


Gives me:

Runaway argument?
{ node {A} child{ node {A}
! Paragraph ended before \tikz@collect@child@code was complete.
\par
l.10

?


What's going on? Does tikx have meaningful whitespace (the only thing that has changed is the addition of new carriage returns before one of the } characters)? My googling is just giving me ways of putting whitespace in the pdf...

• In general no, but in your particular case (in tree structure) has. – Zarko Jul 20 at 14:22
• BTW, the \par is how TeX interprets blank lines. This is before any extraneous text is dumped into a bit box. – John Kormylo Jul 20 at 14:25
• Spaces are mostly ignored in TikZ, with due exception for textual parts. However it doesn't allow blank lines in certain arguments; technically because the macros are not declared \long. At the outer level a blank line is not a problem, because \par tokens are ignored in what is eventually an \hbox; there may be good reasons not to allow blank lines in that situation (or it is just that the developers didn't think to users putting blank lines in that position). – egreg Jul 20 at 17:04
• @egreg thank you! :) – Joe Jul 21 at 4:48

\begin{tikzpicture}[level/.style={sibling distance = 5cm/#1,text width=1cm, level distance = 1.2cm}]