This is a follow-up from : Custom Enumeration
I'd want to obtain something like :
Axioms list :
A1. First axiom
A2. Second axiom
A2'. Equivalent version of the second axiom
with cross-reference, and also in a nice content-oriented manner. More specifically, I expect it to give convenient facility for reordering the items, and also it would be nice if it could generate all enumerations of the sort.
For example, I wouldn't expect to need a new command for :
Hypothesis list :
H1) First hypothesis
H2) Second
H2') Another version of the second
Redefining variables in the enumerate environment (locally or globally) is fine in this setting.
The best I have so far is :
(edited thanks to egreg's answer)
\documentclass{article}
\usepackage{enumitem}
\makeatletter
\def\myEnumCounter#1{\expandafter\@myEnumCounter\csname c@#1\endcsname}
\def\@myEnumCounter#1{\ifcase#1\or \or $'$\or $''$\fi}
\makeatother
\AddEnumerateCounter*{\myEnumCounter}{\@myEnumCounter}{3}
\newlist{axioms}{enumerate}{2}
\setlist[axioms,1]{label=\textbf{A\arabic{axiomsi}.}, ref=A\arabic{axiomsi}}
\setlist[axioms,2]{label=\textbf{A\arabic{axiomsi}\rlap{\myEnumCounter{axiomsii}}.},%
ref=A\arabic{axiomsi}\myEnumCounter{axiomsii},%
align=parleft,%
leftmargin=0em,%
itemsep=1.4ex,%
before={\stepcounter{axiomsi}}}
\begin{document}
\noindent Fail attempt %(useful to compare indentation and vertical separation):
\begin{enumerate}[label=\textbf{A\arabic*.}]
\item \label{item:A1} Axiom 1
\item \label{item:A2} Axiom 2
\item[\textbf{A2'}] \label{item:A2prime} Axiom 3
\end{enumerate}
\noindent "Almost there" attempt :
\begin{axioms}
\item \label{item:B1} Axiom 1
\item[]
\begin{axioms}
\item \label{item:B2} Axiom 2
\item \label{item:B2prime} Axiom 2'
\end{axioms}
\end{axioms}
\noindent References : \ref{item:A1}, \ref{item:A2} and \ref{item:A2prime} (last one doesn't work).
\noindent References : \ref{item:B1}, \ref{item:B2} and \ref{item:B2prime}.
\end{document}
The result is :
(non totally up-to-date)
However, there are still a few issues :
- I used the answer to nested enumeration, skipping items to avoid having an extra label in case I need to enter the second enumeration. However, the result somewhat fails to satisfy the "content-oriented" condition.Also, the situation here is a little different, because there is a scheme : I want a label if and only if the item isn't a new
axioms
environment. I guess there would be a way to do that withenumitem
style key, but I can't figure how. - There is a 1mm offset of the sub-enumeration I can't suppress (I think I tried all the keys
enumitem
provides for horizontal spacing) - I had to add the
itemsep=1.4ex
to ensure the sub-enumeration has the same vertical spacing as the main one, but I suspect there is a better way to do this.
Best Answer
I'd simplify the whole thing:
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:You'll have to pass the letter to the environment:
Alternatively, you can define a "generic" environment and other environments based on it
so that
axioms
will be used as before.