5

How can I have a bibliography per section which shows only the references cited within the section? At the end, I also want a global bibliography which includes all cited references in any section.

As far as labels go, I want them global. So if labels are numeric, then [1] can appear in multiple sections but it always corresponds to the [1] that is in the global bibliography. If the labels are [Author00] then that same label would appear in multiple locations, consistently referring to the same bibitem.

Finally, there is the question of the hyperlink attached to the label. Should it go to the local bibliography or to the global bibliography? For now, I prefer local, but it would be nice to have this configurable.

If it matters, I want to do this with a single bibtex file. I've seen piecemeal answers here and there, but not much on what happens when you click the hyperlink.

5

With each section corresponding to a new reference section, you get "local" labels pointing to the local bibliographies.

With each section corresponding to a new reference segment, you get "global" labels pointing to the first instance the corresponding bibliography entry is printed.

Neither case gives you the desired result. The document below demonstrates how you can modify some internals to obtain the desired links with reference segments. The new boolean flag anchorsegments targets the local bibliographies when true and the global bibliography otherwise.

\documentclass{article}
\usepackage[refsegment=section]{biblatex}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}

\newbool{anchorsegments}
\booltrue{anchorsegments}

\makeatletter

\AtBeginDocument{%
  \ifbool{anchorsegments}
    {\long\def\blx@bibhyperref[#1]#2{%
       \blx@sfsave\hyper@natlinkstart{\the\c@refsection @\the\c@refsegment @#1}%
       \blx@sfrest
       #2%
       \blx@sfsave\hyper@natlinkend\blx@sfrest}%
     \protected\long\def\blx@imc@bibhyperlink#1#2{%
       \blx@sfsave\hyper@natlinkstart{\the\c@refsection:\the\c@refsegment:#1}%
       \blx@sfrest
       #2%
       \blx@sfsave\hyper@natlinkend\blx@sfrest}%
     \protected\long\def\blx@imc@bibhypertarget#1#2{%
       \blx@sfsave\hyper@natanchorstart{\the\c@refsection:\the\c@refsegment:#1}%
       \blx@sfrest
       #2%
       \blx@sfsave\hyper@natanchorend\blx@sfrest}%
     \protected\def\blx@anchor{%
       \xifinlist
         {\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}
         {\blx@anchors}
         {}
         {\listxadd
            {\blx@anchors}
            {\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}%
          \hyper@natanchorstart{%
            \the\c@refsection @\the\c@refsegment @\abx@field@entrykey}%
          \hyper@natanchorend}}%
     \defbibheading{subbibliography}{\subsection*{Local references}}}
    {\defbibheading{subbibliography}{%
       \AtNextBibliography{\let\blx@anchor\relax}%
       \subsection*{Local references}}}}

\makeatother

\defbibheading{bibliography}{\section*{Global references}}

\begin{document}

\section{Title}
Filler \parencite{companion,markey,knuth:ct}.
\printbibliography[segment=1,heading=subbibliography]

\newpage
\section{Title}
Filler \parencite{markey,bertram,companion}.
\printbibliography[segment=2,heading=subbibliography]

\newpage
\printbibliography

\newpage\null

\end{document}

Here local anchors are obtained by inserting \the\c@refsegment into link identifiers so that they are specific to both the reference section and segment. Global anchors are achieved by avoiding anchor definitions in each of the local bibliographies via \AtNextBibliography{\let\blx@anchor\relax}.

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.