2

One MWE of many (w and w/o the plain frame option, w and w/o the vfill, w and w/o the c frame option etc.):

\documentclass[10pt]{beamer}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\begin{document}
\begin{frame}[c]{}
\vfill
\rule{\textwidth}{1pt}
\vfill
\end{frame}
\end{document}

This produces a horizontal line that is not exactly centered (using text instead does not work either). The ratio of the space above and below the line is approximately 4.5/5.5 in this case. Why?

PS: centering via TikZ as in question 208633 works fine.

stefanct
  • 841
  • 6
  • 16

2 Answers2

3

Addition to the answer of campa:

The same result as campa's third frame can also be achieved by a symmetrical definition of the frametopskip and framebottomskip:

\documentclass[10pt]{beamer}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}

\begin{document}

% from https://tex.stackexchange.com/a/354503/36296
\begin{frame}[c]{} % this works
\null\vfill\null
ace\rule[.5ex]{.5\textwidth}{.5pt}
\vfill
\end{frame}

\makeatletter
\define@key{beamerframe}{c}[true]{% centered
  \beamer@frametopskip=0pt plus 1fill\relax%
% \beamer@framebottomskip=0pt plus 1.5fill\relax%
  \beamer@framebottomskip=0pt plus 1fill\relax%
}
\makeatother
\begin{frame}[c]
aba\rule[.5ex]{.5\textwidth}{.5pt}abc
\end{frame}

\end{document}
2

This is only a half-cocked answer, as I do not know exactly the behaviour behind it. One (minor) issue is that \rule gives a line on the baseline, though this is not the real problem. Consider the following example

\documentclass[10pt]{beamer}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}

\begin{document}

\begin{frame}[c]{} % the problem
\vfill
ace\rule[.5ex]{.5\textwidth}{.5pt}
\vfill
\end{frame}

\begin{frame}[c]{} % slightly better
\null\vfill
ace\rule[.5ex]{.5\textwidth}{.5pt}
\vfill
\end{frame}

\begin{frame}[c]{} % this works
\null\vfill\null
ace\rule[.5ex]{.5\textwidth}{.5pt}
\vfill
\end{frame}

\end{document}

The first frame is the not centered one. From experience I knew that just calling \vfill somewhere may be give unexpected results (TeX modes) so I put en empty box at the beginning of the frame. This gives the second frame in the example above, which is slightly better but not yet really centered. To get what we want I had to put another empty box after the \vfill. And I must admit I'm quite befuddled as to why...

enter image description here

campa
  • 31,130