# Some questions regarding tikz tree

I have a tree working written in tikz, however, it's not fully what I wanted it to look like

\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
\node [circle,draw] (equal){$=$}
child {node [circle,draw] (m1) {$meters$}
child {node [circle,draw] (x1) {$X_1$ \\ meters/hour}}
child {node [circle,draw] (x2) {$X_2$ \\ {\it hour}}}
}
child {node [circle,draw] (m2) {$meters$}
child {node [circle,draw] (y1) {$Y_1$ \\ {\it meters/lap}}}
child {node [circle,draw] (y2) {$Y_2$ \\ {\it lap}}}
};

\end{tikzpicture}


My question is first how do I break the text into two lines (\\does not work for some reason), also how do I fix the size of each circle to be the same (meaning shrinking the text for some of the nodes if necessary)

• Add align=center option to each node and you can use \\... – Paul Gaborit Jan 3 '16 at 8:45
• Unrelated note: $meters$ is wrong, look for example at the spacing between r and s. If you want italics, use \textit{meters} or {\itshape meters}, otherwise just meters. (Don't use \it, cf. Does it matter if I use \textit or \it, \bfseries or \bf, etc.) – Torbjørn T. Jan 3 '16 at 9:43

Using Paul's comment and this question on node size, you can set the minimum size of each node (so you have to adjust the font size of each node separately to make sure it fits inside, with the font= option). Here's the code:

\begin{tikzpicture}[level/.style={sibling distance=60mm/#1},
every node/.style={align=center,inner sep=0pt,minimum size=1.5cm}]
\node [circle,draw] (equal){$=$}
child {node [circle,draw] (m1) {$meters$}
child {node [circle,draw,font=\tiny] (x1) { $X_1$ \\ meters/hour}}
child {node [circle,draw] (x2) {$X_2$ \\ {\it hour}}}
}
child {node [circle,draw] (m2) {$meters$}
child {node [circle,draw,font=\footnotesize] (y1) {$Y_1$ \\ {\it meters/lap}}}
child {node [circle,draw] (y2) {$Y_2$ \\ {\it lap}}}
};

\end{tikzpicture}


And here's the result:

The node size is set to 1.5cm, which you can change, and I've only adjusted some of the node font sizes.

A personal opinion - I think long text like "meters/hour" is better to split over two lines or abbreviate, rather than trying to shrink the font. Uniform text size in a figure looks better.