3

I have a list of axioms, and I am using enumitem to label them:

\documentclass{article}
\usepackage{enumitem}
\newcommand\fmt[1]{$\mathbf{(#1)}$}
\begin{document}

\begin{enumerate}[format=\fmt]

\item[Ex_1]\label{ax1} The sky is blue.

\item[Egreg_\infty]\label{ax2} Another item.

\end{enumerate}
The first condition is \ref{ax1}
\end{document}

All the \items have their optional parameter, because the names do not follow a simple pattern. I'd like the \ref to be formatted in exactly the same way as the label appears in the list. But it seems that when \item is given its optional argument it does not even emit a anchor for a reference, let alone format the reference like the label.

Is there a way to do this?

1 Answers1

3

Use a different mark up.

\documentclass{article}
\usepackage{enumitem}

\DeclareRobustCommand\fmt[1]{$\mathbf{(#1)}$}
\newenvironment{axioms}
 {\enumerate[format=\fmt]}
 {\endenumerate}
\makeatletter
\newcommand{\axiom}[1]{%
  \def\@currentlabel{\fmt{#1}}\item[#1]%
}
\makeatother


\begin{document}

\begin{axioms}

\axiom{Ex_1}\label{ax1} The sky is blue.

\axiom{Egreg_\infty}\label{ax2} Another item.

\end{axioms}

The first condition is \ref{ax1}, while the second is \ref{ax2}.

\end{document}

enter image description here

egreg
  • 1,121,712