LaTeX beamer: way to change the bullet indentation?
Asked Answered
E

5

60

I've checked the Beamer Class manual (PDF file).

I can't figure out how to change the indentation bullet assigns to \itemize.

[This is kind of important, as I'm using 2 column slides, and I don't want beamer to steal too much horizontal space].

Edelmiraedelson answered 9/4, 2010 at 22:10 Comment(0)
S
98

Beamer just delegates responsibility for managing layout of itemize environments back to the base LaTeX packages, so there's nothing funky you need to do in Beamer itself to alter the apperaance / layout of your lists.

Since Beamer redefines itemize, item, etc., the fully proper way to manipulate things like indentation is to redefine the Beamer templates. I get the impression that you're not looking to go that far, but if that's not the case, let me know and I'll elaborate.

There are at least three ways of accomplishing your goal from within your document, without mussing about with Beamer templates.

With itemize

In the following code snippet, you can change the value of \itemindent from 0em to whatever you please, including negative values. 0em is the default item indentation.

The advantage of this method is that the list is styled normally. The disadvantage is that Beamer's redefinition of itemize and \item means that the number of paramters that can be manipulated to change the list layout is limited. It can be very hard to get the spacing right with multi-line items.

\begin{itemize}
  \setlength{\itemindent}{0em}
  \item This is a normally-indented item.
\end{itemize}

With list

In the following code snippet, the second parameter to \list is the bullet to use, and the third parameter is a list of layout parameters to change. The \leftmargin parameter adjusts the indentation of the entire list item and all of its rows; \itemindent alters the indentation of subsequent lines.

The advantage of this method is that you have all of the flexibility of lists in non-Beamer LaTeX. The disadvantage is that you have to setup the bullet style (and other visual elements) manually (or identify the right command for the template you're using). Note that if you leave the second argument empty, no bullet will be displayed and you'll save some horizontal space.

\begin{list}{$\square$}{\leftmargin=1em \itemindent=0em}
  \item This item uses the margin and indentation provided above.
\end{list}

Defining a customlist environment

The shortcomings of the list solution can be ameliorated by defining a new customlist environment that basically redefines the itemize environment from Beamer but also incorporates the \leftmargin and \itemindent (etc.) parameters. Put the following in your preamble:

\makeatletter
\newenvironment{customlist}[2]{
  \ifnum\@itemdepth >2\relax\@toodeep\else
      \advance\@itemdepth\@ne%
      \beamer@computepref\@itemdepth%
      \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
      \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
      \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
      \begin{list}
        {
            \usebeamertemplate{itemize \beameritemnestingprefix item}
        }
        { \leftmargin=#1 \itemindent=#2
            \def\makelabel##1{%
              {%  
                  \hss\llap{{%
                    \usebeamerfont*{itemize \beameritemnestingprefix item}%
                        \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
              }%  
            }%  
        }
  \fi
}
{
  \end{list}
  \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body end}%
}
\makeatother

Now, to use an itemized list with custom indentation, you can use the following environment. The first argument is for \leftmargin and the second is for \itemindent. The default values are 2.5em and 0em respectively.

\begin{customlist}{2.5em}{0em}
   \item Any normal item can go here.
\end{customlist}

A custom bullet style can be incorporated into the customlist solution using the standard Beamer mechanism of \setbeamertemplate. (See the answers to this question on the TeX Stack Exchange for more information.)

Alternatively, the bullet style can just be modified directly within the environment, by replacing \usebeamertemplate{itemize \beameritemnestingprefix item} with whatever bullet style you'd like to use (e.g. $\square$).

Soapy answered 10/4, 2010 at 8:59 Comment(4)
From my understanding, the 2nd and the 3rd solution are the same, except that the 2nd solution allows you to set the style of the symbol used for an item. Can I somewhere in the 3rd solution define that symbol style? What I would like to do is create a custom list, define the symbol style for once, and then just operate with the other two parameters as suggested by you. Besides, upvoted this great answer.Flirtation
@Talik3233: I've updated my answer with two methods of modifying the bullet style.Soapy
This is great, thanks. I upvoted this long ago & have been back to it several times over the years. When nudging something by some number of units, you can use millimeters (mm) or points (pt); what kind of unit is em (i.e., [0em])?Retail
Am em is roughly the width of an uppercase M in the active font. See overleaf.com/learn/latex/Lengths_in_LaTeX and tex.stackexchange.com/a/8337 for more information.Soapy
G
23

I use the package enumitem. You may then set such margins when you declare your lists (enumerate, description, itemize):

\begin{itemize}[leftmargin=0cm]
    \item Foo
    \item Bar
\end{itemize}

Naturally, the package provides lots of other nice customizations for lists (use 'label=' to change the bullet, use 'itemsep=' to change the spacing between items, etc...)

Garnishment answered 10/4, 2010 at 12:44 Comment(3)
Unfortunately beamer redefined itemize, so that when you use enumitem you lose the bullet symbolsSeriate
enumitem would be ideal, but Beamer is too intrusive, so many of the settings fail to work.Perigynous
As @Seriate said, unfortunately beamer is not compatible with enumitemClarabelle
G
12

Setting \itemindent for a new itemize environment solves the problem:

\newenvironment{beameritemize}
{ \begin{itemize}
  \setlength{\itemsep}{1.5ex}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}   
  \addtolength{\itemindent}{-2em}  }
{ \end{itemize} } 
Garlaand answered 24/3, 2015 at 10:58 Comment(1)
This only decreases the indentation for the first line (at least in beamer). If an item contains more than one line of text, the following lines remain indented.Libration
B
3

To set the indentation globally, without using enumitem (which doesn't work on Beamer), put the following in your preamble:

\setlength{\leftmargini}{0.5cm}
\setlength{\leftmarginii}{0.5cm}

leftmargini and leftmarginii change the first and second list level, respectively.

This solution was given here.

Barometry answered 18/2, 2022 at 9:15 Comment(1)
This answer, and the reference, saved my life.Bernhardt
C
-1

Like Geoff's answer, I found a solution I like using enumitem. Set defaults with \setlist[⟨names⟩,⟨levels⟩]{⟨keys/values⟩} to inherit existing (theme?) attributes or \setlist*[⟨names⟩,⟨levels⟩]{⟨keys/values⟩} to fully reset. See the enumitem documentation.

The following sets indentation for the first four levels of nested lists as well as explicitly declares labels. The labels here defaults to bullets for itemized lists and arabic numbers for enumerated lists. It then resets the default labels for nested lists; long-hyphen for 2nd itemized, single hyphen for third itemized, etc. The last line resets default label for 2nd level itemized enumerated lists to be alphabetic (a, b, c).

\usepackage{enumitem}
\setlist[1]{leftmargin=0em}
\setlist[2]{leftmargin=2em} %list within a list
\setlist[3]{leftmargin=2.5em} %list within a list within a list
\setlist[4]{leftmargin=3em}
\setlist[itemize]{label=\textbullet}
\setlist[itemize,2]{label={--}}
\setlist[itemize,3]{label={-}}
\setlist[itemize,4]{label={\textperiodcentered}}
\setlist[enumerate]{label={\arabic*}}
\setlist[enumerate,2]{label={\alph*}}

With enumitem you can also declare a specific label or spacing for a particular instance by adding the options e.g. \begin{itemize}[label={*}] This is Geoff's answer.

Croce answered 13/4, 2021 at 19:17 Comment(3)
Don't use enumitem with beamer - that's a guarantee for troubleJaimeejaimes
@Jaimeejaimes why? You can reset the counter after slides I believe.Croce
You loose all the carefully done configurations of beamer themes, like the bullets matching the inner themes, the colours, the font size configurations of nested lists, ... But more importantly, enumitem is simply not compatible with a lot of beamer's patches to the list environments. Try default overlay specifications like \begin{itemize}[<+->] and enjoy the train wreckJaimeejaimes

© 2022 - 2024 — McMap. All rights reserved.