如何更改参考文献第一页的页眉和页脚

如何更改参考文献第一页的页眉和页脚

我正在尝试更改参考文献部分第一页的分页。我一直使用 fancyhdr 自定义页眉中的分页,以满足学校论文格式的要求。在文章类中,章节的第一页将其第一页样式重置为纯文本,因此 fancyhdr 样式永远不会应用,因为它会被覆盖。fancyhdr 手册提供了一种解决方案,即编辑纯文本样式,但我需要保持朴素的风格因为我在其他地方也用过。所以我的问题是,我该如何设置参考资料部分第一页的页眉/页脚,以便它使用花哨的样式,无需编辑普通的页面样式?

以下是 MWE:

\documentclass[12pt]{report}
\usepackage[natbibapa]{apacite}
\usepackage{lipsum}

\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\thepage}
\pagestyle{fancy}

\begin{document}

\chapter{Test}
\thispagestyle{fancy} %% This works
\lipsum[1-4]
\citep{R, lme4, MCMCglmm, MASS, lmerTest, gplots, foreign, CAR, brms}

\bibliographystyle{apacite}
\thispagestyle{fancy} %% This doesn't work
\bibliography{References}
\thispagestyle{fancy} %% Nor this

\end{document}

References.bib 文件包含以下内容:

@Manual{R,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2015},
    url = {https://www.R-project.org/},
}

@Article{lme4,
    title = {Fitting Linear Mixed-Effects Models Using {lme4}},
    author = {Douglas Bates and Martin M{\"a}chler and Ben Bolker and Steve Walker},
    journal = {Journal of Statistical Software},
    year = {2015},
    volume = {67},
    number = {1},
    pages = {1--48},
    doi = {10.18637/jss.v067.i01},
}

@Article{MCMCglmm,
    title = {MCMC Methods for Multi-Response Generalized Linear Mixed Models: The {MCMCglmm} {R} Package},
    author = {Jarrod D Hadfield},
    journal = {Journal of Statistical Software},
    year = {2010},
    volume = {33},
    number = {2},
    pages = {1--22},
    url = {http://www.jstatsoft.org/v33/i02/},
}

@Manual{lmerTest,
    title = {lmerTest: Tests in Linear Mixed Effects Models},
    author = {Alexandra Kuznetsova and Per {Bruun Brockhoff} and Rune {Haubo Bojesen Christensen}},
    year = {2015},
    note = {R package version 2.0-29},
    url = {https://CRAN.R-project.org/package=lmerTest},
}

@Book{MASS,
    title = {Modern Applied Statistics with S},
    author = {W. N. Venables and B. D. Ripley},
    publisher = {Springer},
    edition = {Fourth},
    address = {New York},
    year = {2002},
    note = {ISBN 0-387-95457-0},
    url = {http://www.stats.ox.ac.uk/pub/MASS4},
}

@Manual{gplots,
    title = {gplots: Various R Programming Tools for Plotting Data},
    author = {Gregory R. Warnes and Ben Bolker and Lodewijk Bonebakker and Robert Gentleman and Wolfgang Huber Andy Liaw and Thomas Lumley and Martin Maechler and Arni Magnusson and Steffen Moeller and Marc Schwartz and Bill Venables},
    year = {2015},
    note = {R package version 2.17.0},
    url = {https://CRAN.R-project.org/package=gplots},
}

@Manual{foreign,
    title = {foreign: Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, Weka,
dBase, ...},
    author = {{R Core Team}},
    year = {2015},
    note = {R package version 0.8-66},
    url = {https://CRAN.R-project.org/package=foreign},
}

@Book{CAR,
    title = {An {R} Companion to Applied Regression},
    edition = {Second},
    author = {John Fox and Sanford Weisberg},
    year = {2011},
    publisher = {Sage},
    address = {Thousand Oaks {CA}},
    url = {http://socserv.socsci.mcmaster.ca/jfox/Books/Companion},
}

@Manual{brms,
    title = {brms: Bayesian Regression Models using Stan},
    author = {Paul-Christian Buerkner},
    year = {2015},
    note = {R package version 0.6.0},
    url = {https://CRAN.R-project.org/package=brms},
}

我必须让 MWE 中的参考文献部分长度超过一页,否则,单页页码会正确。但是当长度超过两页时,我似乎无法让参考文献部分使用第一页上的花哨页面样式。

答案1

如果您不想重新定义plain(即使是暂时的),您可以重新定义thebibliography(从 apacite.sty)。

\documentclass[12pt]{report}
\usepackage[natbibapa]{apacite}
\usepackage{lipsum}

\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\thepage}
\pagestyle{fancy}

\makeatletter
\def\thebibliography#1{%
  \@ifundefined{chapter}%
    {\st@rtbibsection}%
    {\if@sectionbibdefault
       {\@ifundefined{@mainmatterfalse}%
          {\st@rtbibchapter\thispagestyle{fancy}}%
          {\if@mainmatter
             \st@rtbibsection
           \else
             \st@rtbibchapter\thispagestyle{fancy}%
           \fi
          }%
       }%
     \else
        \if@sectionbib
          \st@rtbibsection
        \else
          \st@rtbibchapter\thispagestyle{fancy}%
        \fi
     \fi
    }%
  \bibliographytypesize % e.g., to put the bibliography in \small type
  \bibliographyprenote  % some explanatory note before the references
  \@ifundefined{APAC@metaprenote@\APAC@extra@b@citeb}%
    {}% skip
    {\csname APAC@metaprenote@\APAC@extra@b@citeb\endcsname}%
  \list{\relax}{\labelsep=\biblabelsep
                \parsep=\bibparsep
                \itemsep=\bibitemsep
                \leftmargin=\bibleftmargin
                \itemindent=\bibindent}% changed to cope with 4th ed.
   \def\newblock{\hskip .11em plus .33em minus .07em}%
   \sloppy\clubpenalty4000\widowpenalty4000
   \sfcode`\.=1000\relax %'
   \bt@beg@thb@hook
   \APACrestorebibitem
}
\makeatother

\begin{document}

\chapter{Test}
\thispagestyle{fancy} %% This works
\lipsum[1-4]
\citep{R, lme4, MCMCglmm, MASS, lmerTest, gplots, foreign, CAR, brms}

\bibliographystyle{apacite}
\bibliography{references}

\end{document}

或者你也可以添加

\makeatletter
\let\ps@plain=\ps@fancy
\makeatother

就在参考书目之前。

答案2

这是一个解决方案。我们需要重新定义plain风格

\documentclass[12pt]{report}
\usepackage[natbibapa]{apacite}
\usepackage{lipsum}

\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\thepage}
\pagestyle{fancy}

\begin{document}

\chapter{Test}
\thispagestyle{fancy} %% This works
\lipsum[1-4]
\citep{R, lme4, MCMCglmm, MASS, lmerTest, gplots, foreign, CAR, brms}

\bibliographystyle{apacite}

\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[R]{\thepage}}
\bibliography{References}

\end{document}

相关内容