[Tex/LaTex] \psmatrix baseline

lingmacroslinguisticspstricks

I'm using lingmacros' \enumsentence with a \psmatrix inside.

\enumsentence{
\psset{linewidth=.5pt}
\begin{psmatrix}[rowsep=.2cm,nodesep=.05cm,colsep=.1cm]
&\rnode{gm}{grammatical morphemes}\\
\rnode{m}{\textit{bound}}&&\rnode{s}{free}\\
&\rnode{h}{\textit{head}}&&\rnode{d}{dependent}\\
&&\rnode{c}{\textit{complement}}&&\rnode{mod}{\textit{modifier}}
\ncline{gm}{m}\ncline{gm}{s}
\ncline{s}{h}\ncline{s}{d}
\ncline{d}{c}\ncline{d}{mod}
\end{psmatrix}
}

This results in the example number aligned with the bottom of the
psmatrix. I'd like it to align with the top. Normally, I think,
minipage is used for this sort of thing. However, it seems that
minipage isn't helping in this context (I'm flummoxed as to why.)

I found a thread with what seems to be a similar question here. But I don't see an answer given.

Any ideas?

edit: in reply to a comment, I'm adding a minimal working example:

\documentclass{article}
\usepackage{pstricks,pst-node}
\usepackage{lingmacros}
\begin{document}


\enumsentence{
\psset{linewidth=.5pt}
\begin{psmatrix}[rowsep=.2cm,nodesep=.05cm,colsep=.1cm]
&\rnode{gm}{grammatical morphemes}\\
\rnode{m}{\textit{bound}}&&\rnode{s}{free}\\
&\rnode{h}{\textit{head}}&&\rnode{d}{dependent}\\
&&\rnode{c}{\textit{complement}}&&\rnode{mod}{\textit{modifier}}
\ncline{gm}{m}\ncline{gm}{s}
\ncline{s}{h}\ncline{s}{d}
\ncline{d}{c}\ncline{d}{mod}
\end{psmatrix}
}

\end{document}

The above code compiles but produces the example number aligned with the
baseline of the psmatrix as described above.

Best Answer

One might think of using \adjustbox from the adjustbox package, but it turns out that this package is not compatible with pstricks because they both define \clipbox. A workaround is to emulate what the package does in the case we need:

\documentclass{article}
\usepackage{pstricks,pst-node}
\usepackage{lingmacros}
\newcommand{\tstrut}{\vrule width 0pt height\ht\strutbox depth 0pt}
\begin{document}

\enumsentence{\raisebox{\dimexpr-\height+\ht\strutbox}{%
\psset{linewidth=.5pt}
\begin{psmatrix}[rowsep=.2cm,nodesep=.05cm,colsep=.1cm]
&\rnode{gm}{\tstrut grammatical morphemes}\\
\rnode{m}{\textit{bound}}&&\rnode{s}{free}\\
&\rnode{h}{\textit{head}}&&\rnode{d}{dependent}\\
&&\rnode{c}{\textit{complement}}&&\rnode{mod}{\textit{modifier}}
\ncline{gm}{m}\ncline{gm}{s}
\ncline{s}{h}\ncline{s}{d}
\ncline{d}{c}\ncline{d}{mod}
\end{psmatrix}}%
}

\end{document}

The trick is to lower the psmatrix by its height minus the height of the standard strut. However, the first line in the matrix must be made as high as the strut (but not as deep under the baseline or the lines would be clipped), so I define a "top strut".

enter image description here

Alternatively, you can load adjustbox, but with a trick for making it compatible with pstricks; the macro \clipbox of adjustbox (which is not necessary here) becomes \adjclipbox.

\documentclass{article}
\usepackage{pstricks,pst-node}

%%% trick for using adjustbox
\let\pstricksclipbox\clipbox
\let\clipbox\relax

\usepackage{adjustbox}

\let\adjclipbox\clipbox
\let\clipbox\pstricksclipbox
%%% end

\usepackage{lingmacros}

\begin{document}

\enumsentence{\begin{adjustbox}{valign=t}
\psset{linewidth=.5pt}
\begin{psmatrix}[rowsep=.2cm,nodesep=.05cm,colsep=.1cm]
&\rnode{gm}{grammatical morphemes}\\
\rnode{m}{\textit{bound}}&&\rnode{s}{free}\\
&\rnode{h}{\textit{head}}&&\rnode{d}{dependent}\\
&&\rnode{c}{\textit{complement}}&&\rnode{mod}{\textit{modifier}}
\ncline{gm}{m}\ncline{gm}{s}
\ncline{s}{h}\ncline{s}{d}
\ncline{d}{c}\ncline{d}{mod}
\end{psmatrix}
\end{adjustbox}%
}

\end{document}
Related Question