0

I'm having some trouble trying to create the following diagram using tikzcd.yichuanshen.de: enter image description here

My document header is

\documentclass[12pt,openright,oneside,a4paper,english,brazil]{abntex2}
\usepackage[utf8]{inputenc}
\usepackage{tikz-cd}

The site has generated the following code:

\begin{tikzcd}
n_1 \arrow[rr, "R"] \arrow[rd, "at"'] &                                                                              & n_2 \\
                                      & f_1 \arrow[ru, "at^{-1}"'] \arrow["S"', loop, distance=2em, in=305, out=235] &    
\end{tikzcd}

I'm getting this result with several error messages:

enter image description here

Any ideas on what's the problem?

1 Answers1

1

Your example produces an error. The problem is that abntex2 loads babel with the brazil option, which changes the catcode of ". See this answer for more info. Unlike in that problem though, loading the babel tikzlibrary does fix the issue.

\documentclass[12pt,openright,oneside,a4paper,english,brazil]{abntex2}
% \usepackage[utf8]{inputenc} %% not needed
\usepackage{tikz-cd}
\usetikzlibrary{babel} %% added

\begin{document}

\begin{tikzcd} n_1 \arrow[rr, "R"] \arrow[rd, "at"'] & & n_2 \ & f_1 \arrow[ru, "at^{-1}"'] \arrow["S"', loop, distance=2em, in=305, out=235] &
\end{tikzcd}

\end{document}

Note that \usepackage[utf8]{inputenc} is not needed with up-to-date LaTeX.

mbert
  • 4,171
  • Thank you! It works! – Meier_Kreis Nov 04 '22 at 03:36
  • I apologize for returning to this question after already having accepted the answer, but is there any chance this solution wouldn't work inside footnotes? The usual problem with tikz-cd and footnotes seems to be related to the use of the ampersand but the suggested solution to this (using ampersand replacement=&) does not appear to be working when I do it. – Meier_Kreis Nov 05 '22 at 20:29
  • I'm not so sure commutative diagrams in footnotes is good style, but you can use the solution of the linked answer, i.e. setting \shorthandoff{"} before the footnote and \shorthandon{"} after. – mbert Nov 05 '22 at 20:42