33

I would like to insert some explanatory text between two items of a numbered list.

Is there a command that can do this in the same way as the \intertext command in an align environment?

lockstep
  • 250,273
Jan
  • 1,344
  • Do you think it looks nicer to indent the intertext the same amount than other items or remove the indentation? – skan Nov 06 '17 at 12:18

6 Answers6

36

Use the enumitem package and two separate enumerate environments, adding resume as option to the second environment.

\documentclass{article}

\usepackage{enumitem}

\begin{document}

Some text.

\begin{enumerate}
\item First item of enumerated list.
\item Second item.
\end{enumerate}

Some explanatory text.

\begin{enumerate}[resume]
\item Third item.
\end{enumerate}

\end{document}

enter image description here

lockstep
  • 250,273
21

Here is a custom command, \enumeratext, which works like \intertext, it does not require enumitem:

\newcounter{saveenumerate}
\makeatletter
\newcommand{\enumeratext}[1]{%
\setcounter{saveenumerate}{\value{enum\romannumeral\the\@enumdepth}}
\end{enumerate}
#1
\begin{enumerate}
\setcounter{enum\romannumeral\the\@enumdepth}{\value{saveenumerate}}%
}
\makeatother

Example:

\documentclass{article}

\newcounter{saveenumerate}
\makeatletter
\newcommand{\enumeratext}[1]{%
\setcounter{saveenumerate}{\value{enum\romannumeral\the\@enumdepth}}
\end{enumerate}
#1
\begin{enumerate}
\setcounter{enum\romannumeral\the\@enumdepth}{\value{saveenumerate}}%
}
\makeatother

\begin{document}
Here is a list:
\begin{enumerate}
\item Something,
\item some other thing,
\item and more;
\enumeratext{Some intertext}
\item let's continue,
    \begin{enumerate}
        \item here is a sublist,
        \item some stuff,
        \enumeratext{more intertext}
        \item yet another stuff.
    \end{enumerate}
\item last thing.
\end{enumerate}

\end{document}

enter image description here

Update: Now works for lower level list.

Francis
  • 6,183
10

I achieved the task by just putting \item[] instead of \item in front of the inter text

layser
  • 201
6

Here is an analogue for \intertext called \listintertext:

enter image description here

\documentclass{article}

\makeatletter
\newcommand{\listintertext}{\@ifstar\listintertext@\listintertext@@}
\newcommand{\listintertext@}[1]{% \listintertext*{#1}
  \hspace*{-\@totalleftmargin}#1}
\newcommand{\listintertext@@}[1]{% \listintertext{#1}
  \hspace{-\leftmargin}#1}
\makeatother

\begin{document}

\noindent
Some text.

\begin{enumerate}
  \item First item of enumerated list.

  \begin{itemize}
    \item First bullet.

    \listintertext*{Some explanatory text.}

    \item Second bullet.

    \listintertext{Some explanatory text.}

    \item Third bullet.
  \end{itemize}

  \item Second item.

  \listintertext{Some explanatory text.}

  \item Third item.
\end{enumerate}

\end{document}

The starred version \listintertext* always sets the text flush with the left margin, regardless of the nesting depth, while the unstarred version \listintertext sets the text with only the current list depth left margin removed.

Werner
  • 603,163
  • when the explanatory text is longer than one line, the remaining lines are indented, As far as I can tell this command just applies negative space "its contents", but I cannot come up with a way to extend that to multiple lines The reason I'm focusing on this answer is that I'm trying to use it in a custom list – Mahoma May 15 '19 at 05:58
  • 1
    @Mahoma: I'm sure one could place the content in a \parbox with some \struts. That would allow multiple lines. – Werner May 16 '19 at 03:36
4

This is not necessarily better but I have used the following, due to Michel Bovani, for many years:

            \makeatletter
            \newcommand{\interitemtext}[1]{%
            \begin{list}{}
            {\itemindent=0mm\labelsep=0mm
            \labelwidth=0mm\leftmargin=0mm
            \addtolength{\leftmargin}{-\@totalleftmargin}}
            \item #1
            \end{list}}
                \makeatother

The only improvement I have ever wished is to be able to control the vertical space above and below the interitemtext.

schremmer
  • 2,107
0

Here is an overkill solution using a math environment $ ... $:

\begin{itemize}
    \item Pre-text
    $ \text{middle text} $
    \item Post-text
\end{itemize}

If you want the text to be centered, use $$ instead of $

luchonacho
  • 4,161
  • Won't $ lead to middle text being on the same line as Pre-text? – Teepeemm Oct 01 '20 at 19:20
  • @Teepeemm By middle I meant inbetween pre and post (vertically), not horizontal alignment. Is that the question? – luchonacho Oct 01 '20 at 22:49
  • But I'm not seeing anything to make middle come below pre. $$ would do that, but $ will just keep typing in the same line. You'd need to force a new line (perhaps with \\, but then the $ is really doing nothing). – Teepeemm Oct 02 '20 at 00:15
  • @Teepeemm mmm maybe because I tested it on beamer it worked. Will check. – luchonacho Oct 02 '20 at 12:09