5

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?

8

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

|improve this answer|||||
  • Works like a charm :) – Pranav M May 27 '13 at 5:18
  • Is there a way of doing this locally? Say I want to do this for one and only one list? – user1729 Feb 26 '14 at 12:49
  • @user1729 Sure. The redefinition can be made inside a group to keep its effect local. Comments are not the place to give code, so if you want to, feel free to open a nee question. – Gonzalo Medina Feb 26 '14 at 18:33
  • This does sadly not work for me. – Spen Sep 8 '19 at 13:47
0

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).

|improve this answer|||||
  • 5
    But it doesn't work with beamer – Pranav M May 27 '13 at 5:12

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.