1

I am creating a list in LaTeX using the enumitem package, and having trouble setting the alignment of one item in the list. For that one item, I want to remove the label and decrease the indent so that item is aligned with the labels of the previous items.

Here is the code I am currently using:

\usepackage{enumitem}

\begin{enumerate}
  \item Item 1
  \item Item 2
  \item Item 3
  \item Item 4
  \item[] Item 5
\end{enumerate}

Which looks like this:

1. Item 1
2. Item 2
3. Item 3
4. Item 4
   Item 5

But what I want is this:

1. Item 1
2. Item 2
3. Item 3
4. Item 4
Item 5

Making a new paragraph doesn't work because LaTeX automatically creates space after the list and Item 5 needs to be part of the list.

Thanks in advance!

1
  • 1
    you could always use \item[]\hspace*{-whatever your indent is} Item 5 but how is the reader to to know that's item 5? it would be better markup to just end the list after 4, and arrange that it does not add vertical space Oct 17, 2017 at 22:29

1 Answer 1

1

Changing your syntax slightly (just to add more functionality), you can use \item*:

enter image description here

\documentclass{article}

\usepackage{enumitem,xparse}

\setlength{\parindent}{0pt}% Just for this example

\let\oldenumerate\enumerate
\let\endoldenumerate\endenumerate
\RenewDocumentEnvironment{enumerate}{O{}}
  {\begin{oldenumerate}[#1]
     \let\olditem\item
     \RenewDocumentCommand{\item}{s}{%
       \IfBooleanTF{##1}
         {\olditem[]\hspace*{\dimexpr-\labelindent-\labelwidth-\labelsep}\ignorespaces}
         {\olditem}}
     }
  {\end{oldenumerate}}

\begin{document}

Some reference text.

\begin{enumerate}
  \item Item 1
  \item Item 2
  \item Item 3
  \item Item 4
  \item[] Item 5
\end{enumerate}

Some reference text.

\begin{enumerate}[label=\roman*]
  \item Item 1
  \item Item 2
  \item Item 3
  \item Item 4
  \item* Item 5
\end{enumerate}

Some reference text.

\end{document}

The above redefinition of the enumerate environment keeps the optional argument functionality provided by enumitem while changing the way \item functions; it adds a starred \item* version. This *-version sets a regular \item[] and backspaces to the margin.

2
  • I think the O.P. wants to backspace to the left side of the labels (which implies using the key align=left, or wide).
    – Bernard
    Oct 17, 2017 at 23:08
  • Rather than redefining the enumerate environment you can, instead, add before=\let\olditem\newitem to the environment, where \newitem is the *-accepting item command. See, for example, tex.stackexchange.com/questions/342934/…
    – user30471
    Oct 18, 2017 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .