2

I want to cite an item in an enumeration. I have a following LaTeX code:

\documentclass{memoir}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{newtxtext}
\theoremstyle{theorem}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\begin{document}
\begin{definition}[Peano Arithmetic, PA]
Peano Arithmetic is consists of following axioms:
\begin{enumerate}
\item[S1.] $\forall x : S(x) \neq 0$
\item[S2.] $\forall x : x=0\lor (\exists y: S(y) = x)$
\item[S3.] $\forall x \forall y : S(x)=S(y) \to x=y$
\item[A1.] $\forall x : x+0=0$
\item[A2.] $\forall x\forall y : x+S(y) = S(x+y)$
\item $\forall x : x\cdot 0 = 0$
\item[M2.] $\forall x \forall y: x\cdot S(y) = x\cdot y + x$
\item[O1.] $\forall x\forall y x\le y \leftrightarrow \exists z : y=x+z$
\item[Ind.] \label{induction} For any property $P(n)$, if $P(0)$ and $\forall n : P(n)\to P(S(n))$ holds then $\forall n P(n)$ also holds. 
\end{enumerate}
\end{definition}
 However the word \emph{property} in the axiom \ref{induction} is ambiguous.
\end{document}

The result I want to get is

(...)

However the word property in the axiom Ind. is ambiguous.

But it doesn't work. The situation doesn't change even if I change enumerate to itemize or description.

I guess that named labels are not an object can be labeled (Because my trials suggest the label refers the nearest unnamed label or the \definition environment.)

Is there any elegant way to help it? Thanks for any help.

  • Please edit this into a compilable example. When you override items like this you cannot refer to them, special methods (manually setting \@currentlabel) are needed. There are other questions about this on the site – daleif Oct 3 '16 at 13:40
  • Still not a compilable document. Please remember to test your mwe before posting. – daleif Oct 3 '16 at 13:54
  • @daleif I have two separate code (on the question and on my computer) so I couldn't find the problem. I guess it is compilable now. – Hanul Jeon Oct 3 '16 at 13:57
  • It is, do you know the difference between \ref and \cite? Because \cite has nothing to do with \label. I'll post a possible solution in a minute – daleif Oct 3 '16 at 13:59
1

I've removed a lot of stuff that it not really relevant to the problem presented here.

There are two issues: (1) \item[...] is not referable, since you are manually setting the items, you might as well use itemize here, (2) when you have added a \label, to retrieve the data you need to use \ref not \cite (that is something completely different, a citation)

In this case we use a personal \item command that also sets the macro that \label gets its information from. Note that if you use hyperref in your real document, you need to use \item[#1]\phantomsection\@currentlabel{#1} in the definition of \myitem

\documentclass{article}

\newtheorem{definition}{Definition}

\makeatletter
\newcommand\myitem[1][]{%
  \item[#1]\def\@currentlabel{#1}%
}
\makeatother

\begin{document}

\begin{definition}[Peano Arithmetic, PA]
Peano Arithmetic is consists of following axioms:
\begin{enumerate}
\myitem[S1.] $\forall x : S(x) \neq 0$
\myitem[S2.] $\forall x : x=0\lor (\exists y: S(y) = x)$
\myitem[S3.] $\forall x \forall y : S(x)=S(y) \to x=y$
\myitem[A1.] $\forall x : x+0=0$
\myitem[A2.] $\forall x\forall y : x+S(y) = S(x+y)$
\myitem[M1.] $\forall x : x\cdot 0 = 0$
\myitem[M2.] $\forall x \forall y: x\cdot S(y) = x\cdot y + x$
\myitem[O1.] $\forall x\forall y x\le y \leftrightarrow \exists z : y=x+z$
\myitem[Ind.] For any property $P(n)$, if $P(0)$ and $\forall n : P(n)\to P(S(n))$ holds then $\forall n P(n)$ also holds. \label{induction} 
\end{enumerate}
\end{definition}
However the word \emph{property} in the axiom \ref{induction} is ambiguous.
\end{document}
  • 1
    While the % characters I added are not strictly necessary here, it's better to have them, in order not to mislead beginners. – egreg Oct 3 '16 at 20:13
2

It makes sense to define a new environment for this, modeled on the description environment as defined in memoir, but with the addition of a proper definition for \@currentlabel. Some juggling is necessary to get the definition in the right place.

\documentclass{memoir}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{definition}{Definition}

\makeatletter
\newenvironment{labeldesc}
 {%
  \list{}{%
    \labelwidth\z@
    \itemindent-\leftmargin
    \let\makelabel\labeldesclabel
  }%
 }
 {\endlist}
\newcommand*{\labeldesclabel}[1]{%
  \hspace\labelsep
  \normalfont\bfseries #1.%
  \gdef\labeldesc@label{#1}%
  \aftergroup\let\aftergroup\@currentlabel\aftergroup\labeldesc@label
}
\makeatother

\begin{document}

\begin{definition}[Peano Arithmetic, PA]
Peano Arithmetic consists of the following axioms:
\begin{labeldesc}
\item[S1] $\forall x : S(x) \neq 0$
\item[S2] $\forall x : x=0\lor (\exists y: S(y) = x)$
\item[S3] $\forall x \forall y : S(x)=S(y) \to x=y$
\item[A1] $\forall x : x+0=0$
\item[A2] $\forall x\forall y : x+S(y) = S(x+y)$
\item[M1] $\forall x : x\cdot 0 = 0$
\item[M2] $\forall x \forall y: x\cdot S(y) = x\cdot y + x$
\item[O1] $\forall x\forall y x\le y \leftrightarrow \exists z : y=x+z$
\item[Ind]\label{induction}
   For any property $P(n)$, if $P(0)$ and $\forall n : P(n)\to P(S(n))$
   holds, then $\forall n P(n)$ also holds.
\end{labeldesc}
\end{definition}
However the word \emph{property} in the axiom \ref{induction} is ambiguous.
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.