TeX - LaTeX Asked by rugk on December 9, 2020
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.).
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={Quellenverzeichnislabel{bib}}, heading=subbibnumbered]
end{document}
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}{%
ifoddabx@classtyperelax
bibname
else
refname
fi
}
makeatother
begin{document}
section{Here}
subsection{There}
Page pageref{bib}. Section ref{bib}.
nocite{sigfridsson,worman}
printbibliography[title={reforbibnamelabel{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.
Correct answer by moewe on December 9, 2020
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}
Answered by David Purton on December 9, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP