4

I'm trying to obtain:

1. text text text
2. text text text
2*. text text text
3. text text text
4. text text text
4*. text text text

I've seen something similar done with:

\newcommand{\myitem}{\refstepcounter{enumi}\item[\theenumi\up{*}.]}

Here . However, it is not what I'm trying to accomplish.

EDIT. My God, you people are awesome!!! If I could only get as many responses in the Cross Validated stack I would finish my thesis in a week;)

DexzMen
  • 45

3 Answers3

3

enter image description here

It is better to let the very right of labels aligned together. Define \newcommand{\myitem}{\item[$\vphantom{x}^{*}$\theenumi]} and use \setlist[enumerate,1]{leftmargin=*, label=\arabic*.} in the preamble.

\documentclass[]{report}

\usepackage{enumitem}

\newcommand{\myitem}{\item[$\vphantom{x}^{*}$\theenumi]}
\setlist[enumerate,1]{leftmargin=*, label=\arabic*.}

\begin{document}

\begin{enumerate}
    \item Item 1
    \item Item 2
    \myitem Item 2 (with asterisk)
    \item Item 3
    \item Item 4
    \item Item 5
\end{enumerate}

\end{document}
3

A “simple” modification for a first level list with the default 1. appearance of labels:

\documentclass{article}

\newcommand{\repitem}{%
  \addtocounter{enumi}{-1}%
  \let\savedtheenumi\theenumi
  \renewcommand{\theenumi}{\arabic{enumi}\itemasterisk}%
  \item\let\theenumi\savedtheenumi
}
\protected\def\itemasterisk{\rlap{*}}

\begin{document}

\begin{enumerate}

\item One
\item Two
\repitem Two*
\item Three
\item Four
\repitem Four*

\end{enumerate}

\end{document}

enter image description here

With enumitem:

\documentclass{article}
\usepackage{enumitem}

\newlist{fancyenumerate}{enumerate}{1}
\setlist[fancyenumerate]{label=\arabic*\perhapsasterisk.}
\protected\def\perhapsasterisk{}
\protected\def\itemasterisk{\rlap{*}}

\newcommand{\repitem}{%
  \addtocounter{fancyenumeratei}{-1}%
  \let\perhapsasterisk\itemasterisk
  \item\def\perhapsasterisk{}%
}

\begin{document}

\begin{fancyenumerate}

\item One
\item Two
\repitem Two*
\item Three
\item Four
\repitem Four*

\end{fancyenumerate}

\end{document}
egreg
  • 1,121,712
1

A small (referable) implementation doing what you're asking for:

\documentclass[]{article}

\usepackage{xparse}

\makeatletter
\NewDocumentCommand \myitem { o }
  {%
    \IfValueTF {#1}
      {%
        \item[#1]%
      }
      {%
        \addtocounter{enumi}{-1}%
        \let\theenumiBAK\theenumi
        \def\theenumi{\theenumiBAK\myitem@asterisk}%
        \item
        \let\theenumi\theenumiBAK
      }%
  }
\newcommand\myitem@asterisk{}
\protected\def\myitem@asterisk{\textsuperscript{*}}
\makeatletter

\begin{document}
\begin{enumerate}
  \item Hihi
  \myitem Haha
  \item Huhu
\end{enumerate}
\end{document}

enter image description here

Skillmon
  • 60,462
  • Somehow I cannot make it work. I use documentclass{book} and place the relevant part of the code in the main .tex while the chapters are added by \subfile{}. The list is supposed to be in one of the chapters – DexzMen Sep 17 '18 at 20:41
  • @DexzMen do you load any packages changing lists, like e.g. enumitem? – Skillmon Sep 17 '18 at 20:44
  • unfortunately yes, I had to add that because equations in the enumerate kept on going out of textwidth – DexzMen Sep 17 '18 at 20:46
  • 1
    @PatrickT maybe you want to open a new question with a minimal example showing the problematic behaviour (you could link to this thread there)? Just from this comment I'm not sure what you tried and how your code looks like. – Skillmon Jan 23 '22 at 17:51
  • @Skillmon, Thanks! so it turned out to be a conflict with the beamer class, which I solved by redefining an environment and not using the enumitem package at all. – PatrickT Jan 23 '22 at 20:10
  • 1
    @PatrickT good to hear you got your things sorted. Yes, enumitem is known to be incompatible with beamer! Don't ever load the two together. – Skillmon Jan 23 '22 at 21:34