TransWikia.com

Incompatibility between Tikz-cd and German language under Polyglossia

TeX - LaTeX Asked on February 24, 2021

The following MWE shows a incompatibility between tikz-cd and polyglossia:

documentclass{report}

usepackage{polyglossia}
setmainlanguage{german}

usepackage{tikz-cd}

begin{document}

  begin{tikzcd}
     B arrow{rr}{f} && C
    &A arrow{ul}{phi} arrow[swap]{ru}{psi}
  end{tikzcd}

end{document}

I have seen a few solutions when the problems come from babel like this one here, but the solution does not work for polyglossia under xelatex.

The error is:

! Package pgfkeys Error: I do not know the key '/tikz/"{f}"{}' and I am going t
o ignore it. Perhaps you misspelled it.

One Answer

The german language file makes " active, and older tikz-cd don't expect that and break. But if you just load tikz-cd before polyglossia (thus freezing " as catcode-12), your code will work.

tikz-cd diagrams also use lots of " in them, so if you'll use them you also need to make " an ordinary character there. The babel TikZ library does that for you (loading the babel library is usually a good idea).

documentclass{report}

usepackage{tikz-cd} % Load before polyglossia
usetikzlibrary{babel} % load to use " in pictures

usepackage{polyglossia}
setmainlanguage{german}

begin{document}

begin{tikzcd}
   B arrow{rr}{f} && C
  &A arrow{ul}{phi} arrow[swap]{ru}{psi}
end{tikzcd}

begin{tikzcd}
 A arrow[rd] arrow[r, "phi"] & B 
                                & C
end{tikzcd}

end{document}

Correct answer by Phelype Oleinik on February 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP