josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.4k stars 141 forks source link

Missalignment of biblatex bibligraphy with sidebar outer theme #645

Open samcarter opened 3 years ago

samcarter commented 3 years ago

The sidebar outer theme contains \usebeamerfont{frametitle}, which leads to a misalignment of a biblatex bibliography:

\documentclass{beamer}

\useoutertheme{sidebar}

\usepackage[style=authortitle]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}

\begin{frame}
  \nocite{knuth:ct:a}
  \printbibliography
\end{frame}

\end{document}

Screen Shot 2020-11-30 at 13 17 06

samcarter commented 3 years ago

mmm, switching back to normal size seems to avoid the problem

\documentclass{beamer}

\usetheme{PaloAlto}
\normalsize

\usepackage[style=authortitle]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}

\begin{frame}
  \nocite{knuth:ct:a}
  \printbibliography
\end{frame}

\end{document}
samcarter commented 3 years ago

OK, so the problem is that Beamer uses a \parindent of zero. For this case biblatex sets the parindent to 1em at the time of package load and not at the time the bibliography is set. As the sidebar theme uses a bigger than normal font in the preamble this means that the indention is wrong, so the bibhang needs to be reset when the bibliography is actually used.

https://github.com/samcarter/beamer/commit/7df166c0332b70c4933fae7e85daffc5f4c448dc

samcarter commented 3 years ago

Wondering if this isn't actually a biblatex bug ....

samcarter commented 3 years ago

(maybe I need a second github account - all this talking to myself makes me sound crazy)

samcarter commented 3 years ago

I'm wondering if using a modified bibliography environment from the numeric style wouldn't be a better approach, e.g. https://github.com/samcarter/beamer/commit/66205aa0c07c682beaff6cbb32360beb233cc70e

@moewew What do you think?

moewew commented 3 years ago

Given that beamer essentially turns the bibliography into an itemize with the little icons as bullets, the approach in https://github.com/samcarter/beamer/commit/66205aa0c07c682beaff6cbb32360beb233cc70e that makes this explicit by properly defining a list format that is suitable for that task (instead of trying to bend the lengths in the default bibliography list with hanging indent into a shape that sort of works) looks much better.

There is one thing I worry about, though: What if the user wants to get rid of the icons with the authoryear or authortitle style? Currently I can say \setbeamertemplate{bibliography item}{} and get back the normally indented bibliography (with hanging indent). I'm not sure how that would work if beamer overwrites the bibliography environment.

I don't think you want \newlength{\beamer@bibiconwidth} inside the bibliography environment. This could cause problems if people issue \printbibliography multiple times. It should be enough to declare the length once globally. Though I'm wondering if you need it at all. Can't you replace

          \newlength{\beamer@bibiconwidth}%
          \settowidth\beamer@bibiconwidth{\usebeamertemplate*{bibliography item}}%
          \setlength{\labelwidth}{\beamer@bibiconwidth}%

from https://github.com/samcarter/beamer/blob/66205aa0c07c682beaff6cbb32360beb233cc70e/base/beamerbaselocalstructure.sty#L510-L512 with

          \settowidth{\labelwidth}{\usebeamertemplate*{bibliography item}}%
samcarter commented 3 years ago

@moewew Thank you so much for your analysis and all this information!