4

See bottom for an updated MWE and more analysis after touhami's feedback.

The problem I'm seeing is that an itemize environment at the top of a beamer column (columns with [t] alignment) introduces a blank line. I was trying to align the lines of itemize in a column with the text lines in the other column, so I changed the relevant parameters (\topsep and \itemsep) modifiying some code from the beamer class. However, the issue is not caused by such modification; indeed, if I comment the lines in the preamble (see the MWE), the effect is still there. I keep them in the minimal example so that it is evident that the inserted vertical space corresponds to exactly one line. I can fix the vertical space by inserting \vspace{-\baselineskip} at the beginning of the column in every slide with this problem, but I would like to know if there is a way to fix it globally in a presentation.

Some comments:

  • If the columns aligment is changed to [T], the vertical space is reduced, but the lines in the two columns are no more aligned.
  • This only happens if the itemize environment is at the top of the column: if some text is added before the environment, no vertical space is inserted and the lines are aligned.
  • The order of the columns does not matter: the problem also appears if the itemize environment is in the first one.

A minimal working example:

\documentclass{beamer}

%%% These lines are a modified version of the code from the beamer 
%%% class (file beamerbaselocalstructure.sty). If they are commented
%%% out, the effect is still present\makeatletter
\makeatletter
\def\@listi{
  \leftmargin\leftmargini
  \topsep  0pt
  \parsep  0pt
  \itemsep 0pt
}
\let\@listI\@listi
\makeatother

\begin{document}
\begin{frame}
  % If this is changed to [T] the lines are not aligned
  \begin{columns}[t]
    \column{5cm}
    This is some text only to show the alignment (or the lack of it)
    between this column and the following one which starts with an
    itemize environment.
    \column{5cm}
    %%% This vertical space corresponds to normal a text line, but
    %%% only happens if the itemize environment is at the beginning of
    %%% the column: indeed if we uncomment the next line, the items do
    %%% not move.
    % Something
    %%% This is a manual workaround, but I'd prefer a global fix
    % \vspace{-\baselineskip}
    \begin{itemize}
    \item First
    \item Second
    \item Third
    \item Fourth
    \end{itemize}
  \end{columns}
\end{frame}
\end{document}

(Edit) In the case of T alignment, the problem can be solved by also setting \partopsep to zero, as suggested by Ignasi in his comment, but this does not work with t alignment. Then, looking at the difference between the two alignment options at the beginning of touhami's answer, I cannot see why the extra vertical space is inserted. It seem that it can be suppressed by \notinterlineskip, but why is it inserted in the first place?

(Update) The problem is present also when the itemize environment is at the top of a minipage (on which beamer columns are based). Therefore another MWE that shows the issue is the following:

\documentclass{beamer}

\makeatletter
\def\@listi{
  \leftmargin\leftmargini
  \topsep  0pt
  \parsep  0pt
  \itemsep 0pt
}
\let\@listI\@listi
\makeatother

\begin{document}
\begin{frame}
  \begin{minipage}[t]{3cm}
    This is a minipage with some text to show the issue.
  \end{minipage}
  \begin{minipage}[t]{5cm}
    Text in the top line.
    \begin{itemize}
    \item An item.
    \item A second item.
    \end{itemize}
  \end{minipage}
  \vspace{3ex}

  \begin{minipage}[t]{3cm}
    This is a minipage with some text to show the issue.
  \end{minipage}
  \begin{minipage}[t]{5cm}
    \begin{itemize}
    \item Item in the top line.
    \item A second item.
    \end{itemize}
  \end{minipage}
\end{frame}
\end{document}

Output of the MWE

As you can see, if there is a text line at the top of a minipage on the right (first case), the lines of the itemize environment are properly aligned with those in the left minipage. On the other hand, if the itemize environment is at the top of the minipage some vertical space is inserted. After some further investigations I came to the following conclusions:

  • The inserted vertical space is smaller that that in the first MWE, but it becomes the same if I add \leavevmode before \begin{itemize} (as in the definition of beamer column environment).
  • The issue is caused by the beamer class: if documentclass is changed to article (and the frame environment is removed) no vertical space is inserted.
  • However, the issue does not seem to be related to the redefinition of itemize environment by the beamer class. If I comment the code in lines 240-265 of beamerbaselocalstructure.sty in which \itemize and \enditemize are redefined, the beamer item markers disappear but the vertical space stays the same.
2
  • I think you also need \partopsep 0pt as Andrew Swann explains. I've tested with your code and it seems to work. – Ignasi Oct 1 '15 at 16:26
  • @ignasi It seems to me that it works, but only when the optional argument of columns environment is changed to T. I'd prefer a solution that works with t alignment because in my real-world case I'm using a custom environment with \begin{columns}[t] but, if nobody comes up with it, I'll try to see if I can change the definition of such environment. – LucaD Oct 1 '15 at 18:07
2
+50

Update (just a comment) as one can see from this code, the problem is not related to \column command (minipage is behind). It seems that the source of problem is \itemize (or deeper \list).

\documentclass{beamer}

\begin{document}
\begin{frame}
\begin{minipage}[t]{.48\textwidth}
These lines are a modified version of the code from the beamer 
 class (file beamerbaselocalstructure.sty). If they are commented
 out, the effect is still present
\end{minipage}
\hfill
\begin{minipage}[t]{.48\textwidth}%\vskip-1ex
%These lines are a modified versio
    \begin{itemize}
    \item First
    \item Second
    \item Third
    \item Fourth
    \end{itemize}
\end{minipage}
\end{frame}
\end{document}

Here is a solution. By default

\define@key{beamer@col}{t}[true]{\def\beamer@colmode{t}\def\beamer@colalign{t}\def\beamer@colheadskip{}}
\define@key{beamer@col}{T}[true]{\def\beamer@colmode{T}\def\beamer@colalign{t}\def\beamer@colheadskip{\vskip-1ex\nointerlineskip}} 

so one can try

\define@key{beamer@col}{t}[true]{\def\beamer@colmode{t}\def\beamer@colalign{t}\def\beamer@colheadskip{\vskip-1ex\nointerlineskip}}

MWE

\documentclass{beamer}

%%% These lines are a modified version of the code from the beamer 
%%% class (file beamerbaselocalstructure.sty). If they are commented
%%% out, the effect is still present\makeatletter
\makeatletter
\define@key{beamer@col}{t}[true]{\def\beamer@colmode{t}\def\beamer@colalign{t}\def\beamer@colheadskip{\vskip-1ex\nointerlineskip}}
\def\@listi{
  \leftmargin\leftmargini
  \topsep  0pt
  \parsep  0pt
  \itemsep 0pt
}
\let\@listI\@listi
\makeatother

\begin{document}
\begin{frame}
  % If this is changed to [T] the lines are not aligned
  \begin{columns}[t]
    \column{5cm}
    This is some text only to show the alignment (or the lack of it)
    between this column and the following one which starts with an
    itemize environment.
    \column{5cm}
    % This vertical space corresponds to normal a text line, but
    %%% only happens if the itemize environment is at the beginning of
    %%% the column: indeed if we uncomment the next line, the items do
    %%% not move.
    % Something
    %%% This is a manual workaround, but I'd prefer a global fix
    % \vspace{-\baselineskip}
    \begin{itemize}
    \item First
    \item Second
    \item Third
    \item Fourth
    \end{itemize}
  \end{columns}
\end{frame}
\end{document}

enter image description here


enter image description here

6
  • With your solution one would have also to add the line suggested in Ignasi comment: as you can see in the first picture, the lines of the second column are not aligned with those of the first one. If I understand correctly, the point of this solution is to make t alignment behave like T: is it so? In that case i could more easily change t to T: the problem would be to check the effect in the rest of the presentation. – LucaD Oct 11 '15 at 13:22
  • @LucaD you're right. You can see texdoc.net/texmf-dist/doc/latex/beamer/doc/… – touhami Oct 11 '15 at 17:07
  • @LucaD answer updated a comment added. – touhami Oct 12 '15 at 8:55
  • Thank you! Thanks to your feedback I've updated the MWE in the question and added some further analysis. – LucaD Oct 12 '15 at 15:03
  • I'm not marking the answer as accepted because it does not fully solve the issue, but I'm assigning the bounty because it helped me to better understand the problem. – LucaD Oct 16 '15 at 18:26

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.