Here's the default functionality for description
items:
With this code
\begin{description}
\item Lorem ipsum...
\end{description}
Is there any way to make this flush all along the left side with no automatic indentation?
descriptionindentationlists
Here's the default functionality for description
items:
With this code
\begin{description}
\item Lorem ipsum...
\end{description}
Is there any way to make this flush all along the left side with no automatic indentation?
Here's a solution which allows you to just write
\begin{DESCRIPTION}
\item[Label the first] Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
\item[The longest label] Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo
consequat.
\item[Shrtlbl] Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
\end{DESCRIPTION}
and obtain
It works with arbitrary text inside the {DESCRIPTION}
and can be nested with other lists.
\documentclass{article}
\usepackage{calc}
\makeatletter
\newcommand{\DESCRIPTION@original@item}{}
\let\DESCRIPTION@original@item\item
\newcommand*{\DESCRIPTION@envir}{DESCRIPTION}
\newlength{\DESCRIPTION@totalleftmargin}
\newlength{\DESCRIPTION@linewidth}
\newcommand{\DESCRIPTION@makelabel}[1]{\llap{#1}}%
\newcommand{\DESCRIPTION@item}[1][]{%
\setlength{\@totalleftmargin}%
{\DESCRIPTION@totalleftmargin+\widthof{\textbf{#1 }}-\leftmargin}%
\setlength{\linewidth}
{\DESCRIPTION@linewidth-\widthof{\textbf{#1 }}+\leftmargin}%
\par\parshape \@ne \@totalleftmargin \linewidth
\DESCRIPTION@original@item[\textbf{#1}]%
}
\newenvironment{DESCRIPTION}
{\list{}{\setlength{\labelwidth}{0cm}%
\let\makelabel\DESCRIPTION@makelabel}%
\setlength{\DESCRIPTION@totalleftmargin}{\@totalleftmargin}%
\setlength{\DESCRIPTION@linewidth}{\linewidth}%
\renewcommand{\item}{\ifx\@currenvir\DESCRIPTION@envir
\expandafter\DESCRIPTION@item
\else
\expandafter\DESCRIPTION@original@item
\fi}}
{\endlist}
\makeatother
\begin{document}
\begin{DESCRIPTION}
\item[Label the first] Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
\item[The longest label] Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo
consequat.
\item[Shrtlbl] Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
\end{DESCRIPTION}
\end{document}
The code work by resetting the relevant list settings at each \item
instead of just at the start of the list.
Using the enumitem
package with beamer
is not a good idea; for example, just by loading enumitem
, the default beamer font and color specifications for description
are lost; moreover \setbeamercolor
and \setbeamerfont
will have no effect on description item
; even worst, the enumitem package will also interfere with the beamer
layout for itemize
and enumerate
; in fact, it will produce errors for the enumerate
environment (See example at the bottom).
In the following example I defined a Ldescription
environment based on the beamer definition of standard description
; since the new definition follows the "beamer way", it will behave as expected (it's overaly aware, for exampe, and respects the color and font templates) and will give you the desired layout (feel free to adjust the lengths according to your needs):
\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
\begin{document}
\begin{frame}
\begin{Ldescription}
\item<1->[very very very very long item] \lipsum[2]
\item<2,4>[short titem] description 2
\item<3->[another very very very very long item] description 3
\item<4->[short item] description 4
\end{Ldescription}
\end{frame}
\end{document}
An image of the fourth frame:
Processing the following code:
\documentclass{beamer}
%\usepackage{enumitem}
\setbeamercolor{description item}{fg=olive!80!black}
\setbeamerfont{description item}{size=\footnotesize}
\begin{document}
\begin{frame}
\begin{description}
\item[item] description
\end{description}
\begin{itemize}
\item description
\end{itemize}
\end{frame}
\end{document}
produces the following (expected) output:
Now uncomment-out the line loading enumitem
. reprocess and now you'll get the following undesired result:
Now, try this simple document:
\documentclass{beamer}
\usepackage{enumitem}
\begin{document}
\begin{frame}
\begin{enumerate}
\item test
\end{enumerate}
\end{frame}
\end{document}
and you'll receive:
! TeX capacity exceeded, sorry [grouping levels=255].
\labelenumi ->{
\labelenumi }
l.10 \end{frame}
! ==> Fatal error occurred, no output PDF file produced!
The moral is clear: enumitem
and beamer
a are incompatible. Perhaps using the loadonly
package option to create own lists could be safe:
\usepackage[loadonly]{enumitem}
Best Answer
If you load the
enumitem
package then you can tweak this option (and many others) using akey=value
approach.In your particular case, you can use
If you want to assign this behaviour globally, you can use
A complete MWE follows
See the documentation for further details:
texdoc enumitem