3

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{\the\labelindent}%
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{\the\labelwidth-\the\labelsep}

...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.

  • \parindent\labelsep\hangindent\labelsep Some other text ... – Fran Feb 14 '18 at 2:35
  • Semantically, I would rather align the labels on the left margin with the wide option. – Bernard Feb 14 '18 at 8:48
  • If you mean to add the wide option to the \setlist{myenum,1}, then in the resumed part of the list, the labels are no longer aligned with those in the first part of the list. – murray Feb 14 '18 at 15:29
  • @Fran: With \parindent\labelsep\hangindent\labelsep, the some other text is not aligned with the left parens of the labels, but a bit to the left of that. – murray Feb 14 '18 at 15:34
1

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*}}

\newdimen\midlistindent
\settowidth{\midlistindent}{(1)\kern-\labelindent\kern-\labelsep}
\newcommand{\midlist}[1]{%
  \begingroup
  \leftskip\midlistindent
  \noindent #1\unskip\par
  \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

  • Is there some strictly LaTeX way to do this? – murray Feb 15 '18 at 14:34
  • @murray -- there's not a "direct" way to do this. i looked into the enumitem code to see how \labelwidth was calculated, but it is far from obvious. so i simply took advantage of the existence of the \labelwidth name, to avoid having to descend into the realm of command names with @ in them. – barbara beeton Feb 15 '18 at 15:02

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.