tikz에서 \\를 사용한 줄바꿈 문제

tikz에서 \\를 사용한 줄바꿈 문제

다음은 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}

관련 정보