0

I have a tree from tikz-qtree that looks like this:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{tikz-qtree}
\tikzset{frontier/.style={distance from root=80pt},
    every leaf node/.style={text=blue}
}

\begin{document}
    
    \begin{tikzpicture}
        
        \Tree
        [.Adj
            [.Adj
                [.alt
                    R-Adj ]
                [.a
                    AF-G ] ]
        [.\node[shape=coordinate] {}; 
            [.s
                AF-N ] ]]
                
    \end{tikzpicture}
    
\end{document}

enter image description here

As you can see, I'm able to add color to the leaves. However, I want to have multiple colors within a single leaf node. For example, I'd like to have "R" be red and "Adj" be blue inside the left-most leaf node. Then, I'd like to have "AF" in the center and right-most nodes be green. And finally, I want the "G" and "N" to be purple and brown, respectively. Is it possible to do something like this using tikz-qtree?

1 Answer 1

2

Something like this:

enter image description here

I'm not sure if I correctly select colors, however, they can be easy changed. MWE is:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-qtree}

\begin{document}
    \begin{tikzpicture}
\tikzset{frontier/.style={distance from root=80pt},
        }
\Tree
    [.Adj
        [.Adj
            [.alt
                \textcolor{red}{R}-\textcolor{blue}{Adj} ]
            [.a
                \textcolor{green}{AF}-G ] 
        ]
        [.\node[shape=coordinate] {};
            [.s
                \textcolor{purple}{AF}-\textcolor{brown}{N} ]
        ]
    ]
    \end{tikzpicture}
\end{document}
1
  • I didn't know \textcolor{}{} worked inside trees. This is such a simple solution. Thanks!
    – Ernesto
    Commented Feb 23, 2022 at 2:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .