RenewDocummentCommand と newdocument コマンドの些細な間違い (構文)

RenewDocummentCommand と newdocument コマンドの些細な間違い (構文)

私はこれを持っていました:

\let\otitle\title
\renewcommand\title[2] {\otitle{#1 \\ \bigskip \large #2\\ \bigskip}}

問題なく動作しました。これを次のように変更しました (xparse):

\RenewDocumentCommand\title{m m} {\otitle{#1 \\ \bigskip \large #2\\ \bigskip}}

オプションパラメータやその他のxparse機能を追加しようとしましたが、実際にはエラーが発生します。

\title{Notes for Grade 7 Math, 2020}
{
   Complied from the 2013 Curriculum Guide
  \thanks{Thanks to Gereina Skanes for presentation and formatting review} 
}

以前は問題なく動作していました。RenewDocumentCommand の構文を理解したと思っていましたが?

答え1

\titleは堅牢なコマンドであり、\letそのようなコマンドを正しくコピーしません。次を使用できます\LetLtxMacro:

\documentclass{article}

\usepackage{letltxmacro}
\LetLtxMacro\otitle\title

\RenewDocumentCommand\title{m m} {\otitle{#1 \\ \bigskip \large #2\endgraf \bigskip}}

\title{abc}{cde}

\begin{document}
\maketitle
\end{document}

次の LaTeX リリースでは、\NewCommandCopy次のコマンドも使用できるようになります。

\documentclass{article}
\NewCommandCopy\otitle\title %new in the next latex ...
\RenewDocumentCommand\title{m m} {\otitle{#1 \\ \bigskip \large #2\endgraf \bigskip}}

\title{abc}{cde}

\begin{document}
\maketitle
\end{document}

関連情報