自動章節標題和章節標題位於章節編號之前

自動章節標題和章節標題位於章節編號之前

我正在嘗試做三件事:

  1. 自動為每個部分重複一個部分標題(例如“章節”)。
  2. 將章節標題放在章節編號之前(例如,「第 1 章」而不是「1 章」)。
  3. 每個部分的編號長度為 2 位元(例如,「第 01 章」而非「第 1 章」)。

我已經能夠找到如何單獨完成這三件事,但不能全部完成。

答案1

  1. 標準bookreport文檔類\chapter預設可以滿足您的需求。

  2. 標準bookreport文檔類\chapter預設可以滿足您的需求。

  3. 您可以使用內核的\two@digits.

代碼:

\documentclass{book}

\makeatletter
\renewcommand\thechapter{\two@digits{\value{chapter}}}
\makeatother

\begin{document}

\chapter{Test chapter}

\end{document}

在此輸入影像描述

如果您想要實現的是運行標題,請使用titlesec將格式從更改displayblock

\documentclass{book}
\usepackage{titlesec}

\makeatletter
\renewcommand\thechapter{\two@digits{\value{chapter}}}
\makeatother
\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}
  {\chaptertitlename\ \thechapter}
  {1em}
  {}

\begin{document}

\chapter{Test chapter}

\end{document}

在此輸入影像描述

相關內容