I'd simplify the whole thing:
\documentclass{article}
\usepackage{enumitem}
\newenvironment{axioms}
{\enumerate[label=\textbf{A\arabic*.}, ref=A\arabic*]}
{\endenumerate}
\makeatletter
\newcommand\varitem[1]{\item[\textbf{A\arabic{enumi}\rlap{$#1$}.}]%
\edef\@currentlabel{A\arabic{enumi}{$#1$}}}
\makeatother
\begin{document}
\begin{axioms}
\item \label{item:A1} Axiom 1
\item \label{item:A2} Axiom 2
\varitem{'} \label{item:A2prime} Axiom 2$'$
\varitem{''} \label{item:A2dprime} Axiom 2$''$
\item Axiom 3
\varitem{'} Axiom 3$'$
\end{axioms}
\noindent References : \ref{item:A1}, \ref{item:A2} and \ref{item:A2prime}.
\end{document}
In my opinion, \rlap
is better (and primes are surely better than apostrophes), but you can simply get rid of it.
If you want different letters it's better to redefine \varitem
as part of the environment:
\providecommand{\varitem}{} % to keep LaTeX quiet
\makeatletter
\newenvironment{axioms}[1]
{\renewcommand\varitem[1]{\item[\textbf{#1\arabic{enumi}\rlap{$##1$}.}]%
\edef\@currentlabel{#1\arabic{enumi}{$##1$}}}%
\enumerate[label=\textbf{#1\arabic*.}, ref=#1\arabic*]}
{\endenumerate}
\makeatother
You'll have to pass the letter to the environment:
\begin{axioms}{A}
\item \label{item:A1} Axiom 1
\item \label{item:A2} Axiom 2
\varitem{'} \label{item:A2prime} Axiom 2$'$
\varitem{''} \label{item:A2dprime} Axiom 2$''$
\item Axiom 3
\varitem{'} Axiom 3$'$
\end{axioms}
Alternatively, you can define a "generic" environment and other environments based on it
\providecommand{\varitem}{} % to keep LaTeX quiet
\makeatletter
\newenvironment{statements}[1]
{\renewcommand\varitem[1]{\item[\textbf{#1\arabic{enumi}\rlap{$##1$}.}]%
\edef\@currentlabel{#1\arabic{enumi}{$##1$}}}%
\enumerate[label=\textbf{#1\arabic*.}, ref=#1\arabic*]}
{\endenumerate}
\makeatother
\newenvironment{axioms}{\statements{A}}{\endstatements}
\newenvironment{hypotheses}{\statements{H}}{\endstatements}
so that axioms
will be used as before.
Here is a solution to your problem, I think. This is quite an awful looking format. The tricky part is getting the indent of the first item of an embedded second level list. This bit of hackery (appropriately called \trickindent
) is due to egreg.
\documentclass{article}
\usepackage{enumitem}
\usepackage{kantlipsum}
\setlist[enumerate]{nosep,itemindent=3.5em}
\newcommand{\trickindent}{%
\let\normalitem\item
\def\item{%
\itemindent=0pt
\normalitem
\itemindent=3.5em
\let\item\normalitem}%
}
\begin{document}
\begin{enumerate}
\item\kant*[1]
\begin{enumerate}
\item\kant*[4]
\end{enumerate}
\item\begin{enumerate}[before=\trickindent]
\item\kant*[2]
\item\kant*[3]
\end{enumerate}
\end{enumerate}
\end{document}
![output of code](https://i.stack.imgur.com/WSrLa.png)
Best Answer
Just modify accordingly the
modenumerate
environment defined in Add asterisk after labels in enumerateInstead of
*
you can use anything you want, as long as it can be set into an\mbox
. The followingenumerate
is just to show that the result is the same.If you are using the
enumitem
package, the following code allows the use of\moditem
in anyenumerate
environment:If you don't use
enumitem
, then change the first two lines into