Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a corollary with a number of parts whose parts need to be referenced individually later on, so something like:

\begin{cor}\label{cor}
   \begin{enumerate}
       \item Part one \label{partone}
       \item Part two \label{parttwo}
   \end{enumerate}
\end{cor}

Ideally, I want \ref{partone} to produce 2.1 (supposing it were Corollary 2 for the sake of argument), but, of course, \ref{partone} gives 1, as it's referencing the enumi counter.

Is there a way to get \ref to somehow combine the enumi and cor counters?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

This can also be achieved by using the enumitem package:

\documentclass{article}
\usepackage{amsthm}
\usepackage{enumitem}

\newtheorem{cor}{Corolary}

\begin{document}

\begin{cor}\label{cor}
   \begin{enumerate}[label={\thecor.\arabic*}]
       \item Part one \label{partone}
       \item Part two \label{parttwo}
   \end{enumerate}
\end{cor}
As we see in part~\ref{partone}

\end{document}
share|improve this answer
    
Shouldn't it be [ref={\thecor.\arabic*}]? I understand that holyland only wants the reference to be changed, not the label of the item itself. –  Michael Ummels Mar 15 '11 at 0:00
    
@Michael Ummels: if the change should only affect the reference, then yes, [ref={\thecor.\arabic*}] would do the job; however, that would produce an odd result, since formally you would have a reference, for example, 1.2 to an object numbered as simply 2. For the sake of consistency I suggested the change to both the label and the reference. –  Gonzalo Medina Mar 15 '11 at 0:32
1  
I agree. Maybe, it is better to put the item number in parentheses, so the label would just say (1) and the reference would be e.g. to Theorem 2 (1). This could be done by saying [label={(\arabic*)},ref={\thecor~(\arabic*)}], I suppose. –  Michael Ummels Mar 15 '11 at 12:30
    
Michael's second suggestion is what I was after. We'll see what people say about consistency between labels and references (if anyone notices). My feeling is that having the labels appear as 2.1.1, 2.1.2, etc looks really cluttered, especially with 'Corollary 2.1' right above. –  hoyland Mar 15 '11 at 23:54

You can use the chngcntr package to make the enumi counter depend on your cor counter. If you do this within the corollary environment, it won't affect other enumerate environments.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{cor}{Corollary}
\usepackage{chngcntr}

\begin{document}

\begin{cor}{My Cor}\label{mycor}
  \counterwithin{enumi}{cor}
  \begin{enumerate}
    \item An item \label{part1}
    \item Another one \label{part2}
  \end{enumerate}
\end{cor}

In Part~\ref{part1} of the the corollary\ldots

\begin{enumerate}
  \item An item \label{outside}
\end{enumerate}
This is a reference to Item~\ref{outside} that is outside the corollary.
\end{document}

Even simpler, and without using the chngcntr package, you can simply redefine \theenumi within the cor environment:

\begin{cor}{My Cor}\label{mycor}
  \renewcommand{\theenumi}{\thecor.\arabic{enumi}}
  \begin{enumerate}
    \item An item \label{part1}
    \item Another one \label{part2}
  \end{enumerate}
\end{cor}
share|improve this answer
2  
Whoever downvoted this answer: is there something wrong with the solution that I missed? –  Alan Munn Mar 15 '11 at 1:09
    
It does get the job done, as far as I can tell. I'm inclined to think Gonzalo's solution is more elegant or at least allows for more flexibility. (What I was actually after was Michael's comment to Gonzalo's answer.) –  hoyland Mar 15 '11 at 23:48
    
@hoyland I see. But since your question didn't actually state that... Anyway, I don't particularly care about votes, (I certainly don't need the reputation) but you may want to take a look at this for some other ideas on downvoting: Down Vote Etiquette –  Alan Munn Mar 16 '11 at 1:37
    
Ah, I wasn't the down vote; I was just speculating. I have no idea what the objection could have been other than someone thinking it didn't answer the question, since people seemed to read it different ways. –  hoyland Mar 16 '11 at 4:18

i was going to ask the exact same question. i found the solutions given here too complicated, i especially didnt want to get new packages for such a simple job. so i kept on reading and i am now completely satisfied with this solution:

\hyperref[partone]{\ref*{cor}.\ref*{partone}}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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