0

Using the text along path decoration option of tikz, I would like to be able to do line breaks in the text.

Obviously, standard commands such as \\ do not work.

Right now, I am using two different decorations one on top of the other (see MWE), which is not really satisfying.

MWE

\documentclass{article}

\usepackage[linguistics]{forest}
\usetikzlibrary{decorations.pathreplacing,decorations.text}

\begin{document}
    
    \begin{forest}
        [ASP,name=pol[\textit{subject}][Asp 
        [asp][POL
        [AdvP[\textit{non},roof]][Pol
        [pol, name=nab][aP
        [~][a'
        [a][root]]]]]]]
        \draw[decorate,semithick,decoration={brace,raise=36pt,amplitude=8pt}](pol)--(nab);
            \draw[decorate,semithick,decoration={text along path,text align=center,raise=50pt,text=essai}](pol)--(nab);
            \draw[decorate,semithick,decoration={text along path,text align=center,raise=50pt+\baselineskip,text=new line on top}](pol)--(nab);
    \end{forest}

\end{document}

enter image description here

1 Answer 1

1

If you place the text as a node along the line of the brace you can use \\ to start a new line, but you must add align to the node options.

Also, it is unclear to me where you want the bottom of the brace, but I suggest you use the node corners to define the brace lines. For example, (pol.north east) for the top of the brace. You can also add a shift to make the brace follow the tree better.

enter image description here

\documentclass{article}

\usepackage[linguistics]{forest}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}
    
    \begin{forest}
        [ASP,name=pol[\textit{subject}][Asp 
        [asp][POL
        [AdvP[\textit{non},roof]][Pol, name=nab
        [pol][aP
        [~][a'
        [a][root]]]]]]]
        \draw[decorate,semithick,decoration={brace,amplitude=8pt}](pol.north east)--
            node[sloped, above=10pt, align=center]{new line on top\\essai}([shift={(.2,.2)}]nab.south east);
    \end{forest}

\end{document}
3
  • This is absolutely perfect, thank you! Jan 6 at 13:52
  • 1
    @VincentKrebs: I made an edit that I think makes the brace look better.
    – Sandy G
    Jan 6 at 13:56
  • I was precisely thinking of the angle being a bit odd, the brace a bit too close to the tree at the bottom, awesome! Thanks! Jan 6 at 14:25

You must log in to answer this question.

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