TransWikia.com

TikZ conflicts with babel on beamer

TeX - LaTeX Asked on December 8, 2021

I’m trying to draw commutative diagrams with tikz-cd in a LaTeX presentation but I repeatedly get the error "! Argument of language@active@arg" has an extra }.".

documentclass{beamer}

usepackage{tikz-cd}

usepackage[ngerman]{babel}
usetikzlibrary{babel}

tikzset{
  every picture/.prefix style={
    execute at begin picture=shorthandoff{"}
  }
}

begin{document}
begin{frame}
begin{center}
begin{tikzcd}[ampersand replacement=&]
F(x) arrow[r, "a"] & G(x)
end{tikzcd}
end{center}
end{frame}
end{document}

Searching through this forum, I found several suggestions with shorthandoff{"} or usetikzlibrary{babel}. However, neither helps resolving the error (nor using both of them as in the above example code).

The code works without the "a" part in arrow[r, "a"] and I also never had problems using tikzcd in english documents.

Where is my mistake and how can I possibly fix it?

2 Answers

Another possibility is to use a different sintax to arrows so you don't have to turn off the shorthands:

documentclass{beamer}

usepackage{tikz-cd}

usepackage[ngerman]{babel}
usetikzlibrary{babel}

begin{document}
begin{frame}
begin{center}
begin{tikzcd}[ampersand replacement=&]
F(x) arrow[shift left]{r}{a} arrow[shift right]{r}[swap]{b} & G(x)
end{tikzcd}
end{center}
end{frame}
end{document}

enter image description here

Answered by Luis Turcio on December 8, 2021

See if the following workaround work for you:

documentclass{beamer}
usepackage[ngerman]{babel}
usepackage{tikz-cd}
usetikzlibrary{babel}

usepackage{etoolbox}                       % <---
AtBeginEnvironment{frame}{shorthandoff{"}}% <---

begin{document}
begin{frame}
Some "text" dots
    begin{center}
begin{tikzcd}[ampersand replacement=&]
F(x) arrow[r, "a"] & G(x)
end{tikzcd}
    end{center}
end{frame}
end{document}

enter image description here

Answered by Zarko on December 8, 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