pdflatex 사용 시 expl3 확장 오류

pdflatex 사용 시 expl3 확장 오류

에 대한 답변을 찾고 있습니다.이 질문with pdflatex확장과 관련된 오류가 발생했습니다 . 예를 들어 :\$expl3

\documentclass{article}

\ExplSyntaxOn
\NewDocumentCommand{\test}{ m }
  {
    \tl_set:Ne \l_tmpa_tl { #1 }
    \tl_use:N \l_tmpa_tl
  }
\ExplSyntaxOff

\begin{document}

\newcommand*{\mystring}{Special: Five (5) bananas for \$1.50.}

\test{\mystring}

\end{document}

인상

! TeX capacity exceeded, sorry [input stack size=10000].
\font@name ->
             \OT1/cmr/m/n/10 
l.15 \test{\mystring}
                            
!  ==> Fatal error occurred, no output PDF file produced!

lualatex또는 를 사용 xelatex하면 오류 없이 코드가 컴파일됩니다 \$.

왜?

답변1

OT1에서 동일한 위치를 공유 하고 전환하기 위해 새 글꼴을 설정해야 하기 때문에 인수 \$와 같은 확장 컨텍스트에서 안전하지 않은 기본 OT1 인코딩을 사용하고 있습니다 .e£$

인수를 사용하지 않거나 인수 에서 확장되지 않도록 을 e정의 하거나 확장 컨텍스트에서 안전한 인코딩을 사용하세요 .\mystring\protectede\$

따라서 다음 선택 중 하나를 선택하세요.

\documentclass{article}

\ExplSyntaxOn
\NewDocumentCommand{\test}{ m }
  {
    \tl_set:Nn \l_tmpa_tl { #1 }
    \tl_use:N \l_tmpa_tl
  }
\ExplSyntaxOff

\begin{document}

\newcommand{\mystring}{Special: Five (5) bananas for \$1.50.}

\test{\mystring}

\end{document}

또는

\documentclass{article}

\ExplSyntaxOn
\NewDocumentCommand{\test}{ m }
  {
    \tl_set:Ne \l_tmpa_tl { #1 }
    \tl_use:N \l_tmpa_tl
  }
\ExplSyntaxOff

\begin{document}

\NewDocumentCommand\mystring {} {Special: Five (5) bananas for \$1.50.}

\test{\mystring}

\end{document}

또는

\documentclass{article}

\usepackage[T1]{fontenc}

\ExplSyntaxOn
\NewDocumentCommand{\test}{ m }
  {
    \tl_set:Ne \l_tmpa_tl { #1 }
    \tl_use:N \l_tmpa_tl
  }
\ExplSyntaxOff

\begin{document}

\newcommand{\mystring}{Special: Five (5) bananas for \$1.50.}

\test{\mystring}

\end{document}

관련 정보