0

I am trying to get a tree like this using the tikz package

enter image description here

and the syntax for this, according to a manual, is

\begin{tikzpicture}[mytree]
\node (top) {DP}
child {node {D\\the}}
child {node {NP}
child {node {Adj\\brown}}
child {node {NP\\dog}}};
\end{tikzpicture}

However, just copying and pasting this code gives me

enter image description here

It seems that \\ is not recognized. Am I missing something here?

1 Answers1

0

You have to add text options to your nodes, for instance, align=center.

Output:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}


\begin{document}

    \begin{tikzpicture}[align=center] %[mytree]
    \node (top) {DP}
    child {node {D\\the}}
    child {node {NP}
    child {node {Adj\\brown}}
    child {node {NP\\dog}}};
    \end{tikzpicture}

\end{document}
Ñako
  • 3,626