1

The use of a functionality from the "quotes" library initially gave me an error.

I changed the babel's language from "brazilian" to "english", and it worked.

I went after a fix, and found out about the "babel" library; used it, and so it worked for the "normal" cases, but not inside the macro I defined.

Basically, that's how things are working:

  1. english + (no quote package) = works for all cases
  2. brazilian + (no quote package) = doesn't work
  3. english + (quote package) = works for all cases
  4. brazilian + (quote package) = works outside macros, but not inside these.

Minimal working example:

\documentclass[brazil]{standalone}
\usepackage{tikz,babel}
\usetikzlibrary{babel,angles,quotes}

\newcommand\fig[1]% {\begin{tikzpicture}#1\end{tikzpicture}}%

\begin{document}

\fig{\coordinate (a) at (3.75,3.75); \coordinate (b) at (3.75,0.75); \coordinate (lo) at (0, 0.75); \draw[thick,blue] (0, 0.75) -- (3.75, 3.75); \pic [draw, -,thick,"$\theta$", angle radius=1cm, angle eccentricity=1.3] {angle = a--lo--b};}

\end{document}

It fails when "brazil" language is set, but it works when it's set to english.

  • 1
    Please post a full working MWE so we can replicate the issue. In the meantime also check xparse it comes with LaTeX2e and it is a better alternative than xargs. – yannisl Dec 26 '23 at 23:08
  • Hi, thanks for answering and pointing it out. I just updated my post with the MWE. – name_to_display Dec 26 '23 at 23:58

1 Answers1

3

This issue also applies whit the option german for babel.

The reason is that the argument of the command \fig is not read with the correct catcodes. The tikz library babel resets some catcodes to their normal values at the beginning of every tikzpicture environment but the argument of \fig is read before this applies.

The solution is based on the answer from Is there any way to have a catcode set only inside a macro?.

The command \fig starts with \begingroup. Then it sets the catcode of ". Only after this catcode is changed, the command \figaux is executed. At the end of \figaux, \endgroup is placed.

enter image description here

\documentclass[brazil]{standalone}
\usepackage{tikz,babel}
\usetikzlibrary{babel,angles,quotes}
\newcommand{\fig}{\begingroup\catcode`"=12 \figaux}
\newcommand{\figaux}[1]{\begin{tikzpicture}#1\end{tikzpicture}\endgroup}
\begin{document}
\fig{\coordinate (a) at (3.75,3.75);
  \coordinate (b) at (3.75,0.75);
  \coordinate (lo) at (0, 0.75);
  \draw[thick,blue] (0, 0.75) -- (3.75, 3.75);
  \pic [draw, -,thick,"$\theta$", angle radius=1cm, angle eccentricity=1.3] {angle = a--lo--b};}
\end{document}
matexmatics
  • 4,819