3

I have already been searching for this some time, but unfortunately I cannot find an answer. I am trying to write some text that is following a given curve. As long as I do not use math mode that works out fine. However, I need some formulas resp. symbols in that text too, so, is there a way to obtain that? It should be something like this:

\begin{tikzpicture}
    \path [decorate,decoration={text along path,
        text={$t\rightarrow t_0$}}]
        (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0) sin (7,-1);
\end{tikzpicture}

There is of course some more text coming, but just to give an idea...

4

The text along path decorations works by placing the text character for character. In your case, it tries to place the characters $, t, \rightarrow, t, _, 0 and $ on their own. This will lead to many errors ($ without a closing $, math-mode stuff in text-mode).

You will need to split the “text” up in its contents (the spacing provided by math-mode will be lost but this decoration isn’t made for that anyway).

Code

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{decorations.text}
\tikzset{
  text deco/.style={
    postaction={decorate, decoration={text along path, #1}}}}
\begin{document}
\begin{tikzpicture}
  \draw[
    text deco={raise=5pt, text align={align=left, left indent=11em},
      text={$t$} {$\rightarrow$} {$t_0$}},
    text deco={raise=5pt, text align={align=left, left indent=15.5em},
      text={$t$} {$\rightarrow$} {$t_0$}},
    text deco={raise=-5pt,
    text=|\color{gray}|........................%
         |+\bfseries|........................%
         |\color{blue!50}|.............................................}
  ]
    (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0) sin (7,-1);
\end{tikzpicture}
\end{document}

Output

enter image description here

| improve this answer | |
  • I think we need curved \to here. (I have no backticks on my iPad) – kiss my armpit Oct 14 '13 at 5:55

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.