1

I'm trying to create a listing, with pstricks, that has its entrys on top of the line. Unlike normal tree nodes/leaves, the entry is not at the end.

The clue is now to left (or right) align all entries on an imaginary vertical line.

It might be possible, that array is a better alternative. If so, please argue for that.

My MWE looks like this (without alignment, the line indicates the alignment I want). Picture below.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{pstricks,pst-tree}
\begin{document}

\begin{pspicture}
    \rput(0,0){
        \pstree{\Tdot}{%Top Root
            \pstree{%first line down
                \pstree[treemode=R,levelsep=3cm]{%first line right
                    \Tp
                }{
                \Tp
                \taput[labelsep=3pt,tnpos=l]{Level A}
            }
        }{    
        \pstree{%second line down
                \pstree[treemode=R,levelsep=3cm]{%second line right
                    \Tp
                }{
                    \Tp
                    \taput[labelsep=3pt,tnpos=l]{LevelLevel B}
                }
            }{
                \Tp%third line down
            }
        }
    }
}

%Align along this line..
\psline(-1,3)(-1,-2)
\uput[ur](-1,3){align here}
\end{pspicture}

\end{document}

enter image description here

1
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{pst-tree}
\def\Txt#1{\makebox[2cm][l]{#1}}
\begin{document}

        \pstree{\Tdot}{%Top Root
            \pstree{%first line down
                \pstree[treemode=R,levelsep=3cm]{%first line right
                    \Tp
                }{
                \Tp
                \taput[labelsep=3pt]{\Txt{Level A}}
            }
        }{    
        \pstree{%second line down
                \pstree[treemode=R,levelsep=3cm]{%second line right
                    \Tp
                }{
                    \Tp
                    \taput[labelsep=3pt]{\Txt{LevelLevel B}}
                }
            }{
                \Tp%third line down
            }
        }
    }

\end{document}

enter image description here

  • Very nice, I would have never come up with the makebox trick. Thank you! – Felipe Nov 11 '14 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.