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.

2
  • 1
    have you seen Per-chapter bibliographies in biblatex
    – cmhughes
    Commented Nov 6, 2013 at 18:00
  • I have, but it doesn't address my question about hyperlinks. At least, it wasn't clear where those linked to.
    – Tom
    Commented Nov 6, 2013 at 18:02

1 Answer 1

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}.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .