josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.41k stars 142 forks source link

Non-hacky way to configure topsep and itemsep #855

Open tobiasBora opened 1 year ago

tobiasBora commented 1 year ago

Unless I missed something, it is surprisingly difficult to configure in beamer the spacing in lists, as it is incompatible with the great enumitem package. Notably, to just remove the vertical space between the text and the list (usually called topsep), you need a crazy hack that basically redefines itemize https://tex.stackexchange.com/questions/115907/how-do-i-remove-white-space-above-itemize-command-in-beamer-using-enumitem Similarly, other hacks are needed to configure the \itemsep globally https://tex.stackexchange.com/questions/225736/latex-beamer-define-itemsep-globally

It would be great to propose a simple solution to these issues, to allow both local and global configuration of these parameters.

image

MWE

\documentclass{beamer}
\setbeamertemplate{itemize/enumerate body begin}{%
  \setlength{\leftmargini}{0em}% Adjusts the left horizontal margin between margin and text
  \setlength{\labelsep}{0mm}% Adjusts the space between bullet and text
}
\setbeamertemplate{itemize/enumerate subbody begin}{\setlength{\leftmarginii}{4cm}\setlength{\labelsep}{10mm}} % Adjust the left margin for nested lists
\setbeamertemplate{itemize/enumerate subsubbody begin}{\setlength{\leftmarginiii}{2em}} % Adjust the left margin for further nested lists
\setbeamertemplate{itemize item}[triangle] % Use a triangle bullet

\setbeamertemplate{itemize body item}{\setlength{\itemsep}{10cm}} % Adjust the space for nested lists

\begin{document}

\begin{frame}
  See that topsep does not work:
  \topsep100pt % does not work
  \setlength{\parsep}{0mm} %
  \begin{itemize}
    \setlength{\itemsep}{0mm} % important to be inside the itemize. to set it globally, see https://tex.stackexchange.com/questions/225736/latex-beamer-define-itemsep-globally
  \item We want no space between here and the next item
  \item Let us put instead lots of space for subitems
    \begin{itemize}
      \setlength{\itemsep}{10mm} % important to be inside the itemize. to set it globally, see https://tex.stackexchange.com/questions/225736/latex-beamer-define-itemsep-globally
    \item a
    \item b
    \end{itemize}
    \item Second item
  \end{itemize}
\end{frame}

\end{document}