![Fancyhdr 왼쪽 표시 및 오른쪽 표시 센터링](https://rvso.com/image/392324/Fancyhdr%20%EC%99%BC%EC%AA%BD%20%ED%91%9C%EC%8B%9C%20%EB%B0%8F%20%EC%98%A4%EB%A5%B8%EC%AA%BD%20%ED%91%9C%EC%8B%9C%20%EC%84%BC%ED%84%B0%EB%A7%81.png)
어떻게 가능했는지 알고 싶습니다.센터이 (MWE) 코드를 사용하여 장과 섹션 표시(그들이 그렇게 부르는지 모르겠습니다)
\documentclass[10pt,twoside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\fancyhead[LE,RO]{\thepage}
\renewcommand\headrulewidth{0pt}
\renewcommand\chaptermark[1]{\markboth{\scshape#1}{}}
\renewcommand\sectionmark[1]{\markright{\scshape #1}}
\begin{document}
\chapter{chapter} % Even page header
\lipsum[1]
\section{section} % odd page header
\lipsum[1-5]
\end{document}
답변1
여기에 코드가 있습니다. 페이지 스타일을 'fancy'로 선언하는 것을 잊었습니다.
\documentclass[10pt,twoside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[CE]{\leftmark}
\fancyhead[CO]{\rightmark}
\fancyhead[LE,RO]{\thepage}
\renewcommand\headrulewidth{0pt}
\renewcommand\chaptermark[1]{\markboth{\scshape#1}{}}
\renewcommand\sectionmark[1]{\markright{\scshape #1}}
\pagestyle{fancy}
\begin{document}
\chapter{A First Chapter} % Even page header
\lipsum
\section{A section} % odd page header
\lipsum[1-10]
\end{document}
편집하다: 헤더에 제목만 포함하려면 다음을 사용하는 것이 더 쉽습니다 titleps
.
\documentclass[10pt,twoside]{book}
\usepackage{lipsum}
\usepackage{titleps}
\newpagestyle{mine}[\scshape]{%
\sethead[\thepage][\chaptertitle][]{}{\sectiontitle}{\thepage}
}
\pagestyle{mine}
\begin{document}
\chapter{A First Chapter} % Even page header
\lipsum
\section{A section} % odd page header
\lipsum[1-10]
\end{document}