3

Consider the following code:

% Configuration
\documentclass[twoside, 10pt]{book}
\usepackage[paperwidth = 6in, paperheight = 9in]{geometry}
\usepackage{xpatch, xifthen, lmodern, fancyhdr, etoolbox, epigraph, lipsum}
\usepackage[explicit]{titlesec}
\usepackage[sf=false]{libertine}

% Title format
\titleformat{\part}[display]{\filcenter}{}{10em}{#1}[\thispagestyle{epigraph}]
\makeatletter
\xpatchcmd\epigraphhead
 {\let\@evenfoot}
 {\let\@oddfoot\@empty\let\@evenfoot}
 {}{}
\makeatother
\newcommand{\custompart}[5]{
\ifthenelse{\equal{#2}{}}{
    \setlength{\epigraphwidth}{2.5in}
}{
    \setlength{\epigraphwidth}{#2}
}
\epigraphhead[450]{%
    \ifthenelse{\equal{#3}{}}{}{#3}%
    \ifthenelse{\equal{#4}{}}{}{\par\hspace*{\fill}\textit{#4}}%
    \ifthenelse{\equal{#5}{}}{}{\par\hspace*{\fill}\textsc{#5}}%
}
\part{#1}
}

% Document
\begin{document}
\mainmatter
\lipsum
\custompart{First part}{}{This is an epigraph 1}{The source 1}{The author 1}
\lipsum
\custompart{Second part}{}{This is an epigraph 2}{The source 2}{The author 2}
\lipsum\lipsum
\custompart{Third part}{}{This is an epigraph 3}{The source 3}{The author 3}
\end{document}

I would like to print epigraphs on part pages. The problem is that this current version print epigraphs on both the part page, and the page before as illustrated below: epigraph problem

How to solve this problem?

4
+50

You have to issue \cleardoublepage before doing strange things with headers and footers.

\documentclass[twoside, 10pt]{book}
\usepackage[paperwidth = 6in, paperheight = 9in]{geometry}
\usepackage{xpatch, xifthen, lmodern, fancyhdr, etoolbox, epigraph, lipsum}
\usepackage{titlesec}
\usepackage[sf=false]{libertine}

% Title format
\titleformat{\part}[display]{\filcenter}{}{10em}{}[\thispagestyle{epigraph}]
\makeatletter
\xpatchcmd\epigraphhead
  {\let\@evenfoot}
  {\let\@oddfoot\@empty\let\@evenfoot}
  {}{}
\makeatother
\newcommand{\custompart}[5]{%
  \cleardoublepage % <----------------- HERE!
  \ifthenelse{\equal{#2}{}}{%
    \setlength{\epigraphwidth}{2.5in}%
  }{%
    \setlength{\epigraphwidth}{#2}%
  }%
  \epigraphhead[450]{%
    \ifthenelse{\equal{#3}{}}{}{#3}%
    \ifthenelse{\equal{#4}{}}{}{\par\hspace*{\fill}\textit{#4}}%
    \ifthenelse{\equal{#5}{}}{}{\par\hspace*{\fill}\textsc{#5}}%
  }%
  \part{#1}%
}

% Document
\begin{document}
\mainmatter
\lipsum
\custompart{First part}{}{This is an epigraph 1}{The source 1}{The author 1}
\lipsum
\custompart{Second part}{}{This is an epigraph 2}{The source 2}{The author 2}
\lipsum\lipsum
\custompart{Third part}{}{This is an epigraph 3}{The source 3}{The author 3}
\end{document}
  • Can you elaborate on why? – Jesse Knight Oct 28 '17 at 16:04
  • @JesseKnight Without the initial \cleardoublepage, the page style change happens before the last page is ejected. – egreg Oct 28 '17 at 18:10

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.