
Eu tenho um cabeçalho criado com fancyhdr
. Ele se repete em todas as páginas, incluindo as seções Índice e Prefácio. Tentei usar \thispagestyle{empty}
mas só funciona na primeira página enquanto preciso limpar nafrontmatter
\documentclass[11pt]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
\renewcommand\headrulewidth{1.5pt}
\makeatletter
\def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
\hrule\@height\headrulewidth\@width\headwidth
\vskip 2pt% 2pt between lines
\hrule\@height.5pt\@width\headwidth% lower line with .5pt line width
\vskip-\headrulewidth
\vskip-1.5pt}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\thispagestyle{empty}
\frontmatter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table of contents
\tableofcontents
\chapter{Preface}
\lipsum
\lipsum
\mainmatter
\chapter{Ch1}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\lipsum
\section{test}
\chapter{ch2}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\end {document}
Responder1
mude este
\thispagestyle{empty}
para
\pagestyle{empty}
e insira \pagestyle{fancy} aqui
\mainmatter
\chapter{Ch1}
Será parecido agora
\mainmatter
\pagestyle{fancy}
\chapter{Ch1}
Responder2
É isso que voce quer? No início, há apenas o título do capítulo (Conteúdo/Prefácio), as primeiras páginas do capítulo e as páginas em branco possuem estilo vazio (para todo o documento). Eu adicionei a twoside
opção e usei os pacotes emptypage
e xpatche
para conseguir isso.
\documentclass[11pt, twoside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{xpatch, emptypage}%
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
\renewcommand\headrulewidth{1.5pt}
\makeatletter
\def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
\hrule\@height\headrulewidth\@width\headwidth
\vskip 2pt% 2pt between lines
\hrule\@height.5pt\@width\headwidth% lower line with .5pt line width
\vskip-\headrulewidth
\vskip-1.5pt}}
\makeatother
%%
\xpatchcmd{\chapter}{%
\thispagestyle{plain}}{%
\thispagestyle{empty}}{}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\frontmatter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table of contents
\tableofcontents
\chapter*{Preface}
\markboth{Preface}{Preface}
\addcontentsline{toc}{chapter}{Preface}
\lipsum
\lipsum[1-4]
\mainmatter
\pagestyle{fancy}
\chapter{Ch1}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\lipsum
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\chapter{ch2}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\lipsum
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\end {document}