1

I want to be able to put items to the left or right of the tree structure in the following example. How can I do that? At the moment each tree occupies a line.

\documentclass[12pt,a4paper]{article} 
\usepackage{tikz-qtree} 
\usepackage{tikz-qtree-compat}

\begin{document}

\begin{tikzpicture}
\Tree [.X X Y ]
\end{tikzpicture}

\end{document}

enter image description here

  • Because the tikzpicture is an hbox, simply before \begin{tikzpicture} \Tree [.X X Y ] \end{tikzpicture} after will place text to the left and right of the tree. Am I misunderstanding? – Steven B. Segletes Jun 11 '15 at 16:38
  • It didn't seem to work before. ;) – user65526 Jun 11 '15 at 16:40
  • If you had blank lines above/below the tikzpicture, it would interpret it as a paragraph boundary and surrounding text would therefore be above and below, as opposed to either side. Welcome to the site. – Steven B. Segletes Jun 11 '15 at 16:59
3

Just some pictures...

bark of the shark

\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}

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.