TransWikia.com

How align paragraph with labels before resume enumitem list

TeX - LaTeX Asked on April 7, 2021

I have an enumerate list created with enumitem that I interrupt and then resume. Between the last item before the interruption and the first after the resumption, I insert a text paragraph. How can I horizontally align that paragraph so that:

  1. The first line of that paragraph is horizontally aligned with the left ends of the item labels (as indicated on the output shown at the end here); and instead
  2. The entire paragraph’s left edge is aligned with the left ends of the item labels.

Here’s what I tried:

documentclass[12pt]{article}
usepackage{calc}
usepackage{enumitem}

newlist{myenum}{enumerate}{1}
setlist[myenum,1]{label= upshape(arabic*), ref={arabic*}}

begin{document}

noindent Here is a list.

begin{myenum}
  item
    One
  item
    Two
end{myenum}

hspace{thelabelindent}%
Some other text will go here that may or may not fill out more than a single line of text on the page.

begin{myenum}[resume*]
  item 
    Three
  item
    Four
end{myenum}

end{document}

Desired alignment of intermediate paragraph.

I believe I want some arithmetic combination of lengths, such as in…

hspace{thelabelwidth-thelabelsep}

…and I would expect to use some command from package calc to do this, but: (a) I don’t know how to combine such lengths; and (b) I don’t see just what lengths I need to combine.

2 Answers

this seems to do the job:

documentclass[12pt]{article}
usepackage{calc}
usepackage{enumitem}

newlist{myenum}{enumerate}{1}
setlist[myenum,1]{label= upshape(arabic*), ref={arabic*}}

newdimenmidlistindent
settowidth{midlistindent}{(1)kern-labelindentkern-labelsep}
newcommand{midlist}[1]{%
  begingroup
  leftskipmidlistindent
  noindent #1unskippar
  endgroup}

begin{document}

noindent Here is a list.

begin{myenum}
  item
    One
  item
    Two
end{myenum}

midlist{%
Some other text will go here that may or may not fill out more than a single line of text on the page.
}

begin{myenum}[resume*]
  item 
    Three
  item
    Four
end{myenum}

end{document}

output of example code

Correct answer by barbara beeton on April 7, 2021

You have the right idea! However, instead of using the calc environment, enumitem can handle it on its own. For reference, here's the dimensions figure in the enumitem package documentation:

enter image description here

It appears you wish to have the left margin set to zero, and the label width equal to the item indent.

This is achieved with the following adjustments to the enumerate environment:

begin{enumerate}[
    align=left, 
    leftmargin=0pt, 
    itemindent=labelwidth, 
    labelsep=0pt
]
end{enumerate}

This looks like so in your document. Is this what you were after?

enter image description here

MWE:

documentclass[12pt]{article}
usepackage{enumitem}

newlist{myenum}{enumerate}{1}
setlist[myenum,1]{label= upshape(arabic*), ref={arabic*},
    align=left, 
    leftmargin=0pt, 
    itemindent=labelwidth, 
    labelsep=0pt}

begin{document}

    noindent Here is a list.
    
    begin{myenum}
      item One
      item Two
    end{myenum}
    
    noindent Some other text will go here that may or may not fill out more than a single line of text on the page.
    
    begin{myenum}[resume*]
      item Three
      item Four
    end{myenum}

end{document}

Answered by pikopiko on April 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP