How can I use \linebreak inside a node, in tikz?
There is a much simpler and more elegant solution! From the TikZ manual § 17.4.3 Text Parameters: Alignment and Width for Multi-Line Text:
\node[draw, align=left] {This is a\\demonstration.};
Key here is that you must use the align
option, with the parameter that you want.
You could use a single-column tabular
to achieve line breaks:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz \node {\begin{tabular}{l}
start \\
another \\
stop
\end{tabular}};
\end{document}
Also macros like \shortstack{start\\another\\stop}
are useful. I also always add a \strut
in every line to ensure a constant line skip.
You can also put a \parbox around your node text:
\documentclass{article}
\usepackage{calc,tikz}
\begin{document}
\tikz \node {\parbox{\widthof{another}}{
start \\
another \\
stop}};
\end{document}