label={45:my text}
当启用 beamer + babel french 时,我无法使用标签语法将标签置于 45 度。我尝试了各种方法[fragile]
,例如\usetikzlibrary{babel}
或\AtBeginEnvironment{tikzpicture}{\shorthandoff{;}\shorthandoff{:}}
,但都不起作用:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage[french]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\usetikzlibrary{babel} % Important, or I get issues on other code when using french babel like "! Package tikz
\NewDocumentEnvironment{mytest}{+b}{
% scantokens makes it *nearly* work, but then it fails again when using \only
\scantokens{#1} % I do want to use +b as in practice I do more involved stuff here, involving recursion etc…
}{}
\begin{document}
\begin{frame}[fragile]
but this fails
\begin{mytest}
\only<1>{ %% without the only, it works when using scantokens
\begin{tikzpicture}
\node[label={45:mylabel},fill=green]{AAA};
\end{tikzpicture}
}
\end{mytest}
\end{frame}
\end{document}
答案1
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage[french]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\usetikzlibrary{babel} % Important, or I get issues on other code when using french babel like "! Package tikz
\NewDocumentEnvironment{mytest}{+b}{%
#1 % I do want to use +b as in practice I do more involved stuff here, involving recursion etc…
}{}
\AddToHook{env/mytest/begin}{\shorthandoff{:}}
\begin{document}
\begin{frame}[fragile]
\begin{mytest}
\begin{tikzpicture}
\node[label={45:mylabel},fill=green]{AAA};
\end{tikzpicture}
\end{mytest}
\end{frame}
\end{document}
您的环境必须尽早取消激活法国冒号;tikzpicture
一旦内容被您的环境抓取和标记,将无法执行任何操作。
顺便说一句,我不熟悉 xparse 语法,所以这里可能缺少一些重要的解释。