Tikz-cd not working when using package babel (spanish)

babelcommutative-diagramstikz-cd

I'm trying to make a commutative diagram while using the spanish babel package but I'm encountering some problems.

I've made two MWE; one that doesn't work and one that does:

\documentclass{article}

\usepackage[spanish]{babel}
\usepackage{tikz-cd}

\begin{document}
   \begin{tikzcd}
   G \arrow[d, "\varepsilon"', two heads] \arrow[r, "\varphi"] & H \\
   G/N \arrow[ru, "\varphi"', dashed]                          &  
   \end{tikzcd}
\end{document}

and

\documentclass{article}

\usepackage{tikz-cd}

\begin{document}
   \begin{tikzcd}
   G \arrow[d, "\varepsilon"', two heads] \arrow[r, "\varphi"] & H \\
   G/N \arrow[ru, "\varphi"', dashed]                          &  
   \end{tikzcd}
\end{document}

The former fails to work while the latter works just fine. The only difference being the spanish babel package. I really need to use both the package and the tikz-cd environment. Is there a way of doing so?

Here is a picture of the desired output (which is the result of the second piece of code). I want this while having the spanish babel package loaded.

commutative diagram

Edit: I just noticed that if I remove the names of the arrows (\varepsilon and \varphi) then it compiles just fine (I want to have those though).

Best Answer

Spanish babel makes " into an active character which kills \arrow[d, "\varepsilon"', two heads]

As this is quite common there is a tikz library to fix is, just add

\usetikzlibrary{babel}

after loading tikz-cd and the example compiles again

Related Question