使用 titlesec 在错误的页面上打印题词

使用 titlesec 在错误的页面上打印题词

考虑以下代码:

% 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}

我想在部分页面上打印题词。问题是,当前版本在部分页面和之前的页面上都打印题词,如下图所示: 题词问题

如何解决这个问题呢?

答案1

\cleardoublepage在对页眉和页脚进行奇怪的操作之前,您必须先发出问题。

\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}

相关内容