[Tex/LaTex] Vertical space inserted before itemize environment at the top of a minipage in beamer

beameritemize

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.

Best Answer

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