将章节编号为 01、02、...、10、11、... 附录 A、B

将章节编号为 01、02、...、10、11、... 附录 A、B

最小示例(问题很明显):

\documentclass[]{report}

\makeatletter
\def\@makechapterhead#1{
    \vspace*{-5.0em}
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE{0\thechapter}
    \par\vspace{0.25cm}
    \flushleft\MakeUppercase{#1}}
    \par\vspace{3.5em}
}
\makeatother

\begin{document}

\chapter{First Chapter}
\setcounter{chapter}{9}
\chapter{Tenth Chapter}

\appendix
\chapter{Appendix A}

\end{document}

编辑:我忘了说一件重要的事情。只有显示的章节号前面应该有 0,而不是定义、定理等。即:第 01 章、定义 1.1. 等。

答案1

\thechapter您可以调整within的打印以仅当计数器的值小于 10 时\@makechapterhead插入:0chapter

enter image description here

\documentclass{report}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
  {\thechapter}% <search>
  {\expandafter\ifx\@chapapp\appendixname\else\ifnum\value{chapter}<10 0\fi\fi\thechapter}% <replace>
  {}{}% <success><failure>
\makeatother

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]

\begin{document}

\chapter{First Chapter}

\begin{thm}
  A first theorem
\end{thm}
\setcounter{chapter}{9}
\chapter{Tenth Chapter}

\appendix
\chapter{Appendix A}
\begin{thm}
  Another theorem
\end{thm}

\end{document}

首先,在“替换子句”中嵌套的条件\patchcmd会检查您是否在附录中。如果不在,则会在计数器前面加上\thechapter0,类似于内核\two@digits宏。

答案2

易于使用\numprint及其\nplpadding命令:

\documentclass[]{report}

\usepackage{numprint, apptools}

\makeatletter
\def\@makechapterhead#1{
    \vspace*{-5.0em}
    {\parindent \z@ \normalfont
    \interlinepenalty\@M
    \LARGE{\ifappendix\Alph{chapter}\else\nplpadding{2}\numprint{\arabic{chapter}}\fi}%
    \par\vspace{0.25cm}
    \flushleft\MakeUppercase{#1}}
    \par\vspace{3.5em}
    \renewcommand\thechapter{\ifappendix\Alph{chapter}\else\npnolpadding\arabic{chapter}\fi}}
\makeatother

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]

\begin{document}

\chapter{First Chapter}

\begin{thm}
  A first theorem
\end{thm}
\setcounter{chapter}{9}
\chapter{Tenth Chapter}

\appendix
\chapter{Appendix A}
\begin{thm}
  Another theorem
\end{thm}

\end{document} 

enter image description here

enter image description here

答案3

这是 ConTeXt 用户强制章节使用两位数的解决方案。使用该\startsectionblockenvironment命令可以提供仅适用于特定sectionblock环境的设置。

\startsectionblockenvironment[bodypart]
    \setuphead[chapter][deepnumbercommand=\twodigits]
\stopsectionblockenvironment

\starttext

\startsectionblock[bodypart]

\chapter{First chapter}

\stopsectionblock

\startsectionblock[appendix]

\chapter{Appendix A}

\stopsectionblock

\stoptext

要使标题与数字在单独的行上具有相同的布局,必须为其编写自己的渲染替代方案。

\defineheadalternative
  [stacked]
  [alternative=vertical,
   renderingsetup=headalternative:stacked]

\startsetups[headalternative:stacked]
    \vbox {
        \headsetupspacing
        \begstrut
        \ifconditional\headshownumber
            \headnumbercontent
            \par
        \fi
        \headtextcontent
    }
\stopsetups

完成后,可以使用alternative中的密钥加载这个新的渲染\setuphead

\setuphead
  [chapter]
  [alternative=stacked,
   textstyle=WORD]

相关内容