Babel、tikz 和 Beamer 不能一起工作

Babel、tikz 和 Beamer 不能一起工作

以下程式碼無法建置並顯示訊息

! Argument of \language@active@arg" has an extra }.

\documentclass[dvipsnames,unknownkeysallowed,12pt]{beamer}
\usepackage[brazil]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,babel,calc,angles,quotes}
\usepackage{tikzsymbols}
\begin{document}
\section{Figura}
\begin{frame}
         TiKz   \pgfversion
\begin{tikzpicture}
\draw [thick]
(3,-1) coordinate (a) node[right] {a} -- (0,0) coordinate (b) node[left] {b} 
-- (2,2) coordinate (c) node[above right] {c} pic["$\alpha$", thick,draw=orange, <->, angle eccentricity=1.2, angle radius=1cm] {angle=a--b--c};
\end{tikzpicture}
\end{frame}
\end{document}

然而,如果 brazil babel line 被註解或 tikzpicture 是在框架之外建構的,它就可以工作。\pgfversion顯示 3.0.0。

答案1

TikZ 庫提供的機制babel包括"在啟動tikzpicture.本質上,它相當於在\shorthandoff{"}後面添加\begin{tikzpicture}

不幸的是,這在 Beamer 中不起作用frame,因為幀的內容在處理之前被吸收,因此字元令牌獲得其類別代碼,任何\shorthandoff{"}命令都無法再更改該類別代碼。

解決方法(我知道有點難看): use \begin{frame}[fragile],這使得 Beamer 寫出框架的內容以供以後重讀。

請注意\end{frame},在這種情況下,必須從最左邊的列開始,前面沒有任何空格。

相關內容