RenewDocumentCommand 與 newdocument 指令的小錯誤(語法)

RenewDocumentCommand 與 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}

相關內容