
전제: 나는 fancyhdr을 처음 접했습니다. 나는 다음과 같은 멋진 스타일을 정의했습니다.
\lhead{}
\chead{\slshape\leftmark}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
각 장의 첫 번째 페이지를 제외한 모든 페이지에 장 번호와 이름, 윗줄, 아랫줄, 페이지 번호를 올바르게 그립니다.
그래서 저는 다음과 같은 방법으로 일반 스타일을 재정의했습니다.
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}}
각 장의 첫 번째 페이지에 위쪽 줄, 아래쪽 줄, 페이지 번호를 올바르게 그립니다. (참고: 일반 스타일에서는 멋진 스타일의 장 번호와 이름이 누락됩니다.)
이제 목차에 문제가 있습니다. 목차의 첫 번째 페이지에는 일반 스타일(장 번호와 이름 없음)이 있지만 다음 페이지에는 화려한 스타일(장 번호와 이름 포함)이 있습니다. Toc의 모든 페이지에 일반 스타일을 어떻게 적용할 수 있나요?
답변1
당신이 book
클래스를 사용하고 있기 때문에 머리말의 모든 내용은 plain
페이지 스타일 아래에 있도록 의도된 것으로 가정합니다.
\documentclass[a4paper,oneside]{book}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{lipsum} % just for the example
\pagestyle{fancy}
\fancypagestyle{main}{%
\fancyhf{}%
\fancyhead[C]{\slshape\leftmark}%
\fancyfoot[C]{\thepage}%
\renewcommand{\headrulewidth}{0.4pt}%
\renewcommand{\footrulewidth}{0.4pt}%
}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.4pt}%
}
\appto\frontmatter{\pagestyle{plain}}
\appto\mainmatter{\pagestyle{main}}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
%%% fill with some mock text
\def\testsec{\section{B}\lipsum}
\def\test{\chapter{A}
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
}
\test
\test
\test
\test
\test
\test
\test
\test
\end{document}
그러나 나는 footrule을 반대하는 것이 좋습니다.
답변2
실제 문서의 서문에서 이것을 시도해 보세요.
\usepackage{etoc}
\renewcommand{\etocaftertitlehook}{\pagestyle{plain}}
\renewcommand{\etocaftertochook}{\thispagestyle{plain}}
(편집은 위 줄에서 다음 \pagestyle
으로 대체됩니다)\thispagestyle
MWE:
\documentclass{book}
\usepackage{fancyhdr}
\lhead{}
\chead{\slshape\leftmark}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}}
\usepackage{etoc}
\renewcommand{\etocaftertitlehook}{\pagestyle{plain}}
\renewcommand{\etocaftertochook}{\thispagestyle{plain}}
\begin{document}
\tableofcontents
\chapter{ONE}
\section {A}
\chapter{TW0}
\section {B}
\newcount\cnta
\loop
\chapter{\the\cnta}
\ifnum\cnta<50
\advance\cnta 1
\repeat
\end{document}