X のリストを中央揃えにして、テキストを追記する

X のリストを中央揃えにして、テキストを追記する

tocloft パッケージを使用すると、LaTeX ドキュメントの先頭の「List of Z」というタイトルの下にテキストを追加できます。

\renewcommand{\cftafterZtitle}{\par\noindent \textnormal{Z} \hfill \textnormal{PAGE}}

次のようにすると、タイトル「List of Z」を中央に配置できます。

\renewcommand{\cftZtitlefont}{\hfill\bfseries}
\renewcommand{\cftafterZtitle}{\hfill}

しかし、2 つのコマンドを組み合わせようとすると、テキストが中央ではなく右余白に移動します。

\renewcommand{\cftloftitlefont}{\hfill\bfseries}
\renewcommand{\cftafterloftitle}{\hfill\par\noindent \textnormal{Z} \hfill \textnormal{PAGE}}

タイトル「Z のリスト」を中央に配置し、タイトルの下にテキストを配置する方法を知っている人はいますか?

答え1

\hbox2番目の後に空文字を追加することができます\hfillエグレの答え\null とは何ですか? いつ使用する必要がありますか?):

\documentclass{article}
\usepackage{tocloft}

\renewcommand{\cftloftitlefont}{\hfill\bfseries}
\renewcommand{\cftafterloftitle}{\hfill\null\par\noindent\textnormal{Z}\hfill \textnormal{PAGE}}

\begin{document}

\listoffigures

\noindent X\hrulefill Y% for coparison only

\end{document}

ここに画像の説明を入力してください

代わりに次のオプションを使用することもできます\hfil

\renewcommand{\cftloftitlefont}{\hfil\bfseries}
\renewcommand{\cftafterloftitle}{\hfil\par\textnormal{Z}\hfill \textnormal{PAGE}}

関連情報