%20%ED%8C%A8%ED%82%A4%EC%A7%80%20%EA%B0%84%EC%9D%98%20%EC%B6%A9%EB%8F%8C.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}
두 번째 예제는 패키지를 주석 처리하면 올바르게 컴파일됩니다 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}