9

I am new to \LaTeX. I am trying to use solution give on How to remove the whitespace BEFORE itemize/enumerate? to remove vertical space before itemize environment using enumitem and beamer. But I don't get the desired result. Is there a solution to this problem?

  • 2
    Welcome to TeX.SX! You may have a look on our starter guide. Maybe this will help: http://tex.stackexchange.com/questions/114280/how-to-reduce-vertical-space-itemize-environment-inside-table – Mario S. E. May 24 '13 at 09:43
  • In my case (beamer with some customization) I also needed in Gonzalo Medina's answer: \setlength\parskip{0pt} (I don't have enough rep to comment.) – gordon Aug 15 '23 at 14:24

2 Answers2

14

It's not a good idea to use the enumitem package with beamer since beamer has its own ways of dealing with the standard list-like environments. Just by loading enumitem when using beamer you loose the special beamer formatting and the overlay-awareness of the list-like components.

To suppress the spacing, you can redefine itemize as implemented by beamer in the file beamerbaselocalstructure.sty. In the following example I show a possible modification, setting \topsep, \partopsep and \itemsep to 0pt (adjust these values according to your needs); the modified lines are signaled with %NEW:

\documentclass{beamer}

\makeatletter
\renewcommand{\itemize}[1][]{%
  \beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
  \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
      {\usebeamertemplate{itemize \beameritemnestingprefix item}}
      {%
        \setlength\topsep{0pt}%NEW
        \setlength\partopsep{0pt}%NEW
        \setlength\itemsep{0pt}%NEW
        \def\makelabel##1{%
          {%
            \hss\llap{{%
                \usebeamerfont*{itemize \beameritemnestingprefix item}%
                \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
          }%
        }%
      }
  \fi%
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}
\makeatother

\begin{document}

\begin{frame}
Some text
\begin{itemize}
\setlength\topsep{0pt}
\setlength\partopsep{0pt}
  \item Item 1
  \item Item 2
  \item Item 3
\end{itemize}
Some text
\end{frame}

\end{document}

enter image description here

Just for comparison, the same list without the modifications:

enter image description here

Gonzalo Medina
  • 505,128
-2

As described in the enumitem documentation, you have two parameters to play with regarding vertical top space: topsep and partopsep.

So, for example, writing this:

\begin{enumerate}[topsep={0pt},partopsep={0pt}]
\item First item
\item Second item
\end{enumerate}

Will produce something like this:

enter image description here

Of course, if you want to play with the separation between items, you can do so by setting itemsep, again, as described in the enumitem documentation (available at the link mentioned above).

Mario S. E.
  • 18,609