章节开始后的 pagestyle{plain} 显示为 pagestyle{fancy}

章节开始后的 pagestyle{plain} 显示为 pagestyle{fancy}

paracol我正在使用和编写双语版fancyhdr。我希望每章的第 1 页在 中\pagestyle{empty},第 2-3 页在 中\pagestyle{plain},第 4-5 页在 中\pagestyle{fancy}

据我所知,这个 MWE 应该完全实现这一点,除了第 3 页在\pagestyle{fancy}而不是 之外,它实现了上述功能\pagestyle{plain}。我遗漏了什么?

\documentclass[]{book}

\usepackage[utf8x]{inputenc}
\usepackage{paracol}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{afterpage}

\pagestyle{fancy}
\fancyhf{}
\fancyhf[CFE,CFO]{\thepage}
\fancyhead[CE]{\itshape\ Heading Left }
\fancyhead[CO]{\itshape\ Heading Right}

\begin{document}

\chapter{}
\thispagestyle{empty}\afterpage{\thispagestyle{plain}\afterpage{\thispagestyle{plain}}}
\newenvironment{blahparacol}[2]
{\begin{paracol}[1]*{2} 
#1\switchcolumn#2
}{\end{paracol}}
~ \clearpage % clearing the page so the first column starts on verso

\begin{blahparacol}
\switchcolumn[0]*
\vspace{1in}
                    \begin{center}
                        \huge\ Left Chapter Title \par
                    \end{center}
\vspace{.5in}
\switchcolumn
\vspace{1in}
                    \begin{center}
                        \huge\ Right Chapter Title \par
                    \end{center}
\vspace{.5in}
\switchcolumn*
\lipsum
\switchcolumn
\lipsum
\end{blahparacol}
\end{document}

答案1

此解决方案使用 everypage。afterpage 在页面格式化之前运行,而 everypage 在页面格式化之后运行,这意味着它\thispagestyle适用于下一页。

\documentclass[]{book}

\usepackage[utf8x]{inputenc}
\usepackage{paracol}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{everypage}

\newcounter{twopage}
\globalcounter{twopage}
\AddEverypageHook{\ifcase\value{twopage}% zero
  \or\thispagestyle{plain}\addtocounter{twopage}{-1}% one
  \or\thispagestyle{plain}\addtocounter{twopage}{-1}% two
  \else\addtocounter{twopage}{-1}% should not happen
  \fi}

\pagestyle{fancy}
\fancyhf{}
\fancyhf[CFE,CFO]{\thepage}
\fancyhead[CE]{\itshape\ Heading Left }
\fancyhead[CO]{\itshape\ Heading Right}

\begin{document}

\chapter{}
\thispagestyle{empty}\setcounter{twopage}{2}%
\newenvironment{blahparacol}[2]
{\begin{paracol}[1]*{2} 
#1\switchcolumn#2
}{\end{paracol}}
~ \clearpage % clearing the page so the first column starts on verso

\begin{blahparacol}
\switchcolumn[0]*
\vspace{1in}
                    \begin{center}
                        \huge\ Left Chapter Title \par
                    \end{center}
\vspace{.5in}
\switchcolumn
\vspace{1in}
                    \begin{center}
                        \huge\ Right Chapter Title \par
                    \end{center}
\vspace{.5in}
\switchcolumn*
\lipsum
\switchcolumn
\lipsum
\end{blahparacol}
\end{document}

相关内容