비머 프레임 내에서 \newcommand 사용 중 오류가 발생했습니다.

비머 프레임 내에서 \newcommand 사용 중 오류가 발생했습니다.

어떤 이유로 내beamer\newcommand프레젠테이션이 환경 내에 배치 되면 컴파일되지 않습니다 frame. 다음은 최소한의 작업 예입니다.

\documentclass{beamer}

\begin{document}

\begin{frame}{First slide}
  \newcommand{\asdf}[1]{What is the #1 problem?}
\end{frame}

\end{document}

다음 오류가 발생합니다.

\test 정의에 잘못된 매개변수 번호가 있습니다.

매크로 \asdf는 정의된 후에도 사용되지 않습니다. 이상하게도 정의를 환경 외부에 배치하면 frame모든 것이 잘 작동합니다. 이 이상한 행동의 이유는 무엇입니까?

답변1

추가하면 fragile문제가 해결됩니다.

\documentclass{beamer}

\begin{document}

\begin{frame}[fragile]{First slide}
  \newcommand{\asdf}[1]{What is the #1 problem?}
\end{frame}

\end{document}

관련 정보