# Parallel environment breaks fancyhdr

I have a chapter fully enclosed in the parallel environment. Placing the section title outside of the environment caused the creation of an empty page (with the section title only) and the translation starting from the next page. Placing the title inside the environment solved this issue:

...

\begin{Parallel}[p]{\textwidth}{\textwidth}
\ParallelLText{\section{Translation} In the preceding chapter...


However this caused another problem: I'm using fancyhdr to place the title of the current (sub)section at the top of the page, but this particular section becomes invisible and is totally ignored, so regardless of the fact that my last section has begun, the last section title persists in the header.

I'm not sure if this is due to the fact that I'm misusing the parallel environment, but I'd like to know if there is a simple workaround.

Here is my MWE. Note that parallel is creating extra pages before it appears, but my issue with the header is still there.

\documentclass[12pt, twoside]{article}
\usepackage[a4paper, margin=2.5cm, asymmetric,bindingoffset=1cm]{geometry}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{parallel}
\usepackage{lipsum}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyhf{}

\raggedbottom
\begin{document}

\section{First title}
\lipsum[1]

\pagebreak
\section{Second title}
\lipsum[2]

\pagebreak%
\begin{Parallel}[p]{\textwidth}{\textwidth}
\ParallelLText{\section{Translation} \lipsum[3-7]}
\ParallelRText{\lipsum[3-7]}
\end{Parallel}
\end{document}

• I assume this is a \global problem -- something which is redefined by fancyhdr is stuck inside of the Parallel environment group. – user31729 Dec 23 '15 at 21:19
• @ChristianHupfer What is \global? – Alenanno Dec 23 '15 at 21:22
• @Alenanno: I meant something like \gdef actually. – user31729 Dec 23 '15 at 21:23
• If you place \sectionmark{Translation} explicitly into the last Parallel environment, it will appear (just for testing purposes) – user31729 Dec 23 '15 at 21:29
• The marks in a parallel environment are stored in \splitfirstmark, and \splitbotmark, rather than in \firstmark and \botmark. – egreg Dec 23 '15 at 21:32

The package parallel uses \vsplit for its working; the \mark commands issued by \markright (and \markboth) are then stored in \splitfirstmark and \splitbotmark rather than in \firstmark and friends.

If you just use \rightmark the following workaround seems to work, but it should be tested with a bigger document. I assume the section titles are in the left pages.

The idea is that, if a mark appears it will be stored in \splitfirstmark, so I test whether it's empty; if not, I issue an appropriate \markright command.

\documentclass[12pt, twoside]{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{parallel}
\usepackage{etoolbox}

\patchcmd{\ParallelParTwoPages}
{\else\ifodd}
{\extractfirstmark\else\ifodd}
{}{}

\makeatletter
\newcommand{\extractfirstmark}{%
\if\relax\detokenize\expandafter{\splitfirstmark}\relax
\else
\expandafter\expandafter\expandafter\markright
\expandafter\expandafter\expandafter{\expandafter\@secondoftwo\splitfirstmark}%
\fi
}
\makeatother

\usepackage{lipsum}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyhf{}

\raggedbottom
\begin{document}

\section{First title}
\lipsum[1]

\pagebreak
\section{Second title}
\lipsum[2]

\clearpage

\begin{Parallel}[p]{\textwidth}{\textwidth}
\ParallelLText{\section{Translation} \lipsum[3-12]}
\ParallelRText{\lipsum[3-12]}
\end{Parallel}
\end{document}


• Thanks! It seems to be working for the full document as well. I'll let you know in case I run into other issues that I cannot see now, but there doesn't seem to be any. – Alenanno Dec 23 '15 at 22:12