
바닥글에 다음 코드가 있습니다.
\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
)이 예상대로 작동하지 않으므로 a 내부에 헤더를 설정합니다 .
\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}