[Tex/LaTex] Problem with French accents in TikZ environment

accentsfrenchtikz-pgf

I am creating a spiral, inspired by Mark Wibrow's answer from Text spirals with TikZ.

However, I have a problem. I want to put a text in the spiral that uses French characters and symbols, such as à, é, and so on. Concretely, I want to put the text "On a été à Paris".

As you can see below, I tried adding

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

to the preamble, but unfortunately it gives an error. The console says the error is "Extra \else" and "\pgf@lib@dec@text@char ->\else". It might have something to do with the TikZ package though I'm not sure.

What could be the problem? Does somebody have a fix for this?

The code I'm currently using (and which is not working, though it does work provided you leave out from it the three above-mentioned packages) is as follows:

\documentclass{standalone}
\usepackage{tikz}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usetikzlibrary{decorations.text}

\makeatletter

\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%

\def\pgf@lib@dec@text@dobox{%
    \pgf@lib@dec@text@dobox@original%
    \ifpgfdecorationtextalongpathscaletext%
    \pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
    \setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\box\pgf@lib@dec@text@box}}%
    \fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}

\pgfkeys{/pgf/decoration/.cd,
    text path start scale/.code={%
        \pgfdecorationtextalongpathscaletexttrue%
        \def\pgf@lib@dec@text@startscale{#1}%
    },
    text path end scale/.code={%
        \pgfdecorationtextalongpathscaletexttrue%
        \def\pgf@lib@dec@text@endscale{#1}%
    }
}
\begin{document}    
\begin{tikzpicture}[
    decoration={
    reverse path,
    text along path,
    text path start scale=1.5,
    text path end scale=0,
    text={On a \'et\'e \`a Paris.}}
]
\draw [decorate] 
    (0,0) 
    \foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)}; 
\useasboundingbox (-2.75,-2.75) rectangle (2.75,2.75); 
\end{tikzpicture}    
\end{document}

Best Answer

You must use (cf. pgfmanual, v3.0.1a, p.597):

text={On a {é}t{é} {à} Paris.}

Or:

text={On a {\'e}t{\'e} {\`a} Paris.}

Result:

enter image description here

Code:

\documentclass{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usetikzlibrary{decorations.text}

\makeatletter

\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%

\def\pgf@lib@dec@text@dobox{%
    \pgf@lib@dec@text@dobox@original%
    \ifpgfdecorationtextalongpathscaletext%
    \pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
    \setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\box\pgf@lib@dec@text@box}}%
    \fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}

\pgfkeys{/pgf/decoration/.cd,
    text path start scale/.code={%
        \pgfdecorationtextalongpathscaletexttrue%
        \def\pgf@lib@dec@text@startscale{#1}%
    },
    text path end scale/.code={%
        \pgfdecorationtextalongpathscaletexttrue%
        \def\pgf@lib@dec@text@endscale{#1}%
    }
}
\begin{document}    
\begin{tikzpicture}[
  decoration={
    reverse path,
    text along path,
    text path start scale=1.5,
    text path end scale=0,
    text={On a {é}t{é} {à} Paris. On a vu la tour Eiffel, %
      les jardins du Louvre, %
      le mus{é}e d'Orsay et la Seine.},
  }
]
\draw [decorate] (0,0) \foreach \i [evaluate={\r=(\i/2000)^2;}] in
{0,5,...,2880}{ -- (\i:\r)}; \useasboundingbox (-2.75,-2.75) rectangle
(2.75,2.75);
\end{tikzpicture}    
\end{document}