
どういうわけか私のbeamer
\newcommand
presentation は環境内に配置されている場合コンパイルされません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}