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;)

2
  • Welcome to TeX.SX! Do you plan to use \label and \ref for such modified items?
    – egreg
    Sep 17, 2018 at 20:26
  • No, just need a fancy looking list.
    – DexzMen
    Sep 17, 2018 at 20:29

3 Answers 3

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}
5
  • 1
    The number is repeated by I'm note getting the asterisk. Maybe because I use the enumitem package. I don't know
    – DexzMen
    Sep 17, 2018 at 20:47
  • @DexzMen Don't hide important details.
    – egreg
    Sep 17, 2018 at 20:57
  • I'm sorry. Just trying to finish my thesis. I'm a total noob;)
    – DexzMen
    Sep 17, 2018 at 20:59
  • BTW. I came with the idea of enumitem just after Skillmon answer.
    – DexzMen
    Sep 17, 2018 at 21:00
  • @DexzMen I added a solution for enumitem
    – egreg
    Sep 17, 2018 at 21:08
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

6
  • 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, 2018 at 20:41
  • @DexzMen do you load any packages changing lists, like e.g. enumitem?
    – Skillmon
    Sep 17, 2018 at 20:44
  • unfortunately yes, I had to add that because equations in the enumerate kept on going out of textwidth
    – DexzMen
    Sep 17, 2018 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, 2022 at 17:51
  • 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, 2022 at 21:34

You must log in to answer this question.

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