4

enter image description here

When using description, how can I adjust particular indent by given wordlength for every description?

Or to say, how can I get command such as \settowidth, \hangindent and \mbox to work under description?

【CODE】

\documentclass[12pt]{article}

\usepackage{amsmath,amssymb,amsthm,enumitem}

\usepackage{setspace}

\begin{document}

\begin{description}


\item [Short head] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.

\item [Head]Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.

\begin{spacing}{2}

\item [Long long long long head] Lorem ipsum dolor sit amet,    consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabiturdictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

\end{spacing}

\end{description}

\end{document}

1 Answer 1

3

Here's one option, as long as you're willing to use \item[<description>]{text} (I added \raggedright to the last item text just to prevent bad inter-word spacing in the narrow space):

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\usepackage{setspace}
\usepackage{varwidth}
\usepackage{letltxmacro}
\usepackage{linegoal}
\usepackage{etoolbox}

\LetLtxMacro\olditem\item
\AtBeginEnvironment{description}{
\renewcommand\item[2][]{
  \olditem[%
    {\begin{varwidth}[t]{\textwidth}#1\end{varwidth}}]%
    \begin{varwidth}[t]{\linegoal}#2\end{varwidth}%
  }
}

\begin{document}

\begin{description}[leftmargin=0pt]
\item[Short head]{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}

\item[Head]{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}

\begin{spacing}{2}

\item[Long long long long head]{\raggedright Lorem ipsum dolor sit amet,    consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabiturdictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.}

\end{spacing}

\end{description}

\end{document}

enter image description here

I don't really like this solution for two reasons: since the description is placed in an argument, verbatim material will be problematic and, most importantly, since descriptions are inside a box, they won't admit page breaks

1
  • @Howard You're welcome! I updated my answer to make sure thet the redefinition of \item affects only description. I thanks you for accepting the answer, but (just as a suggestion), perhaps you would wait a little longer in case a better answer pops-up? I mean an answer lifting the restriction to enclose the description in braces? Commented Sep 29, 2015 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .