
Premissa: sou novo no fantasiahdr. Eu defini o seguinte estilo sofisticado:
\lhead{}
\chead{\slshape\leftmark}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
que desenhe corretamente o número e o nome do capítulo, a linha superior, a linha inferior e o número da página, em todas as páginas, exceto na primeira de cada capítulo.
Então, redefini o estilo simples da seguinte maneira:
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}}
que desenham corretamente a linha superior, a linha inferior e o número da página na primeira página de cada capítulo (nota: o estilo simples perde o número do capítulo e o nome do estilo sofisticado)
Agora, tenho um problema com o índice. A primeira página do toc tem o estilo simples (sem número e nome do capítulo), mas as páginas seguintes têm o estilo sofisticado (com número e nome do capítulo). Como posso aplicar o estilo simples a TODAS as páginas do toc?
Responder1
Como você está usando a book
classe, presumo que tudo no assunto inicial deve estar sob o plain
estilo de página:
\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}
No entanto, eu recomendaria contra a regra.
Responder2
Tente isso no preâmbulo do seu documento real
\usepackage{etoc}
\renewcommand{\etocaftertitlehook}{\pagestyle{plain}}
\renewcommand{\etocaftertochook}{\thispagestyle{plain}}
(editar substitui \pagestyle
por \thispagestyle
na linha acima)
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}