我如何将@makeschapterhead 改为使章节标题居中?

我如何将@makeschapterhead 改为使章节标题居中?

我重新定义了\@makechapterhead缩短章节标题前后的空间,但我不知道如何将其居中...有什么帮助吗?

\makeatletter
\def\@makechapterhead#1{%
  %%%%\vspace*{50\p@}% %%% removed!
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \normalsize\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \normalsize \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\def\@makeschapterhead#1{%
  %%%%%\vspace*{50\p@}% %%% removed!
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \normalsize \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother

答案1

要使整个章节标题结构居中,只需将\raggedright(标题的当前/典型对齐样式)替换为\centering

在此处输入图片描述

\documentclass{report}

\usepackage{lipsum}% Just for this example

\makeatletter
\def\@makechapterhead#1{%
  %%%%\vspace*{50\p@}% %%% removed!
  {\parindent \z@ \centering \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \normalsize\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \normalsize \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\def\@makeschapterhead#1{%
  %%%%%\vspace*{50\p@}% %%% removed!
  {\parindent \z@ \centering
    \normalfont
    \interlinepenalty\@M
    \normalsize \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother

\begin{document}

\chapter{A chapter}

\lipsum[1]

\end{document}

相关内容