4

Sorry for the bad English. I'm trying to use the tikz-cd package to make commutative diagrams. My code

\documentclass{article}
\usepackage[brazil]{babel}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
A \ar[r, "x"] & B
\end{tikzcd}
\end{document} 

The problem occurs when putting a name under the arrow, the syntax "x" is incompatible with the brazil option of the babel package. When exchanging brazil for english it works normally. I already tried using

\usepackage[main=brazil, english]{babel}, \usepackage[brazil, english]{babel} e  \usepackage[brazil, main=english]{babel}

But it did not work. I also tried to use

\usepackage[english, brazil]{babel}
\usepackage{polyglossia}
\setmainlanguage{brazil}
\setotherlanguages{english}

And finally

\selectlanguage{english}

However, it only works if I remove the option brazil

  • On my pc with Papeeria I have these errors: Argument of \language@active@arg" has an extra }. [\end{tikzcd}] /main.tex :7 Paragraph ended before \language@active@arg" was complete. [\end{tikzcd}] /main.tex :7 Paragraph ended before \pgfkeys@addpath was complete. [\end{tikzcd}] /main.tex :7 Missing \endcsname inserted. [\end{tikzcd}] /main.tex :7 Paragraph ended before \pgfkeys@splitter was complete. [\end{tikzcd}] /main.tex :6 Package pgfkeys Error: I do not know the key '"x\par ' and I am going to ignore it. Perhaps you misspelled it. [I think the culprit is a tikzcd arrow in cell 1-1.] – Sebastiano Mar 16 '17 at 19:49
  • Is exactly that error that appears to me using Texstudio – Marcelo Rodrigues Mar 16 '17 at 19:56
  • 2
    Use \usetikzlibrary{babel} -- this should remove the error and compile –  Mar 16 '17 at 20:18
  • 3
  • 1
    @Saravanan How is this a duplicate of the linked question? The OP asks for disabling the " shorthand from brazil language, while the linked question asks for enabling it in english. – siracusa Dec 07 '18 at 05:23

2 Answers2

13

The TikZ babel library simplifies the interaction between the babel LaTeX package and TikZ itself, taking care of the catcodes etc. change.

\documentclass{article}
\usepackage[brazil]{babel}
\usepackage{tikz-cd}
\usetikzlibrary{babel}
\begin{document}
\begin{tikzcd}
A \ar[r, "x"] & B
\end{tikzcd}
\end{document} 

enter image description here

4

Now there isn't any errors.

enter image description here

\documentclass[a4paper,12pt, brazil]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}

\usepackage{tikz-cd}
\begin{document}
\shorthandoff{"}
\begin{tikzcd}
A \ar[r, "x"] & B
\end{tikzcd}
\shorthandon{"}
\end{document} 
Sebastiano
  • 54,118