Closed user227621 closed 1 year ago
Could you maybe add a screenshot of your result? The alignment looks fine to me:
@samcarter The vertical shift is visible on your screenshot when you zoom in: There is no space between the red line and "2/11", but there is a tiny space (one pixel high) between the red line and "3/11".
I think I understand what you mean, thanks for reporting!
Personally I don't think a pixel at several hundred percent zoom level is worth increasing the code complexity. Making the code more complex has potential drawbacks, like making it slower and harder to maintain.
Meanwhile @Skillmon found a more drastic example:
\documentclass[]{beamer}
\usepackage[oldstyle]{kpfonts}
\geometry{papersize={1cm,1cm}}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[frame number]
\newcommand\emptyframe{\begin{frame}\end{frame}}
\begin{document}
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\emptyframe
\end{document}
@samcarter \usepackage[oldstyle]{noto-sans}
would have been a more drastic example, too... Thanks for fixing this issue!
@user227621 You're welcome!
Yes, the examples with oldstyle where pretty convincing - with them I didn't even have to recompile texstudio in order to allow more then 400% zoom level just to be able to see a hint of a problem :)
@samcarter I just noticed that there is a missing percent sign in \defbeamertemplate{footline}{frame number}
:
\defbeamertemplate{footline}{frame number}
{% <----- MISSING
\hfill%
\usebeamercolor[fg]{page number in head/foot}%
\usebeamerfont{page number in head/foot}%
\setbeamertemplate{page number in head/foot}[totalframenumber]%
\strut\usebeamertemplate*{page number in head/foot}\kern1em\vskip1.4pt%
}
I don't know if this could produce spurious spaces, but it would probably be best if you added the missing percent sign.
The %
is not necessary there.
However, the %
is present in the similar definition of \defbeamertemplate{footline}{page number}
:
\defbeamertemplate{footline}{page number}
{%
\hfill%
\usebeamercolor[fg]{page number in head/foot}%
\usebeamerfont{page number in head/foot}%
\setbeamertemplate{page number in head/foot}[totalpagenumber]%
\strut\usebeamertemplate*{page number in head/foot}\kern1em\vskip1.4pt%
}
Just try it out :) And even if it would add a space (which is not the case), it would be swallowed by the \hfill
.
It is still "good practice to add % in such cases: as there may not always be an \hfill (or some other trick) to swallow it!
Description of the bug
When using
\setbeamertemplate{footline}[frame number]
(or\setbeamertemplate{footline}[page number]
), the vertical alignment of the frame numbers is not consistent, depending on the font. Consider the following example:When you look closely at the frame numbers, you'll see that the frame numbers on pages 3, 5, 6, 8, 9 and 10 are slightly shifted upwards.
This can happen with fonts where the digits do not all have the same height and depth. In Computer Modern Sans, all the digits do have the same height and depth, but this is not true for many other fonts.
Possible Fix
Do
\setbox\mybox=\hbox{0123456789}
, then define a command\mystrut
similar to\strut
, but with\vrule \@height\ht\mybox \@depth\dp\mybox \@width\z@
inside\strutbox
, and insert this command at an appropriate place, possibly inside the beamer templatepage number in head/foot
, like this:(Replace
\mybox
and\mystrut
with appropriate internal names, of course)