1

How do I achieve a linefeed in the text of a tikzpicture node? \\ does nothing, neither does \linefeed, I understand that \textbackslash is simply regarded as a character. Is there a way to have linefeeds replace the : characters in the MWE below? Nothing jumps at me browsing through the TikZ&PGF manual (other than Karl and Hagen). Although everything I do in in LaTeX is LaTeX3, I have in this instance removed the reference to expl3 as it does not appear to make one iota of difference.

\documentclass{article}
% RN. 9 Nov 2017
%=======================
\usepackage{tikz}
%-----------------------
\begin{document}
\begin{tikzpicture}
[level distance=10mm,
every node/.style={circle,draw,inner sep=0.5pt},
level 1/.style={sibling distance=80mm},
level 2/.style={sibling distance=40mm},
level 3/.style={sibling distance=20mm},
level 4/.style={sibling distance=10mm},
level 5/.style={sibling distance=5mm},
level 6/.style={sibling distance=2.5mm}]
\node{9\newline -2}child{node{5\textbackslash\textbackslash2}child{node{2\\-2}
child[missing]child{node{4:1}child{node{3:0}}child[missing]}}child{node{7:0}}}
child{node{17:-3}child{node{16:1}child{node{11:0}}child[missing]}child{node{23:3}
child{node{22:3}child{node{18:-2}child[missing]child{node{19:-1}
child[missing]child{node{21:0}}}}child[missing]}child{node{24:0}}}};
\end{tikzpicture}
\end{document}
  • 1
    I think most options are covered in https://tex.stackexchange.com/questions/123671/manual-automatic-line-breaks-and-text-alignment-in-tikz-nodes – Torbjørn T. Nov 08 '17 at 20:37
  • That's as good as an answer. Thanks. And I withdraw my tongue-in-cheek remark re the TikZ-PGF manual. There is a lot to read on the subject, just couldn't find it in a hurry. – Reinhard Neuwirth Nov 08 '17 at 20:53

0 Answers0