1

I want to set (now wrong) description environment indents the same as (already correct) enumerate environment indents.

Note that I already use \usepackage{enumitem}.

How?

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}
  \item a.
  \item b.
\end{enumerate}

\begin{description}
  \item[1.] a.
  \item[2.] b.
\end{description}

\end{document}

The indents of two lists are different. I want to change description indent to become the same as enumerate indent.

ADDENDUM

I experimented with the below amsbook LaTeX file. In some reason, the indent of enumerate and description has not become the same as I desire. Please help me to find my error.

\documentclass{amsbook}
\usepackage{enumitem}

\setlist[enumerate,1]{leftmargin=1.7em,labelindent=*}
\setlist[description,1]{leftmargin=1.7em,labelindent=*}

\begin{document}

\begin{enumerate}
  \item a.
  \item b.
\end{enumerate}

\begin{description}
  \item[1.] a.
  \item[2.] b.
\end{description}

\end{document}

ADDENDUM 2

By @Harish Kumar recommendation, I've also tried the following. The result is not ideal, enumerate and description do not have the same left margin.

\documentclass{amsbook}
\usepackage{enumitem}

\renewcommand{\descriptionlabel}[1]{%
%   \hspace\labelsep \upshape #1.%
  \upshape #1.%
}
\setlist[enumerate,1]{leftmargin=2em,labelindent=*,label=\arabic*$^\circ$.,
ref=\arabic*$^\circ$} 
\setlist[description,1]{leftmargin=1em,labelindent=*}

\begin{document}

\begin{enumerate}
  \item \label{a} a.
  \item \label{b} b.
\end{enumerate}

\begin{description}
  \item[\ref{a}] a.
  \item[\ref{b}] b.
\end{description}

\end{document}
1
+50

The request being made is not at all clear: if one just wants to typeset the labels of a description environment as if they were part of an enumerate environment, why should one use description at all? Evidently, the question lacks some essential information. A possible interpretation is that what is actually wanted here is to typeset a regular description-style label with a number sticking in the margin, with an alignment similar to that of the labels of enumerate. The following example clarifies what I mean.

\documentclass[a4paper]{amsbook}
\usepackage[T1]{fontenc}
\usepackage{enumitem} % actually redundant, in this example

\newenvironment*{descriptionThatMimicksItemize}{%
  \list{}{\let\makelabel\descriptionTMIlabel}%
}{\endlist}
\newcommand*{\descriptionTMIlabel}[1]{\hss\llap{\upshape #1}}
\makeatletter
  \@ifdefinable\origLabelWidth{\newdimen\origLabelWidth}
  \@ifdefinable\origLabelSep  {\newdimen\origLabelSep}
\makeatother
\newcommand*{\myNumericLabel}[1]{%
  \makebox[\origLabelWidth][r]{#1}\hspace{\origLabelSep}%
}

\begin{document}

\origLabelWidth = \labelwidth
\origLabelSep   = \labelsep
% This is an over-simplification, but for now we can accept it.

The \texttt{enumerate} environment:
\begin{enumerate}
  \item \label{a}
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
  \item \label{b}
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
\end{enumerate}

The first solution:
\begin{descriptionThatMimicksItemize}
  \item[(\ref{a}) Is it this what you want?]
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
  \item[(\ref{b}) I wouldn't say so.]
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
\end{descriptionThatMimicksItemize}

The second one:
\begin{description}
  \item[\myNumericLabel{(\ref{a})}I'd rather say it's this]
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
  \item[\myNumericLabel{(\ref{b})}A label is needed, though]
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
\end{description}

\end{document}

Output: Output produced

If this is the real issue, it involves splitting the supplied label in two components, and therefore goes beyond the mere problem of setting the margins and the label width.

In conlusion, I think that it is impossible to fully answer this question until it is made clear what the precise request is.

Addition

I'm beginning to wonder whether it couldn’t be simply this what is actually wanted:

\documentclass[a4paper]{amsbook} % or whatever
\usepackage[T1]{fontenc}
\usepackage{hyperref}

\begin{document}

Let \( f\colon A\to B \) be a function.  The following are equivalent:
\begin{enumerate}
  \item\label{a}  $f$ is both injective and surjective;
  \item\label{b}  $f$ is invertible.
\end{enumerate}
Proof:
\begin{enumerate}
  \item[$\ref{a}\Rightarrow\ref{b}$:]
    Pick an element \( b\in B \), and let \( a\in A \) be the unique element 
    that is sent into~$b$ by~$f$\ldots
  \item[$\ref{b}\Rightarrow\ref{a}$:]
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
\end{enumerate}

\end{document}

Output: Output of addede code

Of course, the hyperlins work as expected.

But indeed, this wouldn’t be worth a bounty…

Second Addition

Yet another possibility:

\documentclass[a4paper]{amsbook} % or whatever
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage{hyperref}

\setlist[enumerate,1]
  {align=left, labelindent=.5em, labelwidth=1.5em}

\begin{document}

Let \( f\colon A\to B \) be a function.  The following are equivalent:
\begin{enumerate}
  \item\label{a}  $f$ is both injective and surjective;
  \item\label{b}  $f$ is invertible.
\end{enumerate}
Proof:
\begin{enumerate}
  \item[$\mbox{(\ref{a})}\Rightarrow\mbox{(\ref{b})}$:]
    Pick an element \( b\in B \), and let \( a\in A \) be the unique element 
    that is sent into~$b$ by~$f$\ldots
  \item[$\mbox{(\ref{a})}\Rightarrow\mbox{(\ref{b})}$:]
    Lorem ipsum dolor sit amet consectetur adipisci elit iam 
    fugiaet enim duscula.  Reprivit ursula tum donec.
\end{enumerate}

\end{document}

And here is the output #3: Output of third sample code

  • I sometimes want a list which looks like enumerate, but differs in two things: 1. the items may be not in order (for example in order 2,3,1, not 1,2,3); 2. I prefer if the labels are hyperlinks. This can be done with description list with \ref commands. Otherwise this list should look exactly as an enumerate. Note that I use LyX and defining new list types may be a trouble for me, so I use existing list type "description". – porton May 17 '15 at 18:02
  • I've compiled it. Now I see it is not what I want: The labels in the first enumerate and the second enumerate look differently, the indents are different. I need both list to look the same. – porton May 17 '15 at 19:20
  • @porton: Added image for the output I get. If you want the labels to be aligned on their left edge, instead, load the enumitem package and specify \begin{enumerate}[align=left]. It looks awful, anyway, IMHO. – GuM May 17 '15 at 19:45
  • No, it is not what I need. I probably cannot edit titles of items of enumerate with LyX. Maybe, I should switch to plain LaTeX to solve this problem :-( – porton May 17 '15 at 21:01
  • Sorry, I'm not going to make any further trial, since I really cannot understand what you are looking for and what goes wrong with the code I’ve posted. – GuM May 17 '15 at 21:25
1
\documentclass{article}
\usepackage{enumitem,showframe}

\begin{document}

\begin{enumerate}
  \item a.
  \item b.
\end{enumerate}

\begin{description}[leftmargin=1.7em,labelindent=*,before={\renewcommand\makelabel[1]{##1}}]
  \item[1.] a.
  \item[2.] b.
\end{description}

\end{document}

enter image description here

  • Your answer is probably specific for article document class. But I want it to work for amsbook and if possible for every document class. Can you help? – porton Apr 16 '15 at 10:33
  • @porton What makes you think that this will not work for amsbook or any other class? I say try it. This answer is meant to show you how to do it. You can always adjust leftmargin, labelindent and before code to suit your needs. – user11232 Apr 16 '15 at 12:29
  • I've edited the question. It does not work as expected. Please help. – porton Apr 16 '15 at 12:46
  • @porton: You can adjust: \setlist[enumerate,1]{leftmargin=2em,labelindent=*} \setlist[description,1]{leftmargin=1em,labelindent=*}. – user11232 Apr 16 '15 at 13:00
  • The result is not good. See "addendum 2" in my question. – porton Apr 16 '15 at 13:33

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.