
Aquí está mi código, que fue compilado por pdflatex.
\documentclass[11pt]{article}
\usepackage[a5paper,margin=5pt]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{tikz-qtree}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=.6]\Tree
[.(0,0)
[.(0,1)
[.(1,1)
[.(1,2)\\$\downarrow$\\(2,0)
[.(3,0)
[.(4,0)\\$\downarrow$\\\textcolor{olive}{(1,3)} ]
[.\textcolor{olive}{(3,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
[.(0,2)
[.(0,3)
[.(1,3)\\$\downarrow$\\\textcolor{purple}{(4,0)} ]
[.\textcolor{purple}{(0,4)} ]
]
[.(1,2)\\$\downarrow$\\(2,0)
[.(3,0)
[.(4,0)\\$\downarrow$\\\textcolor{olive}{(1,3)} ]
[.\textcolor{olive}{(3,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
]
]
[.(1,0)
[.(2,0)\\$\downarrow$\\(1,2)
[.(1,3)\\$\downarrow$\\\textcolor{purple}{(4,0)} ]
[.\textcolor{blue}{(2,2)} ]
]
[.(1,1)
[.(1,2)\\$\downarrow$\\(2,0)
[.(3,0)
[.(4,0)\\$\downarrow$\\\textcolor{olive}{(1,3)} ]
[.\textcolor{olive}{(3,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
]
]
\end{tikzpicture}
\end{center}
\end{document}
Según la documentación del tikz-qtree
paquete, es posible el uso de \\
para saltos de línea en nodos. Pero el código anterior no se puede compilar correctamente. Si cambio las piezas que \\
lo contienen funcionará.
¿Por que es esto entonces? ¿Cómo puedo romper líneas en un nodo?
Respuesta1
Parece que no has añadido
\tikzset{every tree node/.style={align=center,anchor=north}}
después
\begin{tikzpicture}[scale=.6]
antes de llamar \Tree
. También por si acaso, verifique \pgfversion
si es> 2.1 como dice la documentación
\documentclass[11pt]{article}
\usepackage[a5paper,margin=5pt]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{tikz-qtree}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=.6]
\tikzset{every tree node/.style={align=center,anchor=north}}
\Tree
[.(0,0)
[.(0,1)
[.(1,1)
[.(1,2)\\$\downarrow$\\(2,0)
[.(3,0)
[.(4,0)\\$\downarrow$\\\textcolor{olive}{(1,3)} ]
[.\textcolor{olive}{(3,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
[.(0,2)
[.(0,3)
[.(1,3)\\$\downarrow$\\\textcolor{purple}{(4,0)} ]
[.\textcolor{purple}{(0,4)} ]
]
[.(1,2)\\$\downarrow$\\(2,0)
[.(3,0)
[.(4,0)\\$\downarrow$\\\textcolor{olive}{(1,3)} ]
[.\textcolor{olive}{(3,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
]
]
[.(1,0)
[.(2,0)\\$\downarrow$\\(1,2)
[.(1,3)\\$\downarrow$\\\textcolor{purple}{(4,0)} ]
[.\textcolor{blue}{(2,2)} ]
]
[.(1,1)
[.(1,2)\\$\downarrow$\\(2,0)
[.(3,0)
[.(4,0)\\$\downarrow$\\\textcolor{olive}{(1,3)} ]
[.\textcolor{olive}{(3,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
[.\textcolor{cyan}{(2,1)} ]
]
]
]
\end{tikzpicture}
\end{center}
\end{document}