13

Following this example, I write:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
    decorations.text,
    }
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (6,0);
\draw[->, >=latex, blue!20!white, bend left=20, line width=15pt] (a) to (b) ;
\draw [bend left=20, decoration={raise=-0.8ex,text along path, text={{$start$}.}, text align={align=left}}, decorate] (a) to (b);
\draw [bend left=20, decoration={raise=-0.8ex,text along path, text={{$end\qquad$}.}, text align={align=right}}, decorate] (a) to (b);
\end{tikzpicture}
\end{document}

But, if I remove the "." characters, latex either repeats the text forever or else goes into an infinite loop.

Neil G
  • 17,947

1 Answers1

12

Instead of your . use an empty pair of {}.

Instead of that \qquad hack I present

text align/right indent=1cm

That, sadly, does not work with em units …

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (6,0);
\draw[->, >=latex, blue!20!white, bend left=20, line width=15pt] (a) to (b) ;
\draw [name=reusepath,bend left=20, decoration={raise=-0.8ex,text along path, text={{$start$}{}}}, decorate] (a) to (b);
\draw [bend left=20, decoration={raise=-0.8ex,text along path, text={{$end$}}, text align/right indent=1cm, text align=right}, decorate] (a) to (b);
\end{tikzpicture}
\end{document}

Output

enter image description here

From the beamer manual

It is only possible to typeset text in math mode under considerable restrictions. Math mode is entered and exited using any character of category code 3 (e.g., in plain TeX this is $). Math subscripts and superscripts need to be contained within braces (e.g., {^y_i}) as do commands like \times or \cdot. However, even modestly complex mathematical typesetting is unlikely to be successful along a path (or even desirable).


Update

I allowed myself to "clean" your code a little bit, so that only one path is generated and the decorations are declared as a postaction.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text,intersections}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (6,0);
\draw[->, >=latex,
      blue!20!white,
      bend left=20,
      line width=15pt,
      postaction={decorate,decoration={
          raise=-0.8ex,
          text along path,
          text={{$start$}{}}
        }
      },
      postaction={decorate,decoration={
          raise=-0.8ex,
          text along path,
          text={{$end$}},
          text align/right indent=1cm,
          text align=right
        }
      }
  ] (a) to (b) ;
\end{tikzpicture}
\end{document}
Qrrbrbirlbel
  • 119,821
  • I like the cleaned code! – Neil G Oct 01 '12 at 14:01
  • @NeilG While the indention is for the humans to be able to read the code easier, the implementation with postaction is easier to maintain, because you only have to change one path, not three, when you want a different path. – Qrrbrbirlbel Oct 01 '12 at 14:06
  • Excellent point. In my case, I'm actually generating all of the tikz code using Python, so it's not so bad :) – Neil G Oct 01 '12 at 15:27