
오랫동안 나는 LaTeX가 명령을 확장하는 방법을 이해했다고 생각했습니다. 하지만 분명히 그렇지 않습니다.
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\edef\r{1 and 2}
\draw (0,0) ellipse (2 and 4); % this works
\draw (0,0) ellipse (\r); % this causes the error
\end{tikzpicture}
\end{document}
위 코드를 컴파일하려고 하면 다음 오류가 발생합니다.
! Package PGF Math Error: Unknown operator `a' or `an' (in '1 and 2').
위 오류가 발생하는 이유와 이 문제를 피하기 위해 수행할 수 있는 작업이 무엇인지 설명해 줄 수 있는 사람이 있습니까?
답변1
이 문제는 너무나 널리 퍼져 있어 PGF는 실제로 이를 우회하는 정식 방법을 개발합니다.
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\edef\r{1 and 2}
\draw (0,0) ellipse (2 and 4); % this works
\edef\pgfmarshal{\noexpand\draw (0,0) ellipse (\r);}
\pgfmarshal
\end{tikzpicture}
\end{document}
\pgf@marshal
( 전체 패키지에 232개가 있습니다 .)