1

I need help please with indentation within a description list where custom labels are being used. The mwe below shows my problem. Thanks!

\documentclass{article}

\usepackage{enumitem}

\setlist[description]{leftmargin=\parindent}

\begin{document}

\begin{description}

\item[3.] My issue is indentation within this list. I need the custom labels because I might have to skip numbers. This particular item is indented the way I want it, namely, the second line is aligned with the first word ``My'' of the first line.

\item[30.] Here is where the problem lies. In this item the custom label consists of two digits and a period, and as a result, the second line is no longer aligned with the first letter ``H'' of the first line. Looks bad.

\item[Idea.] If we use the ordinary enumerate environment without custom labels, then as the labels get longer (1, 10, 100, etc.), they ``grow'' to the left rather than to the right, as my labels here are doing. Maybe there is an easy way for me to tell my custom labels that they too should grow to the left? If so, would that solve my indentation problem?

\end{description}

\end{document}

mwe

dcalvis
  • 31
  • Can you please add an screenshot of your result and mark there your issue? – Mensch Dec 17 '21 at 19:27
  • Done. Is that how one presents one's output on this forum? Meant to do so in the first place, but didn't know how. – dcalvis Dec 17 '21 at 19:34
  • 1
    A screenshot is indeed a way to present the output (you could clip away the task bar and other irrelevant stuff, though). But I wonder: How exactly do you want the output to be? – Jasper Habicht Dec 17 '21 at 20:02
  • Agreed about the output, thanks. I'd like the text on each of the second lines to be aligned with the text on the corresponding first line. In the first item, this happens automatically, although I don't know what did to make it happen. In the other two items, it does not happen, and I'd like to know how to make it happen. – dcalvis Dec 17 '21 at 20:07
  • 1
    I am not sure that such an alignment really makes reading easy, if every paragraph has a different indentation from the left. Or did I get you wrong? In the example above, the indentation is always the same. Only if the label is wider than the margin, it protrudes into the text. – Jasper Habicht Dec 17 '21 at 20:50
  • 1
    Maybe you can do something like this: https://tex.stackexchange.com/q/130097/47927 – Jasper Habicht Dec 17 '21 at 21:03
  • Thank you, Jasper. Truthfully, I had the same concern, that various paragraphs would be indented differently. Your suggestion above looks like a good way to go. My only remaining question would be, is it easy to make the custom labels "grow to the left" rather than "grow to the right" as they increase from one to two to three digits, etc.? Again thanks. – dcalvis Dec 17 '21 at 21:52

1 Answers1

1

You could take this nice answer and just change one single letter to make the labels align to the right:

\documentclass{article}
\usepackage{eqparbox}
\usepackage{enumitem}
\usepackage[margin=1em,papersize={4in,2.2in}]{geometry}

\newlist{mydescription}{description}{1} %% <- pick a larger number if you want to nest these \setlist[mydescription]{ labelwidth=\eqboxwidth{listlabel@\EnumitemId}, leftmargin=!, format=\mydescriptionlabel, } \newcommand\mydescriptionlabel[2][r]{\eqmakebox[listlabel@\EnumitemId][#1]{#2}} % change l to r

\newcommand{\text}{long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long text}

\begin{document} \begin{mydescription} \item[The longest label] text \item[Short] \text \end{mydescription} \hrule \begin{mydescription} \item[Medium label] text \item[Short] \text \end{mydescription} \end{document}

enter image description here