当我在参考部分更改 \leftmark 的行为时,它只会在该部分的第二个奇数页上发生变化(默认情况下,\leftmark 和 \rightmark 都设置为 \bibname)。使用以下代码编译下面的 MWE
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
这是什么原因呢?
\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}
答案1
据我所知,参考书目等的运行页眉的使用不能通过fancyhdr
页面样式禁用。您可以myheadings
对这些页面使用页面样式,但页眉的布局会有所不同,例如没有页眉。
所以这里建议使用包scrlayer-scrpage
。注意,此包不能与一起使用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}
您还可以使用包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}