6

I know that I can suppress indentation bullets using \item[], but nonetheless, the vertical space taken up by the bullet still stays empty. I thought of using a custom list environment, but this did neither adjust the space nor the font size. Arrows mark some of the questionable spots in the following example.

\documentclass{beamer}
\begin{document}
\begin{frame}
  \begin{itemize}
    \item A sub-itemize
      \begin{itemize}
        \item an item with a bullet
        \item[] items without a bullet waste space
        \item[] \(\leftarrow\) here
      \end{itemize}
    \item A sub-list
      \begin{list}{}{}
        \item these items are too big
        \item the sublist font should be smaller
        \item[] \(\leftarrow\) still too much space
      \end{list}
  \end{itemize}
\end{frame}
\end{document}

too much space

How can I close the gap? Or, alternatively, how can a new environment be created, that works like itemize but only adds an indent and decreases the font size without adding any bullets?

  • You want an itemized list with some items that have bullets and some that don't? And those that don't, you want them to have less of an indent? Or do you want an entire (sub-) list to not have any bullets and less of an indent? – Werner Nov 23 '13 at 1:27
  • I mostly aim to place code examples below some of my bullet points. They may even be mixed with common text items. So both cases would be useful. – XZS Nov 23 '13 at 14:19
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – jub0bs Dec 8 '13 at 18:54
8

If you want a list of bullets but have some of the un-bulleted items not indented as far as the regular ones, you need to manually push them back using a negative indent. If you want an entire list to not have bullets and not have as big an indent, then you can set the appropriate beamer template for that (possibly nested) list, as well as the list margin.

Here's an example:

enter image description here

\documentclass{beamer}% http://ctan.org/pkg/beamer
\let\Tiny\tiny% http://tex.stackexchange.com/q/58087/5764
\begin{document}
\begin{frame}
  \begin{itemize}
    \item A sub-itemize
      \begin{itemize}
        \item an item with a bullet
        \item[] items without a bullet waste space
        \item[] \hspace*{-1em}\(\leftarrow\) here
      \end{itemize}
    \item A sub-list
      \begin{list}{}{}
        \item these items are too big
        \item the sublist font should be smaller
        \item[] \(\leftarrow\) still too much space
      \end{list}
  \end{itemize}

  \setbeamertemplate{itemize subitem}{}% Remove bullets frp, ote,oze sinote,
  \setlength\leftmarginii{0.5em}% Left margin of subitems

  \begin{itemize}
    \item A sub-itemize
    \begin{itemize}
      \item an item with a bullet
      \item items without a bullet waste space
      \item \(\leftarrow\) here
    \end{itemize}
  \end{itemize}
\end{frame}

\end{document}

For the third subitem, a negative \hspace{-1em} pushes the content back by 1em. The final list has a itemize subitem template set to nothing (meaning the bullets will not appear), but also the left margin is set to 0.5em, making the items appear with less of an indent.

The default intent for the respective nested lists are 2em each (with a \labelsep of .5em). The following detail is taken from beamerbaselocalstructure.sty:

%
% List stuff
%

\setlength\leftmargini  {2em}
\setlength\leftmarginii  {2em}
\setlength\leftmarginiii  {2em}
\setlength  \labelsep  {.5em}
\setlength  \labelwidth{\leftmargini}
\addtolength\labelwidth{-\labelsep}
  • Both solutions work magnificently fine for plain text and math. But when I replace \(\leftarrow\) here with a more complex environment, for example \begin{lstlisting}printf('Hello World!');\end{lstlisting} it inserts an ugly linebreak. So I prefer your second solution, which does not have this drawback. I would like to make it into a \newenvironment. Perhaps you can give me a hint how to make it work independent of the current itemization depth? – XZS Nov 23 '13 at 14:11
  • @XZS: Anything related to a customization of environments in listings require the \lstnewenvironment rather than a regular \newenvironment. See section 4.6 Environments (p 41) of the listings documentation. – Werner Nov 23 '13 at 18:18
  • It is section 4.16 on the mentioned page. But instead of listings, the problem I am faced with is choosing the right one of \leftmargini, \leftmarginii and \leftmarginiii according to the current nesting depth. In my answer I compiled from your directions, I simply set all three. Perhaps you know how to only set the right one. – XZS Nov 24 '13 at 14:04
  • 1
    @XZS: Try \setlength{\csname leftmargin\romannumeral\@itemdepth\endcsname}{.5em}. – Werner Nov 24 '13 at 14:25
0

I took the definition of the itemize environment and modified it to my liking.

The incorporated \list avoids creating any bullet at all with an empty first parameter and the current margin is set to a fixed width.

\documentclass{beamer}
\makeatletter
% This is itemize, stolen from beamer/base/beamerbaselocalstructure.sty
% but stripped from the bullets and their indentation.
\newcommand{\sub}[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}%
    \setlength{\csname leftmargin\romannumeral\@itemdepth\endcsname}{.5em}%
    \list{}%
      {\def\makelabel##1{%
          {%
            \hss\llap{{%
                \usebeamerfont*{itemize \beameritemnestingprefix item}%
                \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
          }%
        }%
      }
  \fi%
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}
\def\endsub{\enditemize} % recycle identical itemize end.
\makeatother


\begin{document}
\begin{frame}
  \begin{itemize}
    \item A sub-itemize
      \begin{itemize}
        \item an item with a bullet
        \item[] items without a bullet waste space
        \item[] \(\leftarrow\) here
      \end{itemize}
    \item A custom sublist
      \begin{sub}
        \item these items work like sub-itemize
        \item but they waste no space
        \item \(\leftarrow\) here
          \begin{sub}
            \item they even work when nested
          \end{sub}
      \end{sub}
  \end{itemize}
\end{frame}
\end{document}

a custom list solution

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.