28

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?

  • Do you think it looks nicer to indent the intertext the same amount than other items or remove the indentation? – skan Nov 6 '17 at 12:18
30

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

| improve this answer | |
  • Exactly as explained in [the enumitem package documentation](www.tex-tipografia.com/archive/enumitem.pdf) on page 6. – yo' Sep 30 '13 at 8:48
  • It works! And it looks like I used to wrong key words for my search. – Jan Sep 30 '13 at 8:50
  • 9
    May be you can define a command: \newcommand{\myintertext}[1]{\end{enumerate} #1\begin{enumerate}[resume]}. – user11232 Sep 30 '13 at 8:58
  • 1
    If one uses \usepackage[shortlabels]{enumitem}with more sophisticated labels the possibility to use multiple arguments is very helpful: \begin{enumerate}[step 1):, resume] – Jakob Aug 10 '19 at 13:34
18

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.

| improve this answer | |
6

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

| improve this answer | |
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Seamus Jun 9 '16 at 10:48
  • This is the easiest solution. Though some may prefer a non indented one, and it's not as easy as using \noindent – skan Nov 6 '17 at 12:12
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.

| improve this answer | |
  • 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 5: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 3: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.

| improve this answer | |
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 $

| improve this answer | |
  • Won't $ lead to middle text being on the same line as Pre-text? – Teepeemm Oct 1 at 19:20
  • @Teepeemm By middle I meant inbetween pre and post (vertically), not horizontal alignment. Is that the question? – luchonacho Oct 1 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 2 at 0:15
  • @Teepeemm mmm maybe because I tested it on beamer it worked. Will check. – luchonacho Oct 2 at 12:09

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.