tags:

views:

78

answers:

2

This is my code, which doesn't work:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz \node {start\linebreak{}stop};
\end{document}

The \linebreak command doesn't work. In order to make it working I have to say \node[text width=5em]... Is there any other method to make it working, without explicit specification of the node text width? Thanks!

A: 
\def\mynode#{\vtop \bgroup \hsize 0pt \parindent 0pt 
        \rightskip = 0pt minus \maxdimen \let\next=}
\tikz \node {\mynode{start\linebreak stop}};
Alexey Malistov
A: 

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 always add a \strut in every line to ensure a constant line skip.

Martin Scharrer