带字母标签的附录

带字母标签的附录

我希望将我的附录标记为“附录 A”、“附录 B”等,如下所示。

我在用着\documentclass{book}

在此处输入图片描述

答案1

这是完成您需要做的事情的简单方法。

如果这不符合您的需求,请编辑您的问题并添加最小工作示例(MWE)

\documentclass{book}

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\centering\Huge}
{\Huge\bfseries\chaptertitlename\ \thechapter}
{20pt}
{}

\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]

\begin{document}
    \tableofcontents

    \chapter{Short chapter title}
    \section{Section title}
    \begin{theorem}
        \LaTeX\ is fun!
    \end{theorem}
    \begin{theorem}
        Ducks are fun!
    \end{theorem}

    \section{Section title}
    \begin{theorem}
        \LaTeX\ is fun!
    \end{theorem}
    \begin{theorem}
        Ducks are fun!
    \end{theorem}

    \chapter[Long chapter title]{Long long long long long long chapter title}
    \section{Section title}
    \begin{theorem}
        \LaTeX\ is fun!
    \end{theorem}
    \begin{theorem}
        Ducks are fun!
    \end{theorem}
    \section{Section title}
    \begin{theorem}
        \LaTeX\ is fun!
    \end{theorem}
    \begin{theorem}
        Ducks are fun!
    \end{theorem} 

    \appendix

    \chapter{Short appendix title}
    \section{Section title}
    \begin{theorem}
        This is a simple way to do what you need.
    \end{theorem}
    \begin{theorem}
        Since you didn't provide a MWE, I cannot know if this is actually what you need!
    \end{theorem}
    \section{Section title}
    \begin{theorem}
        Why don't people provide a MWE?
    \end{theorem}
    \begin{theorem}
        A MWE is always needed!
    \end{theorem}

    \chapter[Long appendix title]{Long long long long long long appendix title}
    \section{Section title}
    \begin{theorem}
        \LaTeX\ is fun!
    \end{theorem}
    \begin{theorem}
        Ducks are fun!
    \end{theorem}
    \section{Section title}
    \begin{theorem}
        \LaTeX\ is fun!
    \end{theorem}
    \begin{theorem}
        Ducks are fun!
    \end{theorem}
\end{document}

在此处输入图片描述

在此处输入图片描述

答案2

appendix这是除了通过“稍微”(咳嗽!;-))修改命令的包之外没有任何其他包的版本\@makechapterhead

\documentclass{book}

\usepackage[title]{appendix}


\newlength{\appendixafterchapheadskip}
\newlength{\appendixbeforechapheadskip}
\newlength{\appendixafterchaptitleskip}
\setlength{\appendixafterchapheadskip}{10pt}
\setlength{\appendixbeforechapheadskip}{30pt}
\setlength{\appendixafterchaptitleskip}{30pt}


\makeatletter
\g@addto@macro\appendices{%
  \def\@makechapterhead#1{%
    \vspace*{\appendixbeforechapheadskip}%
    { \parindent \z@ \raggedright \normalfont
      \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
      \huge\bfseries\centering \@chapapp\space \thechapter
      \par\nobreak
      \vskip \appendixafterchapheadskip
      \fi
      \fi
      \interlinepenalty\@M
      \Huge \bfseries #1\par\nobreak
      \vskip \appendixafterchaptitleskip%
    }%
  }
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Regular chapter}


\begin{appendices}

\chapter{Foo appendix}
\section{Some foo appendix section}
\end{appendices}


\end{document}

在此处输入图片描述

相关内容