# More on dealing with long description environment items in beamer

This is a follow-up question to Dealing with long description environment items

Gonzalo Medina was very helpfully resolving an issue I had with his solution to Dealing with long description environment items.

However, I still have a few issues with it, and want to avoid a lengthy discussion in comments. Hence this question. I believe any solution should be able to address all my issues simultaneously so I have not asked them separately.

• I don't quite understand how Gonzalo's solution works. In order to solve the Overfull \hbox issues I reported, he changed the length \beamer@descdefault. Now, this appears to solve that problem, but I don't understand why, and it also changes the left-alignment of the item labels.
• If possible, I'd personally favour the labels to always be aligned with the left margin.
• However, more importantly:

When the first entity inside a Ldescription \item body is another list environment, things go a bit wrong, as illustrated by the following example. The "bullet" in the first item in the sub-list is positioned on the wrong line (and causes an(other) Overfull \hbox).

Any suggestions on how to ensure that nested lists work okay would be gratefully received. However, I'd rather not have to define my own \item command if possible.

MWE:

\documentclass{beamer}
\usepackage{lipsum}

\makeatletter
\def\Ldescription{%
\@ifnextchar[{\beamer@testforospec}{\beamer@descdefault\beamer@descriptionwidth\@@Ldescription}%
}

\def\beamer@testforospec[{\@ifnextchar<{\beamer@scandefaultospec[}{\@Ldescription[}}%

\def\beamer@scandefaultospec[#1]{\def\beamer@defaultospec{#1}\Ldescription}

\def\@Ldescription[#1]{%
\setbox\beamer@tempbox=\hbox{\def\insertdescriptionitem{#1}
\usebeamertemplate**{description item}}%
\beamer@descdefault\wd\beamer@tempbox\@@description%
}%

\def\@@Ldescription{%
\beamer@descdefault35pt%
\list
{}
{\labelwidth\beamer@descdefault\leftmargin2.8em\let\makelabel\beamer@Ldescriptionitem}%
\beamer@cramped%
\raggedright
\beamer@firstlineitemizeunskip%
}

\def\endLdescription{\ifhmode\unskip\fi\endlist}
\long\def\beamer@Ldescriptionitem#1{%
\def\insertdescriptionitem{#1}%
\hspace\labelsep{\parbox[b]{\dimexpr\textwidth-\labelsep\relax}{%
\usebeamertemplate**{description item}%
}}}
\makeatother

\def\myLdescription{Ldescription}
%\def\myLdescription{description}%uncomment to compare with beamer's normal description environment

\overfullrule=1mm

\begin{document}

\begin{frame}
\noindent I live a very, very wild lifestyle.
\begin{\myLdescription}
\item[very very very very long item]
\begin{itemize}
\item description 1
\item[test] 1,2,3
\end{itemize}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.\par
Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque.
\begin{itemize}
\item description A
\item[test] x,y,z
\end{itemize}
\item[short item] description 2
\item[another very very very very long item] description 3
\item[i] description 4
\end{\myLdescription}
\end{frame}

\end{document}

-

• For the first and second issues: the idea with \beamer@descdefault is that it's value must be no less than the one for \leftmargin inside the list (otherwise overfull \hboxes will be produced). To get the labels aligned with the left margin, those two values (\leftmargin and \beamer@descdefault) must be equal; since \leftmargin is set to 2.8em, \beamer@descdefault must also be set to 2.8em (in the original answer I initially had set \beamer@descdefault to 30pt, which is slightly less than 2.8em and that was producing the overfull boxes).

• For the third issue: the idea behind the Ldescription environment is that labels will be on their own line (as width as possible, i.e., \textwidth-\labelsep) and the description text will be on a new line. Adding \leavevmode for the inner itemize produces the desired result; I used the etoolbox package to accomplish this.

The code:

\documentclass{beamer}
\usepackage{lipsum}
\usepackage{etoolbox}

\AtBeginEnvironment{itemize}{\leavevmode}
\makeatletter
\def\Ldescription{%
\@ifnextchar[{\beamer@testforospec}{\beamer@descdefault\beamer@descriptionwidth\@@Ldescription}%
}

\def\beamer@testforospec[{\@ifnextchar<{\beamer@scandefaultospec[}{\@Ldescription[}}%

\def\beamer@scandefaultospec[#1]{\def\beamer@defaultospec{#1}\Ldescription}

\def\@Ldescription[#1]{%
\setbox\beamer@tempbox=\hbox{\def\insertdescriptionitem{#1}
\usebeamertemplate**{description item}}%
\beamer@descdefault\wd\beamer@tempbox\@@description%
}%

\def\@@Ldescription{%
\beamer@descdefault2.8em%
\list
{}
{\labelwidth\beamer@descdefault\leftmargin2.8em\let\makelabel\beamer@Ldescriptionitem}%
\beamer@cramped%
\raggedright
\beamer@firstlineitemizeunskip%
}

\def\endLdescription{\ifhmode\unskip\fi\endlist}
\long\def\beamer@Ldescriptionitem#1{%
\def\insertdescriptionitem{#1}%
\hspace\labelsep{\parbox[b]{\dimexpr\textwidth-\labelsep\relax}{%
\usebeamertemplate**{description item}%
}}}
\makeatother

\def\myLdescription{Ldescription}
%\def\myLdescription{description}%uncomment to compare with beamer's normal description environment

\overfullrule=1mm

\begin{document}

\begin{frame}
\noindent I live a very, very wild lifestyle.
\begin{\myLdescription}
\item[very very very very long item]
\begin{itemize}
\item description 1
\item[test] 1,2,3
\end{itemize}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.\par
Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque.
\begin{itemize}
\item description A
\item[test] x,y,z
\end{itemize}
\item[short item] description 2
\item[another very very very very long item] description 3
\item[i] description 4
\end{\myLdescription}
\end{frame}

\end{document}


The output:

-
Thanks, I'll also use a \AtBeginEnvironment{enumerate}{\leavevmode} to take care of enumerate environments too, unless you know of a better way of affecting all lists (or more generally, all following entities)? –  cyberSingularity Oct 13 '12 at 11:47
@cyberSingularity yes, enumerate also needs to be taken care of, and no, I don't know a better way. –  Gonzalo Medina Oct 13 '12 at 17:24