4

Is it possible to use a linebreak in a text which decorates a path? Consider the following MWE:

% Circular arrows with text
% Author: Tom Bombadil
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.text}
\newcommand*{\mytextstyle}{\sffamily\Large\bfseries\color{black!85}}
\newcommand{\arcarrow}[8]{%
% inner radius, middle radius, outer radius, start angle,
% end angle, tip protusion angle, options, text
  \pgfmathsetmacro{\rin}{#1}
  \pgfmathsetmacro{\rmid}{#2}
  \pgfmathsetmacro{\rout}{#3}
  \pgfmathsetmacro{\astart}{#4}
  \pgfmathsetmacro{\aend}{#5}
  \pgfmathsetmacro{\atip}{#6}
  \fill[#7] (\astart:\rin) arc (\astart:\aend:\rin)
       -- (\aend+\atip:\rmid) -- (\aend:\rout) arc (\aend:\astart:\rout)
       -- (\astart+\atip:\rmid) -- cycle;
  \path[font = \sffamily, decoration = {text along path, text = {|\mytextstyle|#8},
    text align = {align = center}, raise = -0.5ex}, decorate]
    (\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid);
}

\begin{document}
\begin{tikzpicture}
  \fill[even odd rule,red!30] circle (3.8) circle (3.2);
  \foreach \x in {0,60,...,300} {
    \arcarrow{3}{3.5}{4}{\x+20}{\x+70}{5}{red,
      draw = red!50!black, very thick}{a very long text that wants to be split into multiple lines \x}
  }
\end{tikzpicture}
\end{document}

Using '\\' does not compile. I had a look at http://tug.ctan.org/info/visualtikz/VisualTikZ.pdf, however, it doesn't seem to be possible, per se. Any ideas?

optional
  • 161
  • 5

3 Answers3

2

this?

enter image description here

% Circular arrows with text
% Author: Tom Bombadil
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.text}
\newcommand*{\mytextstyle}{\sffamily\Large\bfseries\color{black!85}}
\newcommand{\arcarrow}[8]{%
% inner radius, middle radius, outer radius, start angle,
% end angle, tip protusion angle, options, text
  \pgfmathsetmacro{\rin}{#1}
  \pgfmathsetmacro{\rmid}{#2}
  \pgfmathsetmacro{\rout}{#3}
  \pgfmathsetmacro{\astart}{#4}
  \pgfmathsetmacro{\aend}{#5}
  \pgfmathsetmacro{\atip}{#6}
  \fill[#7] (\astart:\rin) arc (\astart:\aend:\rin)
       -- (\aend+\atip:\rmid) -- (\aend:\rout) arc (\aend:\astart:\rout)
       -- (\astart+\atip:\rmid) -- cycle;
  \path[font = \sffamily, decoration = {text along path, text = {|\mytextstyle|#8},
    text align = {align = center}, raise = -0.5ex}, decorate]
    (\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid);
}

\begin{document}
\begin{tikzpicture}
  \fill[even odd rule,red!30] circle (3.8) circle (3.2);
  \foreach \x in {0,60,...,300} {
    \arcarrow{3}{3.5}{4}{\x+20}{\x+70}{5}{red,
      draw = red!50!black, very thick}{%
{\footnotesize\begin{tabular}{@{}c@{}}
a very long text\\
that wants to be\\
split into multiple\\
lines
\end{tabular}}
\x}
  }
\end{tikzpicture}
\end{document}
David Carlisle
  • 757,742
  • 1
    That is a great idea, however, the text is not bend "along the path". I figured out (based on the idea of: https://tex.stackexchange.com/questions/75432/curved-text-on-multiple-lines-within-curved-arrow-using-tikz) that splitting the text manually by adding multiple postaction={decoration = {text along path, text align = {align = center}, text={a very long text}}, decorate}, postaction={decoration = {text along path, text align = {align = center}, text={that wants to be split}, raise=-2ex}, decorate}, ..., and then using the "raise" parameter to adjust the paths works for me :) – optional Jul 10 '19 at 06:57
  • 1
    @optional can you post a self answer and accept it to get this off the list of questions, thanks. – David Carlisle Jul 10 '19 at 07:55
2

Based on the idea of Curved text (on multiple lines) within curved arrow using tikz using multiple postactions, I ended up with the following solution (which might be improved, but works for my needs):

enter image description here

% Circular arrows with text
% Author: Tom Bombadil
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.text}
\newcommand*{\mytextstyle}{\sffamily\Large\bfseries\color{black!85}}
\newcommand{\arcarrow}[8]{%
% inner radius, middle radius, outer radius, start angle,
% end angle, tip protusion angle, options, text
  \pgfmathsetmacro{\rin}{#1}
  \pgfmathsetmacro{\rmid}{#2}
  \pgfmathsetmacro{\rout}{#3}
  \pgfmathsetmacro{\astart}{#4}
  \pgfmathsetmacro{\aend}{#5}
  \pgfmathsetmacro{\atip}{#6}
  \fill[#7] (\astart:\rin) arc (\astart:\aend:\rin)
       -- (\aend+\atip:\rmid) -- (\aend:\rout) arc (\aend:\astart:\rout)
       -- (\astart+\atip:\rmid) -- cycle;
  \foreach \x/\y in #8 
  {
    \path[{postaction={decoration = {text along path, text align = {align = center}, text={\x}, reverse path, raise=\y ex}, decorate}}] (\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid);
  }
}
\begin{document}
\begin{tikzpicture}
  \fill[even odd rule,red!30] circle (3.8) circle (3.2);
  \foreach \x in {0,60,...,300} {
    \arcarrow{2.75}{3.5}{4}{\x+20}{\x+70}{5}{red,
      draw = red!50!black, very thick}{{a very long text/1.5, that wants to be/-0.5, split into multiple/-2.5, lines/-4.5}}
  }
\end{tikzpicture}
\end{document}
optional
  • 161
  • 5
0

The answer below uses the wheelchart package, which I wrote.

The text in the key arc data can contain \\ to split the text over multiple lines.

This text is centered with the key arc data pos=0.5.

The arrow is obtained with the key slices arrow={-0.6}{0}.

enter image description here

\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\sffamily
\fill[red!30,even odd rule] (0,0) circle[radius=3.8] circle[radius=3.2];
\wheelchart[
  arc data=a very long text\\that wants to be\\split into multiple\\lines,
  arc data angle shift=-5,
  arc data expand=f,
  arc data pos=0.5,
  gap polar=5,
  radius={2.8}{4.2},
  slices arrow={-0.6}{0},
  slices style={red,draw=red!50!black,very thick},
  total count=6
]{}
\end{tikzpicture}
\end{document}
matexmatics
  • 4,819