1

With pst-node and pst-tree, is it possible to display node's label on multiple lines?

With TikZ, it is very easy, you simply put a line break at the appropriate place in the node's label { first line of the label \\ second line of the label}. I tried to do the same using pst-tree and pst-node.

  \pstree[nodesep=5pt,levelsep=7em]{ \TR{first line of label \\ second line of label}} {
    \pstree{ \TR{N2}} {
        \TR{N3}
    }
    \pstree{ \TR{N4}} {
        \TR{N5}
    }
}

but it does not work. In general, the line break simply results in no space between "label" and "sec ond", and when the whole code in inserted into a \begin{center} ... \end{center} I get the error message

line 123: Something's wrong--perhaps a missing \item. ...t line of label \\ second line of label}}
: Unable to redefine math accent \vec.
: You have enabled option `breaklinks'.
line 116: Overfull \hbox (89.58849pt too wide) in paragraph
: Underfull \hbox (badness 10000) has occurred while \output is active

Any idea on how to make this work using pst-tree and pst-node?

1 Answer 1

3

You can get it using the stackengine package, for instance. Demo with two alignments, center and left-aligned:

\documentclass[1pt, pdf, svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{pstricks-add, pst-tree}
\usepackage{stackengine}
\usepackage{xcolor}
\setstackEOL{\\}

\begin{document}

\begin{pspicture}\def\stackalignment{l}
\pstree[nodesep=5pt,levelsep=7em]{ \TR{\Centerstack{first line of label\\ second line of label}}} {
\pstree{ \TR{N2}} {
    \TR{N3}
}
\pstree{ \TR{N4}} {
    \TR{N5}
}
}
\end{pspicture}
\qquad
\begin{pspicture}
\pstree[nodesep=5pt,levelsep=7em]{ \TR{\Centerstack{first line of label\\ second line of label}}} {
\pstree{ \TR{N2}} {
    \TR{N3}
}
\pstree{ \TR{N4}} {
    \TR{N5}
}
}
\end{pspicture}

\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .