The explicit code
\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}
works but if I use a new environment, it fails to compile
\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}
The second example compiles correctly if I comment out the babel
package.
Any ideas on how to fix this? The shorthandoff
suggestions in answers to other similar questions do not seem to work here.
bodeplot
package a while ago, and at the time, I could not figure out how to handle the argument macros correctly using the usual\newenvironment
command. I was able to get it to work using\newenviron
from theenviron
package. The functionality I wanted was the ability to passtikz
commands andpgf
keys to environments inside the newly created environment. For example, write something like\begin{MyEnv}[tikz/{},axes/{}]...
and pass thetikz
options totikzpicture
andaxes
options toaxis
. I got that to work using\newenviron.
environ,
unfortunately, I am better at control theory than LaTeX :-) I'll try to rewrite my package again withoutenviron,
but just wanted to see if anyone has any quick fixes in the meantime...\AddToHook{env/MyEnv/begin}{\shorthandoff{;}}
. Btw: the environ package is no longer needed, a current LaTeX has the functionality in-built.\NewDocumentEnvironment{MyEnv}{omm+b}{...}{}
. Use#4
instead of\BODY
in the content.