[Tex/LaTex] How to let all the pagestyle of pages from \frontmatter to \mainmatter empty

front-matterheader-footertable of contents

\frontmatter may include

  • Table of Contents
  • List of Figures
  • List of Tables
  • Preference
  • and other parts

Now, I want to set up the pagestyle of pages range from the tag \frontmatter to the tag \mainmatter be plain. that is said all of \tableofcontents,\listoffigures,\listoftables,preference parts should not contain page number, page head, page foot. I dont want to set them one by one with \thispagestyle.
the \pagestyle of all pages in \mainmatterpart should be fancy.

I think if I can deal with \frontmatter, I also can apply the method to \mainmatter to \backmatter.

Am I right?

Best Answer

According to the revised version of the question, you (may) want:

\documentclass{book}                                                        
\usepackage{lipsum, fancyhdr}                                               

\begin{document}                                                            

\pagestyle{empty}                                                           
% pagestyle{plain}                                                          
\frontmatter                                                                

\lipsum[1]                                                                  

\mainmatter                                                                 
\pagestyle{fancy}                                                           

\chapter{1}                                                                 
\section{1}                                                                 
\lipsum                                                                     


\backmatter                                                                 
\pagestyle{empty}                                                           
%\pagestyle{plain}                                                          

\lipsum[1]                                                                  

\end{document} 

Edit: If you want to wrap these changes into a .sty file, you could do this:

\NeedsTeXFormat{LaTeX2e}[1994/06/01]                                        
\ProvidesPackage{myfile}                                                    
  [2012/05/02 v0.01 modifications to the *matter commands]                  


\RequirePackage{etoolbox}                                                   
\appto\frontmatter{\pagestyle{empty}}                                       
\appto\mainmatter{\pagestyle{fancy}}                                        
\appto\backmatter{\pagestyle{empty}}                                        


\endinput

Name this file myfile.sty and load it in the preamble of your document with the usual \usepackage{myfile}. Note that the name of this file is arbitrary, and the first three lines as well as the last line are not strictly needed.

However, I do not really see the advantage of hard-wiring such changes into the \*matter commands, even if I agree with the idea that generic formatting changes are often better put into a .sty file for complex documents.

Related Question