biblatex

biblatex

我有一份包含大量编号参考书目的文档,例如从 1 到 600。我希望将页面的第一个和最后一个参考编号插入到页面标题中。如下例所示:

在此处输入图片描述

我正在使用的fancyhdr已经解释过了回答

\documentclass[a4,11pt,twoside]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LE]{\slshape My text}
\fancyhead[RE]{}
\fancyhead[LO]{\hfill \slshape \leftmark}

\renewcommand{\headrulewidth}{0pt}

\usepackage{kantlipsum}

\title{My title}
\author{My name}
\date{}

\begin{document}

\renewcommand{\headrulewidth}{.4pt}

\chapter{example}

\kant[1-3]\clearpage

\fancyhead[LE]{\slshape BIBLIOGRAPHY 19 - 42}

\begin{thebibliography}{99}

\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}
\bibitem{example}

\end{thebibliography}

\end{document}

是否有可能存在一种同样适用于的方法 \usepackage[backend=biber]{biblatex}

答案1

biblatex

这是 的解决方案biblatex。我们可以(滥用)使用标记机制,每个条目设置标记,然后标题抓取\rightmark\leftmark,其中包含每页上的第一个和最后一个参考编号。

\documentclass[british]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=numeric, backend=biber]{biblatex}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LE]{\slshape My text}
\fancyhead[RE]{}
\fancyhead[LO]{\hfill \slshape \leftmark}

\defbibheading{bibliography}[\bibname]{%
  \chapter*{#1}%
  \fancyhead{}%
  \fancyhead[RO,LE]{#1 \rightmark{} -- \leftmark}}

\makeatletter
\providecommand*{\@mkdouble}[1]{\@mkboth{#1}{#1}}

\newcommand*{\markbib}{%
  \@mkdouble{\thefield{labelprefix}\thefield{labelnumber}}}
\makeatother

\renewbibmacro*{begentry}{\markbib}


\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

带有引用编号的标题。


thebibliography/BibTeX

结构类似的方法适用于标准thebibliography(如果您使用不同的文档类或更复杂的参考书目包,则可能需要调整定义natbib)。

事情变得更加@复杂,因为我们必须重新定义完整的thebibliography环境才能改变标题并将\@lbibitem引用\@bibitem标签放入标记机制中。

\documentclass[british]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}


\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LE]{\slshape My text}
\fancyhead[RE]{}
\fancyhead[LO]{\hfill \slshape \leftmark}

\makeatletter
% \@lbibitem & \@bibitem from latex.ltx
% the only change apart from indentation is the addition of \markbib
\def\@lbibitem[#1]#2{%
  \item[\@biblabel{#1}\hfill]%
  \markbib{#1}% <-- added
  \if@filesw
    {\let\protect\noexpand
     \immediate\write\@auxout
       {\string\bibcite{#2}{#1}}}%
  \fi
  \ignorespaces}
\def\@bibitem#1{%
  \item
  \markbib{\the\value{\@listctr}}% <-- added
  \if@filesw
    \immediate\write\@auxout
       {\string\bibcite{#1}{\the\value{\@listctr}}}%
  \fi
  \ignorespaces}

% from book.cls
% only change was to add the two \fancyhead calls
\renewenvironment{thebibliography}[1]
     {\chapter*{\bibname}%
      \fancyhead{}% <-- added
      \fancyhead[RO,LE]{\bibname{} \rightmark{} -- \leftmark}% <-- added
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

\providecommand*{\@mkdouble}[1]{\@mkboth{#1}{#1}}

\newcommand*{\markbib}{\@mkdouble}
\makeatother


\begin{document}
\nocite{*}
\begin{thebibliography}{99}

\bibitem{example01}
\bibitem{example02}
\bibitem{example03}
\bibitem{example04}
\bibitem{example05}
\bibitem{example06}
\bibitem{example07}
\bibitem{example08}
\bibitem{example09}
\bibitem{example10}
\bibitem{example11}
\bibitem{example12}
\bibitem{example13}
\bibitem{example14}
\bibitem{example15}
\bibitem{example16}
\bibitem{example17}
\bibitem{example18}
\bibitem{example19}
\bibitem{example20}
\bibitem{example21}
\bibitem{example22}
\bibitem{example23}
\bibitem{example24}
\bibitem{example25}
\bibitem{example26}
\bibitem{example27}
\bibitem{example28}
\bibitem{example29}
\bibitem{example30}
\bibitem{example31}
\bibitem{example32}
\bibitem{example33}
\bibitem{example34}
\bibitem{example35}
\bibitem{example36}
\bibitem{example37}
\bibitem{example38}
\bibitem{example39}
\bibitem{example40}
\bibitem{example41}
\bibitem{example42}
\bibitem{example43}
\bibitem{example44}
\bibitem{example45}
\bibitem{example46}
\bibitem{example47}

\end{thebibliography}
\end{document}

相关内容