
Hier ist mein Code, der von pdflatex kompiliert wurde.
\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}
Laut der Paketdokumentation ist tikz-qtree
die Verwendung von \\
für Zeilenumbrüche in Knoten möglich. Der obige Code kann jedoch nicht korrekt kompiliert werden. Wenn ich die Teile ändere, die es enthalten, \\
funktioniert es.
Warum ist das so? Wie kann ich Zeilen in einem Knoten unterbrechen?
Antwort1
Sieht so aus, als hätten Sie nicht hinzugefügt
\tikzset{every tree node/.style={align=center,anchor=north}}
nach
\begin{tikzpicture}[scale=.6]
vor dem Aufruf \Tree
. Überprüfen Sie außerdem vorsichtshalber, \pgfversion
ob es > 2.1 ist, wie in der Dokumentation angegeben
\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}