1

When I change the behavior of \leftmark in the Reference section, it only changes on the second odd page of that section (by default, both \leftmark and \rightmark is set as \bibname). Compile the MWE below with

pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %.tex|bibtex bu1.aux|bibtex bu2.aux|pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %.tex|pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %.tex

What is the reason for this?

\documentclass[b5paper, twoside, 11pt]{book}

\usepackage{fancyhdr}           % needed for fancy headers
\setlength{\headheight}{13.6pt}   % to avoid lame warning ...
\usepackage[sectionbib]{bibunits} % enable several bibliography. The sectionbib sets bibliography titles at section level
\usepackage{blindtext}
\begin{filecontents}{test.bib}
@article{test,
    author={A Dummy Reference},
    title = {\blindtext[7]},
    journal = {Some random Journal},
    year = {2013}
}
\end{filecontents}
\defaultbibliography{test}      % source for references
\renewcommand\bibname{References} % rename bibliography as references
\newtoks\paperTitle

\usepackage{titlesec}
\newcommand{\includePaper}[1]{
    \begin{bibunit}
        \part{\the\paperTitle}
        \vspace*{50pt}
        {\noindent\raggedright\normalfont\LARGE\bfseries\the\paperTitle\par\nobreak}
        \vspace*{40pt}
        \chaptermark{\the\paperTitle}
        #1 % contents
        \clearpage
        \putbib
        \sectionmark{References}   % <- I want this as \rightmark
        \chaptermark{\the\paperTitle} % <- I want this as \leftmark
        \cleardoublepage
    \end{bibunit}
}
\makeatletter
\renewcommand\thesection{\@arabic\c@section}
\@addtoreset{section}{part}
\makeatother
\titleformat{\section}[hang]{\bfseries\Large}{\thesection.\quad}{0pt}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}

\begin{bibunit}
\chapter*{Introduction}
\chaptermark{Introduction}
\section{First section in introduction}
\blindtext[10]\cite{test}
\clearpage
\putbib
\sectionmark{References}   % <- I want this as \rightmark
\chaptermark{Introduction} % <- I want this as \leftmark
\cleardoublepage
\end{bibunit}

\paperTitle{First paper title}%
\includePaper{\section{First section in paper}\blindtext[8]\cite{test}}
\end{document}
  • The code does not compile, undefined control sequences – Åke Jul 3 at 12:30
  • Yes, sorry about that, I tried to optimize the MWE. It is fixed now. – user253249 Jul 3 at 12:33
0

AFAIK the usage of running headers for the bibliography etc can not be disabled by a fancyhdr pagestyle. You could use pagestyle myheadings for those pages, but then the layout of the header is different, eg. there is no headsepline.

So here is a suggestion using package scrlayer-scrpage. Note that this package can not be used together with fancyhdr.

\documentclass[b5paper, twoside, 11pt]{book}

\usepackage[headsepline,automark,markcase=noupper]{scrlayer-scrpage}
\renewcommand*\chaptermarkformat{}
\renewcommand*\sectionmarkformat{}
\addtokomafont{pageheadfoot}{\normalfont}

\setlength{\headheight}{13.6pt}   % to avoid lame warning ...
\usepackage[sectionbib]{bibunits} % enable several bibliography. The sectionbib sets bibliography titles at section level
\usepackage{blindtext}
\begin{filecontents}{test.bib}
@article{test,
    author={A Dummy Reference},
    title = {\blindtext[7]},
    journal = {Some random Journal},
    year = {2013}
}
\end{filecontents}
\defaultbibliography{test}      % source for references
\renewcommand\bibname{References} % rename bibliography as references
\newtoks\paperTitle

\usepackage{titlesec}
\newcommand{\includePaper}[1]{
    \begin{bibunit}
        \part{\the\paperTitle}
        \vspace*{50pt}
        {\noindent\raggedright\normalfont\LARGE\bfseries\the\paperTitle\par\nobreak}
        \vspace*{40pt}
        \markboth{\the\paperTitle}{}
        #1 % contents
        \clearpage
        \KOMAoptions{manualmark}
        \markright{References}
        \putbib
        \cleardoublepage
        \KOMAoptions{automark}
    \end{bibunit}
}
\makeatletter
\renewcommand\thesection{\@arabic\c@section}
\@addtoreset{section}{part}
\makeatother
\titleformat{\section}[hang]{\bfseries\Large}{\thesection.\quad}{0pt}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{bibunit}
\chapter*{Introduction}
\markleft{Introduction}
\section{First section in introduction}
\blindtext[14]\cite{test}
\clearpage
\KOMAoptions{manualmark}
\markright{References}
\putbib
\cleardoublepage
\KOMAoptions{automark}
\end{bibunit}

\paperTitle{First paper title}%
\includePaper{\section{First section in paper}\blindtext[8]\cite{test}}
\end{document}

enter image description here

enter image description here


You can also use package scrlayer-fancyhdr:

\documentclass[b5paper, twoside, 11pt]{book}

\usepackage{scrlayer-fancyhdr}           % needed for fancy headers
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}

\setlength{\headheight}{13.6pt}   % to avoid lame warning ...
\usepackage[sectionbib]{bibunits} % enable several bibliography. The sectionbib sets bibliography titles at section level
\usepackage{blindtext}
\begin{filecontents}{test.bib}
@article{test,
    author={A Dummy Reference},
    title = {\blindtext[7]},
    journal = {Some random Journal},
    year = {2013}
}
\end{filecontents}
\defaultbibliography{test}      % source for references
\renewcommand\bibname{References} % rename bibliography as references
\newtoks\paperTitle

\usepackage{titlesec}
\newcommand{\includePaper}[1]{
    \begin{bibunit}
        \part{\the\paperTitle}
        \vspace*{50pt}
        {\noindent\raggedright\normalfont\LARGE\bfseries\the\paperTitle\par\nobreak}
        \vspace*{40pt}
        \chaptermark{\the\paperTitle}
        #1 % contents
        \clearpage
        \KOMAoptions{manualmark}
        \markright{References}   % <- I want this as \rightmark
        \putbib
        \cleardoublepage
        \KOMAoptions{automark}
    \end{bibunit}
}
\makeatletter
\renewcommand\thesection{\@arabic\c@section}
\@addtoreset{section}{part}
\makeatother
\titleformat{\section}[hang]{\bfseries\Large}{\thesection.\quad}{0pt}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{bibunit}
\chapter*{Introduction}
\chaptermark{Introduction}
\section{First section in introduction}
\blindtext[14]\cite{test}
\clearpage
\KOMAoptions{manualmark}
\rightmark{References}   % <- I want this as \rightmark
\putbib
\cleardoublepage
\KOMAoptions{automark}
\end{bibunit}

\paperTitle{First paper title}%
\includePaper{\section{First section in paper}\blindtext[8]\cite{test}}
\end{document}
  • This works! I only needed to change \pagestyle{empty} to \thispagestyle{empty} in the full document. (btw. you have duplicated the first solution into the second solution). – user253249 Jul 4 at 9:17

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.