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.

I would like to justify text inside an itemize environment with the beamer class. Text appears to be justified by default with the article class, but not with the beamer class.

The following code justifies text left and right:

    \documentclass{article}
    \usepackage{lipsum}
    \begin{document}
    \begin{itemize}
    \item \lipsum[1-1]
    \end{itemize}
    \end{document}

The following code does not:

    \documentclass{beamer}
    \usepackage{lipsum}
    \begin{document}
    \begin{frame}
    \begin{itemize}
    \item \lipsum[1-1]
    \end{itemize}
    \end{frame}
    \end{document}

I have tried this:

    \documentclass{beamer}
    \usepackage{ragged2e}
    \usepackage{lipsum}
    \let\olditemize=\itemize 
    \renewenvironment{itemize}{\olditemize\justify}{\endlist} 
    \begin{document}
    \begin{frame}
    \begin{itemize}
    \item \lipsum[1-1]
    \end{itemize}
    \end{frame}
    \end{document}

but it won't justify text on the right. Any suggestions welcome!

share|improve this question
1  
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. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). –  Gonzalo Medina Apr 5 '12 at 13:27
1  
See How do you accept an answer? how to go about making a decision on the answer that helped you most. –  Werner Apr 7 '12 at 3:29
add comment

2 Answers

up vote 8 down vote accepted

beamer has its own ways and, in particular, it redefines many standard LaTeX environments/commands; in particular, it redefines the basic list-like environments itemize, enumerate and description.

Here's, for example, the definition of \itemize as given in beamerbaselocalstructure.sty:

\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%
  \beamer@cramped%
  \raggedright% 
  \beamer@firstlineitemizeunskip%
}

as you can see, \itemize internally uses \raggedright. The best approach to keep things overlay specification-aware is to redefine \itemize to use \justifying (from the ragged2e package) instead; the following code shows this redefinition in an actual document:

\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{lipsum}

\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%
  \beamer@cramped%
  \justifying% NEW
  %\raggedright% ORIGINAL
  \beamer@firstlineitemizeunskip%
}
\makeatother

\begin{document}

\begin{frame}
\begin{itemize}
\item<1->\lipsum[2]
\item<2>\lipsum[2]
\end{itemize}
\end{frame}

\end{document}

The output:

enter image description here

As a final note, I would suggest you to consider if this redefinition is really needed at all; frames with too much text (like the one I just build for the example) are to be avoided in a presentation.

share|improve this answer
    
Thanks Gonzalo, Thanks Ian, that does it! I just want to answer your question Gonzalo, the reason for wanting to have text justified within a beamer document is that I alternate frames designed for presentation and slides designed for the handout version (tagging with "beamer" or "handout"). I typeset some of the "handout" frames as plain text for reading, for instance writing out page-length proofs or long explanations. There may be a better way to do this, but I've found it to be easy to do this way. –  PatrickT Apr 5 '12 at 11:02
    
Gonzalo, I have no option to select an answer, no option to write in comments either. I suspect the problem is related to this: I asked the question without registering, by simply entering my email. I then decided to register, as suggested by the site, but my email was rejected as "being in use", but it wasn't since I was immediately asked to register again. After a few back-and-forth I registered with another email. Bottom line: I can't do much right now except add an answer... Sorry about the mess. I would like to select your answer Gonzalo. Thanks a lot. –  PatrickT Apr 6 '12 at 20:54
1  
@PatrickT: I've flagged your (now deleted) answer for Moderatos attention, asking them if there's something they can do to help you with your accounts. Anyway, thanks for your comment. –  Gonzalo Medina Apr 7 '12 at 3:51
add comment

Try this.

\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{lipsum}
\let\olditem\item
\renewcommand\item{\olditem\justifying}
\begin{document}
\begin{frame}
\begin{itemize}
\item \lipsum[1-1]
\end{itemize}
\end{frame}
\end{document}
share|improve this answer
1  
But now \item is no longer overlay specification-aware. –  Gonzalo Medina Mar 29 '12 at 21:13
add comment

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.