6

I have a slide in the beamer package with an itemize environment where some items slightly are too wide to fit in one line (according to LaTeX' automatic line break system). This is the code:

\documentclass{beamer}
\begin{document}
\begin{frame}
  A polymorphism f is
  \begin{itemize}
    \item{\textbf{Malcev}, if $f(y,y,x) = f(x,y,y) = f(x,x,x) = x$}
    \item{\textbf{majority}, if $f(x,x,y) = f(x,y,x) = f(y,x,x) = f(x,x,x) = x$}
    \item{\textbf{sml}, if $f(x,x)=x, f(x,y)=f(y,x), f(f(x,y),z)=f(x,f(y,z))$}
    \item{\textbf{2sml}, if $f(x,x)=x, f(x,y)=f(y,x), f(f(x,y),x)=f(x,y)$}
  \end{itemize}
\end{frame}
\end{document}

Because I find it visually acceptable to put every item in just one line, I surrounded every item entry with \mbox to prevent line break:

    \item{\mbox{\textbf{majority}, if $f(x,x,y) = f(x,y,x) = f(y,x,x) = f(x,x,x) = x$}}

But what I got was this: useless line break

How do I work around this? My goal is to prevent the line break - it doesn't have to be with \mbox.

And as a secondary question, why is it behaving like that? I don't believe this is an intended behaviour...

  • \item \makebox[\linewidth][l]{\textbf{majority} ...} – egreg Sep 30 '15 at 15:25
4

TeX wants to avoid an overfull line, so it finds a possible line break before the \mbox; then it gives up, because it can't break the box.

Solution: if you are sure the text will fit in the slide, albeit sticking a bit out of the zone reserved for the text, use

\item \makebox[\linewidth][l]{\textbf{majority}, if $f(x,x,y) = f(x,y,x) = f(y,x,x) = f(x,x,x) = x$}

so the item text will not seen to be wider than the available space.

Example where one of the long items is put in a box and the other isn't, for comparison:

\documentclass{beamer}
\begin{document}

\begin{frame}
A polymorphism $f$ is
\begin{itemize}
\item \textbf{Malcev}, if $f(y,y,x) = f(x,y,y) = f(x,x,x) = x$
\item \makebox[\linewidth][l]{\textbf{majority}, if $f(x,x,y) = f(x,y,x) = f(y,x,x) = f(x,x,x) = x$}
\item \textbf{sml}, if $f(x,x)=x, f(x,y)=f(y,x), f(f(x,y),z)=f(x,f(y,z))$
\item \textbf{2sml}, if $f(x,x)=x, f(x,y)=f(y,x), f(f(x,y),x)=f(x,y)$
\end{itemize}

\end{frame}
\end{document}

enter image description here

Note that you don't need \item{...}, but just \item ...

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.