巨集 - renewcommand 的問題

巨集 - renewcommand 的問題

我正在使用 book 類,並且我想更新其現有命令 \@makechapterhead。原始指令顯示在第 32 頁這個文件。特別是,我想將第 811 行的間距從 50 更改為 30,所以我執行了以下操作

\renewcommand{\@makechapterhead}{
     \def\@makechapterhead#1{%
        \vspace*{30\p@}%
        {\parindent \z@ \raggedright \normalfont
     \ifnum \c@secnumdepth >\m@ne
 ⟨book⟩     \if@mainmatter
         \huge\bfseries \@chapapp\space \thechapter
         \par\nobreak
         \vskip 20\p@
      \fi
⟨book⟩    \fi
    \interlinepenalty\@M
      \Huge \bfseries #1\par\nobreak
      \vskip 40\p@
    }}
}

但我收到一條錯誤訊息,指出 \@makechapterhead 定義中的參數編號非法。我該如何解決?

謝謝。

答案1

您可以在文件的序言中新增:

\makeatletter
\let\@makechapterhead@ori\@makechapterhead
\renewcommand{\@makechapterhead}[1]{\vspace*{-20\p@}\@makechapterhead@ori{#1}}
\makeatother

的原始定義\@makechapterhead已備份在 中\@makechapterhead@ori。接下來,加入 20pt 的負垂直,然後\@makechapterhead套用原始內容。結果,您得到了所需的 50-20 = 30pt 的垂直空間。

相關內容