在下面这个例子中,我希望能够将项目放在树结构的左侧或右侧。我该怎么做?目前,每棵树占据一行。
\documentclass[12pt,a4paper]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\begin{document}
\begin{tikzpicture}
\Tree [.X X Y ]
\end{tikzpicture}
\end{document}
答案1
只是一些图片...
\documentclass[a4paper]{article}
\usepackage{tikz-qtree,tikz-qtree-compat,forest}
\begin{document}
The base of the following tree is aligned with the baseline \begin{tikzpicture}[baseline=(current bounding box.south)]
\Tree [.X X Y ]
\end{tikzpicture}, whereas the top of the next is aligned with the baseline \tikz[baseline=(current bounding box.north)]{\Tree [.X X Y ]} and the baseline is aligned with the centre of the next one \tikz[baseline=(current bounding box.center)]{\Tree [.X X Y ]}.
\forestset{
parent anchor=south,
child anchor=north,
mycomma/.style={%
before drawing tree={
content/.wrap value={##1,},
typeset node
}
},
baseline/.append style={text=red},
}
Any node of a tree may be aligned with the baseline quite easily.
For example,
\begin{forest}[A, baseline, mycomma [B [D] [E]] [C [F] [G]]]\end{forest}
\begin{forest}[A [B, baseline, mycomma [D] [E]] [C, mycomma [F] [G]]]\end{forest}
\begin{forest}[A [B [D, baseline, mycomma] [E, mycomma]] [C [F, mycomma] [G, mycomma]]]\end{forest}
and \begin{forest}[A [B [D] [E [H., baseline]]] [C [F] [G]]]\end{forest}
\fbox{\begin{minipage}[c]{.35\textwidth}
This is some information
about the tree
on the right
which is quite
upright
--- for a tree.
\end{minipage}}
\fbox{\begin{forest}
[A[B[C]]]
\end{forest}}
\fbox{\begin{minipage}[t]{.25\textwidth}
This is the weft
from the left
--- not the warp
or the gawp.
\end{minipage}}
\fbox{\begin{minipage}[b]{.25\textwidth}
Far on the side,
safe from the tide,
shark of the bark.
\end{minipage}}
\end{document}