%20%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%AE%E8%A1%9D%E7%AA%81.png)
明示的なコード
\documentclass{standalone}
\usepackage[french]{babel}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{babel}
\begin{document}
\begin{tikzpicture}
\begin{semilogxaxis}[
xmin=1e-1,
xmax=1e4,
ymin=0,
ymax=1
]
\draw[thick,blue,dashed] (axis cs:1,0) -- (axis cs:100,1);
\end{semilogxaxis}
\end{tikzpicture}
\end{document}
動作しますが、新しい環境を使用するとコンパイルに失敗します
\documentclass{standalone}
\usepackage{pgfplots,environ}
\usepackage[french]{babel}
\usetikzlibrary{babel}
\pgfplotsset{compat=1.18}
\NewEnviron{MyEnv}[3][]{
\begin{tikzpicture}
\begin{semilogxaxis}[
xmin={#2},
xmax={#3},
ymin=0,
ymax=1
]
\BODY
\end{semilogxaxis}
\end{tikzpicture}
}
\begin{document}
\begin{MyEnv}[]{1e-1}{1e4}
\draw[thick,blue,dashed] (axis cs:1,0) -- (axis cs:100,1);
\end{MyEnv}
\end{document}
2 番目の例は、パッケージをコメント アウトすると正しくコンパイルされますbabel
。
これを修正する方法について何かアイデアはありますか?shorthandoff
他の同様の質問への回答の提案は、ここでは機能しないようです。
答え1
編集:これを行うより良い方法は、現在のショートカットのリストを生成し、それらをすべて無効にすることです。この答えのようなショートカットを手動で無効にすると、がショートカットでない;
場合、エラーが発生する可能性があります(以下のコメントを参照)。;
元の回答: コメントで@UlrikeFischerが示唆したように、
\AddToHook{env/MyEnv/begin}{\shorthandoff{;}}
アクティブ文字を処理するためにパッケージが使用されています。このenviron
パッケージはライブラリとの競合を避けるために使用されていますtikz
external
。このパッケージはxparse
environ.
\documentclass{standalone}
\usepackage[french]{babel}
\usepackage{xparse}
\usetikzlibrary{babel,external}
\tikzexternalize[prefix=figure]
\pgfplotsset{compat=1.18}
\AddToHook{env/MyEnv/begin}{\shorthandoff{;}}
\NewDocumentEnvironment{MyEnv}{O{}mm+b}{
\begin{tikzpicture}
\begin{semilogxaxis}[xmin={#2},xmax={#3},ymin=0,ymax=1]
#4
\end{semilogxaxis}
\end{tikzpicture}
}{}
\begin{document}
\begin{MyEnv}[]{1e-1}{1e4}
\draw[thick,blue,dashed] (axis cs:1,0) -- (axis cs:100,1);
\end{MyEnv}
\end{document}