
以下は 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}
パッケージのドキュメントによるとtikz-qtree
、ノード内での改行に を使用すること\\
は可能です。しかし、上記のコードは正しくコンパイルできません。 を含む部分を変更すれば\\
動作します。
なぜでしょうか? ノード内で行を区切るにはどうすればよいのでしょうか?
答え1
追加されていないようです
\tikzset{every tree node/.style={align=center,anchor=north}}
後
\begin{tikzpicture}[scale=.6]
を呼び出す前に\Tree
。また、念のため、\pgfversion
ドキュメントに記載されているように、2.1以上であるかどうかを確認してください。
\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}