Open moewew opened 5 years ago
It would certainly be useful to change the default \labelnumberwidth
if biblatex
is used in combination with beamer (also setting \setbeamertemplate{bibliography item}[text]
for numerical styles would be great!)
Instead of hardcoding a value, I would suggest something like
\settowidth\labelnumberwidth{\usebeamertemplate*{bibliography item}}%
to get the width of the default icon. This way the width would adept if the user replaces the icons.
Yes,
\settowidth\labelnumberwidth{\usebeamertemplate*{bibliography item}}%
looks a lot nicer than hard-coding the value. Can we branch on whether \setbeamertemplate{bibliography item}[text]
is in force or not before doing that? I'm also not quite sure where exactly the assignment should happen. Easiest would probably be somewhere in \blx@env@bibliography
that is patched already.
As to whether or not this should happen on the biblatex
side, I'm not sure. Obviously I'm biased, but beamer
also patches normal BibTeX idioms, so it makes sense to have beamer
deal with this. The question of who should take care of a interface between two packages is tricky and biblatex
already has its fingers in quite a few pies that it should have no business with (I'm thinking the footnote and section heading patching). The headings thingy in biblatex.def
is another issue. Traditionally that was taken care of by the document class by redefining thebibliography
, but since biblatex
does not use thebibliography
it would not obey most class settings. I guess PL felt that it would help biblatex
's ambitions if it at least interfaced in some (limited) way with the big KOMA-Script and memoir
classes. It has been argued that it would help if biblatex
would offer a clear interface for class authors to make their changes instead of trying to only work with the big three (standard classes, KOMA-Script, memoir
) or so (https://github.com/plk/biblatex/issues/693). It probably also comes down to which side has more to gain (or lose) by supporting (or not supporting) the other side. Another factor is whether or not the other side can reasonably be expected to implement the relevant changes (most BibTeX styles and the standard classes are pretty stable...).
Can we branch on whether \setbeamertemplate{bibliography item}[text] is in force or not before doing that?
This is something I was wondering myself yesterday, but stopped looking for a solution because I realised that checking if the text
template is currently active would ultimately not solve the problem. For example it does not take into account any custom templates, for example
\setbeamertemplate{bibliography item}{\insertbiblabel}
I would prefer to measure the width of \usebeamertemplate*{bibliography item}
at the begin of the bibliography. Technically this should also be possible for the text
template, I just see two obstacles to tackle:
at the places where I tried \insertbiblabel
was not yet defined, but this is hopefully just a problem of where to measure the width
(related to this) how to make sure that the width is measured with the wides \insertbiblabel
@moewew Do you know if there is a good way to check if the selected bibliography style is numeric? The best thing I could find was \blx@bbxfile
, but then one would still have to test for numeric, numeric-comp, numeric-verb, ....
Do you know if there is a good way to check if the selected bibliography style is numeric?
Not really, sorry. As you write, you could check \blx@cbxfile
or \blx@bbxfile
but that only gives you the file name of the style, which might tell you something about the user's intention for the standard styles, but in theory the user could well rewrite stuff to get something else entirely. The option labelnumber
that is set by all numeric styles comes with a toggle blx@labelnumber
, but again the state of the toggle at a point where you can query it (its global state) does not tell us with certainty if we are dealing with a numeric style or not.
In the end you only know if a bibliography is numeric when you analyse its \defbibenvironment
and it prints the labelnumber
. But I don't know of there is an automatic way to do that. Or at least a good enough indicator.
@moewew Thanks for your reply! For my personal use checking for \blx@bbxfile
seems to work good enough.
In the bigger picture, this problematic might be easier to solve if it would be up to the biblatex style to modify the template if used with beamer instead of having beamer do it.... (I know we have quite different opinions on this :) )
In case anyone is interested: A suggestion how to repair alignment/labels for some often used biblatex styles can be found at https://github.com/samcarter/beamer/commit/c5fe3d76e7b995c0a023791f1a7464c5e8fe9fa0
I still think it would be better to include this in the respective biblatex styles because:
\begin{document}
feels too late and bereaves the user of the possibility to conveniently adjust these settings in the preamble. For example it would break customisations like https://tex.stackexchange.com/questions/291296/biblatex-beamer-missing-citation-abbreviation-in-the-bibliographyRelated Q&As
Just a short heads-up: We are planning on releasing biblatex
3.15 and Biber 2.15 shortly. Since the Biber binaries need to be built by binary contributors it may take a few days until the update hits CTAN.
It suppose the fix in https://github.com/josephwright/beamer/commit/2a81ef0c0172a4ba7ee11676a177c7f6fd21cf3d only works for the default font size setting. If I use \documentclass[10pt]{beamer}
, for instance, I still have the same problem:
\documentclass[10pt]{beamer}
\usepackage[backend=biber,style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\begin{frame}
\textcite{knuth:ct}
\end{frame}
\begin{frame}{Bibliography}
\printbibliography[heading=none]
\end{frame}
\end{document}
https://tex.stackexchange.com/q/481724/35864 made me aware of the following issue.
Consider
If one looks closely one can see that the first line is shifted slightly to the right compared to the following lines.
AFAICS this is caused by the fact that
beamer
substitutes its bibliography picture for the label number, butbiblatex
calculated the labelwidth based on the actual numeric label.A possible fix would be to set the
\labelnumberwidth
to a fixed (and suitable) value whenbeamer
uses its pictures. Something like(I just guessed the exact length here).
edit
https://github.com/josephwright/beamer/blob/04b25165835abcbe39294c9f5d89c371c70ba8c3/base/themes/inner/beamerinnerthemedefault.sty#L16-L36
suggest that
14pt
might be more appropriate.edit 2
Just setting
\setlength{\labelnumberwidth}{14pt}
in the preamble or early enough would essentially mean that14pt
is the minimum value for\labelnumberwidth
. Ridiculously long labels could make it much larger which would cause the bibliography list to be indented too far to the right. So it might make sense to set the value only directly in the bibliography environment if the icons are used.