4

While making a poster, I've got two columns with blocks with itemize inside them. MWE:

\documentclass[final]{beamer}
\mode<presentation>{}

\usepackage{times}
\usepackage{amsmath,amssymb}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}

\begin{document}
\begin{frame}[t]{} 

%\leavevmode
\begin{columns}[t, onlytextwidth]
\begin{column}{.5\linewidth}
\begin{block}{Contributions}
\begin{itemize}
\item First Item
\item Second Item
\end{itemize}
\end{block}
\end{column}
\begin{column}{.5\linewidth}
\begin{block}{Approach}
\begin{itemize}
\item First Item
\item Second Item
\end{itemize}
\end{block}
\end{column}
\end{columns}

\end{frame}
\end{document}

My local installation and ShareLaTeX would misalign the bullets(baselines added by me): bug illustration

This problem seems similar to:

But this time it happens when itemize is inside the block. If one removes the blocks it works fine.

Am I missing something or does it look like a Beamer bug?

Thanks! I'm a LaTeX noob, sorry if I missed something stupid.

  • 3
    To work around this bug, you may add \vphantom{Ag} in each title of your blocks. – Paul Gaborit Oct 3 '16 at 23:55
  • That's a very mysterious workaround that just worked! Appending this after in the beamer theme after \insertblocktitle seems to have worked too. Thanks! I'll still submit this to beamer maintainers... – Vadim Kantorov Oct 4 '16 at 0:18
  • In your example, the depth of the first title is null (no letter as g or y...). \vphantom add a vertical phantom of its content. – Paul Gaborit Oct 4 '16 at 0:23
  • @PaulGaborit Would you like to write an answer? – samcarter_is_at_topanswers.xyz Oct 4 '16 at 10:08
  • Btw I put on a bug report at bitbucket.org/rivanvx/beamer/issues/339/… – Vadim Kantorov Oct 4 '16 at 12:22
2

In your example, the depth of the first title is null (no letter as g or y). To work around this feature (or "bug") of beamer, you may add \vphantom{Ag} in each title of your blocks (\vphantom adds a vertical phantom of its content).

\documentclass{beamer}
\usepackage{times}
\usepackage{amsmath,amssymb}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}

\begin{document}
\begin{frame}[t]{} 
  \begin{columns}[t, onlytextwidth]
    \begin{column}{.45\linewidth}
      \begin{block}{Contributions\vphantom{Ag}}
        \begin{itemize}
        \item First Item
        \item Second Item
        \end{itemize}
      \end{block}
    \end{column}
    \begin{column}{.45\linewidth}
      \begin{block}{Approach\vphantom{Ag}}
        \begin{itemize}
        \item First Item
        \item Second Item
        \end{itemize}
      \end{block}
    \end{column}
  \end{columns}
\end{frame}
\end{document}

Note: if you use onlytextwidth, the sum of the width of your columns should be lesser than \textwidth (to get a space between your columns).

| improve this answer | |
  • Thanks for this workaround, accepting it as an answer. Hope Beamer devs will check up on this. – Vadim Kantorov Oct 5 '16 at 20:02
1

In case one prefers a tighter vertical spacing, the following answer ignores the descending parts of the letters:

\documentclass{beamer}

\setbeamercolor{block title}{bg=red!30,fg=black}

\setbeamertemplate{block begin}
{
  \par\vskip\medskipamount%
  \begin{beamercolorbox}[colsep*=.75ex]{block title}
    \usebeamerfont*{block title}\strut\insertblocktitle\vskip-\dp\strutbox%
  \end{beamercolorbox}%
  {\parskip0pt\par}%
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
    \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}

\begin{document}

\begin{frame}
\begin{block}{This title has a problem}
    some text
\end{block}
\begin{block}{This title is about fine}
    some text
\end{block}
\end{frame}

\end{document}

enter image description here

| improve this answer | |
  • It it possible to achieve a vertically centered layout (considering only the baseline and cap height)? Assuming that \dp\strutbox is equivalent to 0.3\baselineskip, I think that something between 0.2\baselineskip and 0.25\baselineskip would look best, but unfortunately the result seems to depend on the font... – Jakub Klinkovský Jul 6 '17 at 15:48
  • @JakubKlinkovský Isn't this vertically centred? If I measure the space below and above the T are equal. – samcarter_is_at_topanswers.xyz Jul 6 '17 at 15:52
  • @JakubKlinkovský In any case, if you find \vskip-\dp\strutbox too much try with \vskip-.66\dp\strutbox or whatever you like. – samcarter_is_at_topanswers.xyz Jul 6 '17 at 15:54
  • In the posted image, there is 10px of red above the T, but only 8px below it. I think that I've already found the ideal dimension for the fonts in my current project, but obviously it would be great to have a solution guaranteed to not depend on any particular font. – Jakub Klinkovský Jul 6 '17 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.