2

I've found numerous posts about removing the header/footer on the blank pages between chapters, and they work fine with one big exception... I need a \pagestyle{plain} (i.e. single centered pg#) at all blank pages before chapter starts in the document except I need a \pagestyle{empty} for the page right after the \titlepage. All the methods I've seen and tried either leave me with completely empty pages for the whole document or \pagestyle{plain} for all of them.

I'm using book document class [twosided,openright], fancyhdr, and have included the code to redefine \cleardoublepage as follows:

\makeatletter
\def
\cleardoublepage{%
\clearpage
  \ifodd\c@page
  \else
    \hbox{}
    \thispagestyle{plain}
    \newpage      
  \fi
  }%
\makeatother

...as recommended in various posts. Unfortunately, that leaves me with the blank page after the titlepage with a page number (which is driving the client nuts). The code seems to override any inline attempts to get that page to {empty}.

Is there some form of \if@titlepage conditional that parallels \if@mainmatter I could use to clear just that section and leave the rest (\frontmatter, \mainmatter, \appendix, \backmatter) as \pagestyle{plain} for those in-between blank pages? Is there some way to capture that as a conditional?

A (very) rough approximation MWE:

\documentclass[12pt,letterpaper,final,openright]{book}

\usepackage{fancyhdr}
\usepackage{natbib}

\pagestyle{fancy}
  \setlength{\headheight}{15.2pt}
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0.2pt}

  \makeatletter
    \renewcommand{\chaptermark}[1]{%
      \if@mainmatter
        \markboth{\MakeUppercase{\chaptername\ \thechapter.\ #1}}{}
      \else
        \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}
      \fi
      }%
  \makeatother  

  \fancyhf{} 
  \fancyhead[LE,RO]{\small \thepage}
  \fancyhead[LO]{\small \leftmark}
  \fancyhead[RE]{\small \rightmark}

% Redefine \pagestyle{plain}
\fancypagestyle{plain}{%
  \fancyhf{} % clear all header and footer fields
  \fancyfoot[C]{\small \thepage} % except the center
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  }%

% Code for creating plain on empty pages before new chapter
\makeatletter
\def
  \cleardoublepage{%
    \clearpage
      \ifodd\c@page
      \else
        \hbox{}
        \thispagestyle{plain}
        \newpage      
      \fi
    }%
\makeatother

\begin{document}
% TITLE PAGE
\pagestyle{empty}  %Clear hdr/ftr 
\titlepage
  \input{./Chapter_txt/titlepageV1} %Custom title page text/layout

\frontmatter
\pagestyle{fancy} % Resume hdr/ftr
%MANAGEMENT SUMMARY 
\include{Preface} %Intro/Preface chapter

%ToC and Lists  
\tableofcontents
\listoftables   
\listoffigures

\mainmatter
\part{PartI}
  \include{Chapter1}
  \include{Chapter2}
\part{PartII}
  \include{Chapter3}
  \include{Chapter4}

\appendix
  \include{app}

\backmatter  
    \bibliographystyle{humannat}
    \bibliography{mybib}\footnotesize
    \addcontentsline{toc}{chapter}{Bibliography}

\end{document}

The whole thing is a multi-volume work, with each section drawn in by \include{file}... not a good way to do much of an MWE (don't know how to do one that has \input or \include).

4
  • you need : 1) titlepage -->2) empty--> 3 + plain like this? – touhami Apr 23 '15 at 18:57
  • @touhami, almost... for "3+" I need fancy for the main body and plain for those situations where there's a blank even-page after parts/chapters. – Scard Apr 23 '15 at 19:02
  • There is a difference between \thispagestyle and \pagestyle commands. The former defines the page style for the current page only, while the latter defines for the entire document. However, there is not much we can do to help you without a MWE example. Can you provide one? MWE: meta.tex.stackexchange.com/questions/228/… – Carlos Viegas Apr 23 '15 at 19:03
  • @CarlosViegas, I'll try and put up an MWE soon. I do understand the difference between \thispagestyle and \pagestyle, but according to the examples I've found \thispagestyle is appropriate in this case since it's just redefining the even-page instance of a \cleardoublepage condition. – Scard Apr 23 '15 at 19:05
1

Here is a solution Edit: more explanation

pagestyle is fancy, pages between chapters are set to plain by redefining \cleardoublepage (this last command is used by \part and \chapter)

the page after part page is set to plain by redefining \@endpart

the page after title page is set to empty by this pagestyle{empty} just after titlepage environment

\documentclass{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\fancyhf{}  
\fancyhead[R]{\leftmark} 
\fancyfoot[R]{test} 
\fancyfoot[C]{\thepage}
\pagestyle{fancy}
\let\mtcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\clearpage{\pagestyle{plain}\mtcleardoublepage}}
\makeatletter
\def\@endpart{\vfil\newpage
              \if@twoside
               \if@openright
                \null
                \thispagestyle{plain}%
                \newpage
               \fi
              \fi
              \if@tempswa
                \twocolumn
              \fi}
\makeatother
\title{Test}
\author{Me}
\begin{document}
\begin{titlepage}
\maketitle
\end{titlepage}
\thispagestyle{empty}
\lipsum[1-20]
\part{Deux}
\chapter{trois}
\lipsum[1-50]
\end{document}

Edit: code for this particular

\documentclass[12pt]{book}

\usepackage{fancyhdr}
\usepackage{natbib}

\pagestyle{fancy}
  \setlength{\headheight}{15.2pt}
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0.2pt}

  \makeatletter
    \renewcommand{\chaptermark}[1]{%
      \if@mainmatter
        \markboth{\MakeUppercase{\chaptername\ \thechapter.\ #1}}{}
      \else
        \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}
      \fi
      }%
  \makeatother  

  \fancyhf{} 
  \fancyhead[LE,RO]{\small \thepage}
  \fancyhead[LO]{\small \leftmark}
  \fancyhead[RE]{\small \rightmark}

% Redefine \pagestyle{plain}
\fancypagestyle{plain}{%
  \fancyhf{} % clear all header and footer fields
  \fancyfoot[C]{\small \thepage} % except the center
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  }%

\let\mtcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\clearpage{\pagestyle{plain}\mtcleardoublepage}}
\makeatletter
\def\@endpart{\vfil\newpage
              \if@twoside
               \if@openright
                \null
                \thispagestyle{plain}%
                \newpage
               \fi
              \fi
              \if@tempswa
                \twocolumn
              \fi}
\makeatother

\begin{document}

\begin{titlepage}
test
\end{titlepage}
\thispagestyle{empty}
\frontmatter

\include{Preface} %Intro/Preface chapter

%ToC and Lists  
\tableofcontents
\listoftables   
\listoffigures

\mainmatter
\part{PartI}
  \include{Chapter1}
  \include{Chapter2}
\part{PartII}
  \include{Chapter3}
  \include{Chapter4}

\appendix
  \include{app}

\backmatter 
\footnotesize 
    \bibliographystyle{humannat}
    \bibliography{mybib}
    \addcontentsline{toc}{chapter}{Bibliography}

\end{document}
8
  • Is there a place I can find a list of those conditionals (@endpart, @tempswa, etc), or a way to know which environments have some such macro? – Scard Apr 23 '15 at 19:32
  • here for example ctan.org/tex-archive/macros/latex/base file: classes.pdf – touhami Apr 23 '15 at 19:52
  • Tried it... I still end up with the plain style page for the blank page after the titlepage... – Scard Apr 23 '15 at 19:52
  • in this example there is no blank page after title page – touhami Apr 23 '15 at 19:53
  • if i understand may be you shoud use \thispagestyle{empty}\frontmatter – touhami Apr 23 '15 at 19:57
2

You probably need to redefine your titlepage environment. Mine is like this, and the first page after titlepage is empty and the following are numbered correctly.

\newenvironment{titlepage}
{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi%
  \newpage
  \thispagestyle{empty}%
  \setcounter{page}\@ne
}%
{\newpage
  \thispagestyle{empty}
}%%

Moreover, if you use \maketitle command, you should add a \clearpage at the end of the command definition:

\if@titlepage
\newcommand\maketitle{%
  \begin{titlepage}
...
  \end{titlepage}%
  \clearpage%
  \setcounter{footnote}{0}%
...
}%
\fi

I hope it helps.

6
  • \newenvironment over-writes the existing titlepage definition for the book class? Definitely worth a try. The project is actually in 4 separate .tex main documents sharing a custom .sty... that would simplify if I can drop it in there. – Scard Apr 23 '15 at 19:28
  • You can redefine the book class directly (the sty file) or create a new environment at your .tex and overwriting the default one. – Carlos Viegas Apr 23 '15 at 19:33
  • Get the error: ! LaTeX Error: Command \titlepage already defined.Or name \end... illegal, see p.192 of the manual.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... }... – Scard Apr 23 '15 at 19:47
  • 1
    @Scard -- you probably want \renewcommand{\titlepage}{...}. – barbara beeton Apr 23 '15 at 20:01
  • @Scard my code is to replace the corresponding code in the sty. Otherwise you need to redefine it. – Carlos Viegas Apr 23 '15 at 20:21
0

You can load the package scrextend with the option cleardoublepage=plain. To get an empty page right after the titlepage use \cleardoubleoddemptypage after the titlepage environment or as last command inside this environment.

\documentclass{book}
\usepackage[cleardoublepage=plain]{scrextend}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{blindtext}% dummy text
\begin{document}
\begin{titlepage}
\Huge My Titlepage
\end{titlepage}
\cleardoubleoddemptypage
\frontmatter
\tableofcontents
\mainmatter
\blinddocument
\Blindtext
\blinddocument
\end{document}

Another possibility is the additional use of etoolbox:

\documentclass{book}
%
\usepackage[cleardoublepage=plain]{scrextend}
\usepackage{etoolbox}
\AfterEndEnvironment{titlepage}{\cleardoubleoddemptypage}
%
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{blindtext}% dummy text
\begin{document}
\begin{titlepage}
\Huge My Titlepage
\end{titlepage}
\frontmatter
\tableofcontents
\mainmatter
\blinddocument
\Blindtext
\blinddocument
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.