1

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?

3

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}
| improve this answer | |
  • That is a great idea, however, the text is not bend "along the path". I figured out (based on the idea of: tex.stackexchange.com/questions/75432/…) 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 6: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 7:55
0

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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.