[Tex/LaTex] Beamer: Vertically stretching level-1 list items in a nested list environment

beameritemizelistsspacing

I use \setlength\itemsep{\fill} to vertically stretch items in an itemize environment. This works fine if I don't have a sub-list:

enter image description here

However, if there is a sub-list, the item following the sub-list would not be stretched. As you can see in the screenshot below, the space between the first two level-1 items is smaller than the space between the last two.

enter image description here

Question

How do I fix this issue in a way that does not require setting a fixed length for \itemsep (e.g. 10pt) or manually adding \vfill before every level-1 \item?

MWE

\documentclass{beamer}
\begin{document}
\begin{frame}{Title}
  \begin{itemize}
    \setlength\itemsep{\fill}
    \item item 
    \begin{itemize}
      \item subitem 
    \end{itemize}
    \item item
    \item item
  \end{itemize}
\end{frame}
\end{document}

Best Answer

To stretch the list over the whole space I see two problems:

  • To automatically set \setlength\itemsep{\fill} for all itemizations, it can be added to the definition of \itemize

  • To add the same space between the items from the parent list and the sublist, one can use

    \ifnum \@itemdepth >1
        \vfill
    \fi%
    

    at the beginning and end of this sublist.


\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}}%
          }%
        }%
      }
  \fi%
  \setlength\itemsep{\fill}
    \ifnum \@itemdepth >1
        \vfill
    \fi%  
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}

\def\enditemize{\ifhmode\unskip\fi\endlist%
  \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body end}
  \ifnum \@itemdepth >1
        \vfil
  \fi%  
  }
\makeatother

\begin{document}
\begin{frame}{Title}
  \begin{itemize}
    \item item 
    \begin{itemize}
      \item subitem 
      \item subitem 
    \end{itemize}
    \item item
    \item item
  \end{itemize}
\end{frame}
\end{document}

enter image description here