2

I've recently tried the tikz wheel from this other thread: https://tex.stackexchange.com/a/423907/140011 - it all works fine until I switched polyglossia to german.

This fails with

Extra }, or forgotten \endgroup.

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        \pgfmathparse{(5? "west" : "east" )}  % Apprently these quotes are  the culprit.
    \end{tikzpicture}
\end{document}

This works

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        \pgfmathparse{(5? 5 : 4 )} % This does not make sense but works
    \end{tikzpicture}
\end{document}

As we can easily see the quotes around east seem to be problem.

How can I bypass this?

nhck
  • 740

1 Answers1

2

Edit: Phelype Oleinik beat me to this in a comment.

The polyglossia package is setting the " character active in order to enable babel-style shorthands, which breaks it in pgf. You want to load the babel TikZ library for compatibility:

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{babel}

\begin{document} \begin{tikzpicture} \pgfmathparse{(5? "west" : "east" )} % Apprently these quotes are the culprit. \end{tikzpicture} \end{document}

You can additionally give either \usepackage{polyglossia} or \setdefaultlanguage{german} the option [babelshorthands=false], although this is not enough for your MWE to compile.

You could also use \tikz[handle active characters in code] to enable active characters in node text, without breaking pgf parsing.

Davislor
  • 44,045