3

A simple question, but I was unable to find it on Stackexchange here or somewhere else.

I want to cross-reference the header generated by \printbibliography, i.e. not a specific entry but just the title/starting page.

How can I do that?

I do use it like this:

\printbibliography[title={Quellenverzeichnis}, heading=subbibnumbered]

The problem is the package generates its heading automatically, so I cannot just place a \label there and refer to that.

Basically, I just want to do what's needed so I can use the usual \ref, \hyperref,\autoref, \fullref etc.

And I also have not found anything in the biblatex docs (page 88 ff. aka sec. 3.7.2 it starts to talk about the \printbibliography command.).

rugk
  • 1,090
  • 1
  • 10
  • 27
  • What exactly is the use case you have in mind? Is writing something such as "As is noted in the Quellenverzeichnis at the end of this article, ..." not clear enough? Are you concerned that if readers can't click on a link that takes them to the first page of the formatted bibliography, they won't be able to find the bibliography? – Mico Aug 17 '20 at 13:01
  • Well… the use case is I do list some files as local copies for some sources in the bibliography and I do want to add a note in the appendix that says "The local copies that are referenced in the Quellenverzeichnis are placed in the directory … in the accompanying ZIP/USB drive [etc.]". In any case, even in your sentence I would find it very useful if the term "bibliography" could already link to the page where this is found. If I have hyperref, why not make use of it? – rugk Aug 17 '20 at 13:05
  • Might your readers be better served if you stated the individual bibliographic entries (using the usual \cite-type commands) for which electronic copies are made available on some device? The mere fact that your paper contains a Quellenverzeichnis needn't be demonstrated by providing a suitable hyperlink, does it? – Mico Aug 17 '20 at 13:40
  • It's more of a requirement, so no. It's offline copies of files I actually can already link to, see the linked question). Anyway, it's slightly off-topic for this question, so see the question I've linked. – rugk Aug 17 '20 at 13:42

3 Answers3

4

Since v3.16 of biblatex you now can use label .

Example and so on copied from the issue/feature request, so all credits goes to @moewew, who also implemented this.

Here an example:

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

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

\addbibresource{biblatex-examples.bib}

\begin{document} \autocite{sigfridsson}

\Cref{biblabel}

\printbibliography[heading=bibnumbered, label=biblabel] \end{document}

rugk
  • 1,090
  • 1
  • 10
  • 27
  • Ah @moewe sorry just now saw you are here too. If you want to get the credits for this new updated answer, feel free to repost it and I'll accept that. – rugk Jan 03 '21 at 16:41
3

Weirdly, I can't find an obvious way of doing this.

Here's an option which prints the heading, then inserts the label, then prints the rest of the bibliography. For some reason unknown to me, the \@currentlabel isn't updated by \printbibheading, so I need the hack to decrement the subsection counter, then increment it using \refstepcounter.

I'm left thinking there must be a better option.

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage[colorlinks]{hyperref}
\begin{document}
\section{Here}
\subsection{There}
Page \pageref{bib}. Section \ref{bib}.
\nocite{westfahl:space,aksin}
\printbibheading[title=Quellenverzeichnis, heading=subbibnumbered]
\addtocounter{subsection}{-1}
\refstepcounter{subsection}
\label{bib}
\printbibliography[heading=none]
\end{document}

Output

David Purton
  • 25,884
  • The assignment of \@currentlabel is always local. Since \printbibheading is processed in a group (to make sure the options don't spill out), \@currentlabel can't leave the group. – moewe Aug 17 '20 at 14:13
  • The grouping is the same issue as https://tex.stackexchange.com/a/534569/35864 – moewe Aug 17 '20 at 14:22
  • @moewe oh yes, I should have remembered that. – David Purton Aug 18 '20 at 00:46
3

Since you are already explicitly give the title of your bibliography, you can just sneak in a \label there.

With David Purton's MWE and the obvious changes

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage[colorlinks]{hyperref}
\begin{document}
\section{Here}
\subsection{There}
Page \pageref{bib}. Section \ref{bib}.
\nocite{sigfridsson,worman}

\printbibliography[title={Quellenverzeichnis\label{bib}}, heading=subbibnumbered] \end{document}

Page 1. Section 1.2.

If you'd like a solution that automatically selects 'References' or 'Bibliography' depending on the class, you can try

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage[colorlinks]{hyperref}

\makeatletter \newcommand*{\reforbibname}{% \ifodd\abx@classtype\relax \bibname \else \refname \fi } \makeatother

\begin{document} \section{Here} \subsection{There} Page \pageref{bib}. Section \ref{bib}. \nocite{sigfridsson,worman}

\printbibliography[title={\reforbibname\label{bib}}, heading=subbibnumbered] \end{document}

The internal command \abx@classtype is used by biblatex to detect certain classes. Conveniently, the 'even classes' are article-like and use \refname, the 'odd classes' are report/book-like and use \bibname.

Note that this does not take into account possible changes of the default title in bibliography heading definitions.


An alternative would be to include the \label directly in the bibliography heading definition. In this case that would be

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage[colorlinks]{hyperref}

\defbibheading{subbibnumbered:link}[\refname]{% \subsection{#1}% \label{bib}}

\begin{document} \section{Here} \subsection{There} Page \pageref{bib}. Section \ref{bib}. \nocite{sigfridsson,worman}

\printbibliography[heading=subbibnumbered:link] \end{document}

(of course you could overwrite the bibheading subbibnumbered if you like, but since the label is hard-coded in the heading, it may be better to choose a unique name to avoid using it twice.) In any case, this requires you to know/copy the original definition of the bibliography heading used in your document.

moewe
  • 175,683
  • And if I did not defined it – I guess there is some macro I could use to keep the default title? – rugk Aug 17 '20 at 14:13
  • But yeah, fun, but a really hacky/"workaroundish" solution… – rugk Aug 17 '20 at 14:13
  • 1
    @rugk title={\refname\label{bib}} or title={\bibname\label{bib}}. The only other option I see is to integrate the \label directly into the bibliography heading as defined with \defbibheading. But the code there is usually much longer, so this solution here seems quicker. – moewe Aug 17 '20 at 14:15
  • @rugk That all said, it would certainly be possible to add an option to \printbibliography to set a label after the heading. Implementing it for/in this answer would result in something I'd see as much more hacky than what I presented here so far, because it would involve messing with many, many internal commands. But if you think that would be useful you can always ask that it be implemented officially: Just go to https://github.com/plk/biblatex/issues and open an issue. – moewe Aug 17 '20 at 14:38
  • Yeah, indeed, fine. (After all, having a label assigned by default or so would be enough) I've asked for that here: https://github.com/plk/biblatex/issues/1036 – rugk Aug 17 '20 at 14:50