@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}

関連情報