Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to set space between each items to 2ex, between subitems to 1ex, between an item and its subitem to 1ex, between a subitem and the next item to 2ex?

I've tried to proceed this way:

\documentclass{beamer}
\makeatletter
\def\@listii{\leftmargin\leftmarginii
              \topsep    1ex
              \parsep    0\p@   \@plus\p@
              \itemsep   \parsep}
\makeatother
\begin{document}
    \begin{frame}
        \begin{itemize}
            \item Here are two interesting things:
            \begin{itemize}
                \item Here are two interesting things:
                \item Here are two interesting things:
            \end{itemize}
                \item Here are two interesting things:
                \item Here are two interesting things:
        \end{itemize}
    \end{frame}
\end{document}

Thanks in advance!

share|improve this question
    
enumitem package could help. –  Manuel May 13 at 15:36
    
@Manuel unfortunately, the enumitem package and beamer don't cooperate well. –  Gonzalo Medina May 13 at 16:01
    
@GonzaloMedina I supposed so, but I tried :P –  Manuel May 13 at 16:49

1 Answer 1

up vote 6 down vote accepted

One option redefining \itemize (as defined in beamerbaselocalstructure.sty) to conditionally set \itemsep based on the value of \@itemdepth (the new code is signaled by % start change, % end change):

\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}}
  {\def\makelabel##1{%
  {%
\hss\llap{{%
\usebeamerfont*{itemize \beameritemnestingprefix item}%
\usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
  }%
}%
% start change
\ifnum\@itemdepth=1\relax
\setlength\itemsep{2ex}
\else
\ifnum\@itemdepth=2\relax
\setlength\itemsep{1ex}
\fi\fi%
% end change
  }
  \fi%
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}
\makeatother

\begin{document}

\begin{frame}
\begin{itemize}
\item Here are two interesting things:
  \begin{itemize}
  \item Here are two interesting things:
  \item Here are two interesting things:
  \item Here are two interesting things:
  \end{itemize}
\item Here are two interesting things:
\item Here are two interesting things:
\end{itemize}
\end{frame}

\end{document}

enter image description here

With the help of xpatch we can patch \itemize and the code simplifies a little:

\documentclass{beamer}
\usepackage{xpatch}

\xpatchcmd{\itemize}
  {\def\makelabel}
  {\ifnum\@itemdepth=1\relax
     \setlength\itemsep{2ex}
   \else
     \ifnum\@itemdepth=2\relax
   \setlength\itemsep{1ex}
   \fi\fi\def\makelabel
  }
 {}
 {}

\begin{document}

\begin{frame}
\begin{itemize}
\item Here are two interesting things:
  \begin{itemize}
  \item Here are two interesting things:
  \item Here are two interesting things:
  \item Here are two interesting things:
  \end{itemize}
\item Here are two interesting things:
\item Here are two interesting things:
\end{itemize}
\end{frame}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.