
フッターには次のコードがあります:
\usepackage{fancyhdr}
\lhead{}
\rhead{}
\chead{My very important and long title that is not being centered as I would like to \newline Very Myself}
\cfoot{\thepage}
\setlength{\headheight}{14pt}
しかし、中央に配置されていません。
中央に配置するにはどうしたらいいでしょうか?\documentclass[11pt,a4paper]{article}
答え1
\\
ではなく を使用してください\newline
。この動作は簡単に再現できます。
\fbox{\parbox{5cm}{\centering A centered\\ text}}
\medskip
\fbox{\parbox{5cm}{\centering A centered\newline text}}
与える
これがあなたのためのコードです
\documentclass{article}
\usepackage{geometry,fancyhdr}
\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\chead{%
My very important and long title that is not being centered as I would like to \\ Very Myself
}
\cfoot{\thepage}
\setlength{\headheight}{24pt}
\begin{document}
\section{A section}
\end{document}
コマンドは、 コンテキスト\\
では意味が変わります。 は では\centering
有効ですが\chead
、 では\newline
有効ではありません。
答え2
ヘッダー ボックス内ではtabular
改行 ( を使用) が期待どおりに機能しないため、内にヘッダーを設定します。\newline
\documentclass{article}
\usepackage{geometry,fancyhdr}
\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\chead{\begin{tabular}{c}
My very important and long title that is not being centered as I would like to \\ Very Myself
\end{tabular}}
\cfoot{\thepage}
\setlength{\headheight}{24pt}
\begin{document}
\section{A section}
\end{document}