增加 scrreprt 中章節編號和章節標題之間的水平間距

增加 scrreprt 中章節編號和章節標題之間的水平間距

我想更改章節編號和章節文字之間的距離。一個糟糕的方法是更新\thechapter,但這也會影響章節標題。其他答案似乎建議.cls通過etoolbox或修改文件\renewcommand,但似乎\renewcommand\thesection...實際上更具可讀性且更易於調試。做到這一點的「自然」方法是什麼?

\documentclass{scrreprt}
\renewcommand\thechapter{\arabic{chapter}\ \ }

\begin{document}
 \chapter{Blah}
\end{document}

答案1

根據您的需求更改數值(此處為 4 公分)。

\documentclass{scrreprt}

\renewcommand*{\chapterformat}{%
  \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot
  \IfUsePrefixLine{}{\hspace{4cm}}}%
}
\begin{document}
\chapter{Canh chua}
\end{document}

這可能看起來很複雜,我們也可以讓它變得更簡單,但仍然看到完全相同的結果。

\documentclass[chapterprefix]{scrreprt}
\renewcommand*{\chapterformat}{\thechapter\hspace{4cm}}
\begin{document}
\chapter{Canh chua}
\end{document}

後來,您決定使用前綴線的 KOMA 功能,使外觀與標準類別相符並添加chapterprefix.您還決定有一個附錄,因為知道 KOMA-script 現在將在數字末尾設置點以匹配德語的定義杜登

\documentclass[chapterprefix]{scrreprt}
\renewcommand*{\chapterformat}{\thechapter\hspace{4cm}}
\begin{document}
\chapter{Canh chua}
\appendix
\chapter{Pho King Crazy}
\end{document}

我們得到的是這樣的:

瘋王

現在,所有的東西都去哪了?附錄這個詞,使用時會以 babel 語言印出。點在哪裡?
我們刪除了它。就那麼簡單。
最初的定義使用條件來處理 KOMA 提供的各種選項。如果我們想改變空間,我們就只改變空間,僅此而已。

\documentclass[chapterprefix]{scrreprt}
\renewcommand*{\chapterformat}{%
      \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot
        \IfUsePrefixLine{}{\hspace{4cm}}}%
    }
\begin{document}
\chapter{Canh chua}
\appendix
\chapter{Pho King Crazy}
\end{document}

phoKinCrazy擴展

相關內容