AnswerBun.com

TikZ conflicts with babel on beamer

I’m trying to draw commutative diagrams with tikz-cd in a LaTeX presentation but I repeatedly get the error "! Argument of [email protected]@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?

TeX - LaTeX Asked on December 8, 2021

2 Answers

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!

Related Questions

Footnote without reference

2  Asked on August 11, 2021 by saurus

   

Use custom delimiter for inline minted environment

1  Asked on August 11, 2021 by migwell

     

Help with Tikz graphic

1  Asked on August 10, 2021 by frank-zafka

   

Overriding table alignment for linguistic glossing

1  Asked on August 10, 2021 by daniel-harbour

     

Redefining chapter for indices

0  Asked on August 10, 2021 by seabody

   

Compile LaTeX document to PNG automatically

2  Asked on August 10, 2021 by user363808

       

Filldraw square in tikz

1  Asked on August 10, 2021 by firdous-ahmad-mala

 

Figure with long caption on side, wrapping under it

0  Asked on August 10, 2021 by panos

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.