1

I want to produce 3 versions of the same document in 3 different languages (catalan, spanish and english), also keeping a single source document. For that I define a "doclanguage" macro to which I pass the values 1, 2 or 3, combined with "\ifcase \or \else \fi" structure to print the desired language version of the document.

(I also define a "TFGdate" command to create a date with only the (localised) month and year. I played a bit with the "datetime2" package but I found it a bit confusing and decided to obtain the desired date this way. But I'm sure the \TFGdate macro isn't the culprit.)

The document was large and all went smooth until I decided to insert a TikZ example (in fact, one of the examples of the TikZ manual), then the english version shows no problems but the catalan or spanish versions don't compile, and I don't understand why, although I suspect that the culprit is an obscure babel problem.

I've reduced the code to a MWE that shows the problem:

\documentclass[a4paper,12pt]{book}

\usepackage{tikz} \usetikzlibrary{angles,calc,quotes}

% Setting this to "3" (english) makes the document compile smoothly, % but "1" (catalan) or "2" (spanish) don't compile \newcommand\doclanguage{1}

% Language selection based on the language variable defined above \ifcase\doclanguage\or % Case 1 \usepackage[catalan]{babel} \selectlanguage{catalan}% \newcommand\TFGdate{% \ifcase\month\or% Gener\or Febrer\or Març\or Abril\or Maig\or Juny\or Juliol\or Agost\or Setembre\or Octubre\or Novembre\or Desembre\fi \space de~\number\year% }% \or % Case 2 \usepackage[spanish,es-noquoting]{babel} \selectlanguage{spanish}% \newcommand\TFGdate{% \ifcase\month\or% Enero\or Febrero\or Marzo\or Abril\or Mayo\or Junio\or Julio\or Agosto\or Septiembre\or Octubre\or Noviembre\or Diciembre\fi \space de~\number\year% }% \else % Case 3 (default) \usepackage[english]{babel} \selectlanguage{english}% \newcommand\TFGdate{% \ifcase\month\or% January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\year% }% \fi

\begin{document}

\TFGdate

\begin{figure}[ht] \centering \begin{tikzpicture}[angle radius=.75cm] \node (A) at (-2,0) [red,left] {$A$}; \node (B) at ( 3,.5) [red,right] {$B$}; \node (C) at (-2,2) [blue,left] {$C$}; \node (D) at ( 3,2.5) [blue,right] {$D$}; \node (E) at (60:-5mm) [below] {$E$}; \node (F) at (60:3.5cm) [above] {$F$}; \coordinate (X) at (intersection cs:first line={(A)--(B)}, second line={(E)--(F)}); \coordinate (Y) at (intersection cs:first line={(C)--(D)}, second line={(E)--(F)}); \path (A) edge [red, thick] (B) (C) edge [blue, thick] (D) (E) edge [thick] (F) pic ["$\alpha$", draw, fill=yellow] {angle = F--X--A} pic ["$\beta$", draw, fill=green!30] {angle = B--X--F} pic ["$\gamma$", draw, fill=yellow] {angle = E--Y--D} pic ["$\delta$", draw, fill=green!30] {angle = C--Y--E}; \node at ($ (D)!.5!(B) $) [right=1cm,text width=6cm,rounded corners,fill=red!20,inner sep=1ex] { When we assume that $\color{red}AB$ and $\color{blue}CD$ are parallel, i.,e., ${\color{red}AB} \mathbin{|} \color{blue}CD$, then $\alpha = \gamma$ and $\beta = \delta$. }; \end{tikzpicture} \end{figure}

\end{document}

The compilation with "doclanguage" set to "1" or "2" throws a lot of errors (too long to paste here) starting with:

! Argument of \language@active@arg" has an extra }.
<inserted text> 
                \par 
l.62     pic ["$\alpha$", draw, fill=yellow]
                                               {angle = F--X--A}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument? ! Paragraph ended before \language@active@arg" was complete. <to be read again> ...

If I continue the compilation disregarding the errors (-interaction=nonstopmode) then a result is eventually produced but without the greek letters defined in the angles:

enter image description here

Any ideas? I'm out of them...

  • use the babel tikz library – samcarter_is_at_topanswers.xyz Nov 03 '23 at 11:16
  • As san says, as soon as babel is involved you ought to use the babeltikz module for TikZ to protect itself against active characters. – daleif Nov 03 '23 at 11:18
  • 1
    Sometimes the babel library is not sufficient. I always use also \usepackage[spanish, es-noshorthands, shorthands=off]{babel} and that remove all the problems ;-) (See https://tex.stackexchange.com/questions/314884/babel-active-chars-ifthenelse-and-tikz) – Rmano Nov 03 '23 at 11:19
  • Thanks to all who suggestes the use of "babel" TikZ library. Works like a charm! You cannot imagine how many hours I wasted with that... – Orestes Mas Nov 03 '23 at 11:47

1 Answers1

0

As some people suggested in the comments, the solution is to use the "babel" TikZ library:

\usetikzlibrary{babel}