This is a follow-up question to my last question:
Defining a new LaTeX environment for numbered two-column proofs
Basically, I'm trying to define the following environment:
\newcounter{proofc}
\DeclareRobustCommand\stepproofc{\refstepcounter{proofc}(\arabic{proofc})}
\newenvironment{twoproof}{%
\setcounter{proofc}{0}
\begin{tabular}{@{\stepproofc \hspace{4pt}}>{$}c<{$}|>{$}l<{$}}
}{
\end{tabular}
}
and I used \refstepcounter specifically so that I could refer to some entries inside other entries, like this:
\begin{twoproof}
\label{step1} Prop A & Justification \\
\label{step2} Prop B & Justification \\
Prop C & Because \ref{step1} and \ref{step2}
\end{twoproof}
Sadly, if you include the array package, this doesn't come out the way I'd hoped, because the \ref macros don't turn into the right number. I'm like 99% sure that this is because the \label macro is catching the wrong number (if you put a theorem environment before a twoproof environment, the \ref macros transform into the number of the theorem).
If I don't include the array package, this works the way it should. But then I can't use the >{$} and <{$} column modifiers to put my columns into math mode (I've tried using @-espressions instead and that gives an error). So how do I
- get
labelto work inside tabular, even with thearraypackage included (preferable), or - Typeset my columns in math mode without using
>{$}and<{$}, which come from the array package.
Any help will be greatly appreciated!
Edit: Unfortunately, if you try to wrap the whole environment in \begin{displaymath} and \end{displaymath}, and change tabular to array (and get rid of the column modifiers), you get this error:
! Package amsmath Error: Multiple \label's: label 'step1' will be lost.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.30 \label
{step2} Prop B & Justification \\
?
So it seems like displaymath doesn't play nicely with labels either.
Edit 2: As requested, here is a complete example illustrating the problem:
\documentclass[oneside]{article}
\usepackage{amsmath,amsthm}
\usepackage{array}
\newcounter{proofc}
\DeclareRobustCommand\stepproofc{\refstepcounter{proofc}(\arabic{proofc})}
\newenvironment{twoproof}{%
\setcounter{proofc}{0}
\begin{tabular}{@{\stepproofc \hspace{4pt}}>{$}c<{$}|>{$}l<{$}}
}{
\end{tabular}
}
\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\begin{document}
\begin{thm} This theorem exists to highlight the problem. \\
If you remove it or take the proof out of the theorem, the ref numbers simply disappear in the proof below
\begin{center}
\begin{twoproof}
\label{step1} E \vdash \alpha & \pi_1 \\
\label{step2} E \vdash \beta & \pi_2 \\
E \vdash \gamma & \ref{step1} \mbox{ and } \ref{step2}
\end{twoproof}
\end{center}
\end{thm}
\end{document}
Note that if you replace lines 7-12 with:
\newenvironment{twoproof}{%
\setcounter{proofc}{0}
\begin{displaymath}
\begin{array}{@{\mbox{\stepproofc \hspace{4pt}}}c|l}
}{
\end{array}
\end{displaymath}
}
You get the error described above.
Thanks again for your help!
\Labelmacro (what's the point of automatic numbering if I have to put something in anyway). That may seem silly, but it just doesn't quite do what I want. I've tried modifying the provided solution, but haven't been able to separate the labeling and numbering mechanisms without running into the issue described in the question. That's what I'm going to keep trying to do, though. – maths Dec 22 '10 at 05:10\labeland\ref? Herbert gave you a solution, but in this case\ref{step<n>}is just a very fancy and unnecessarily complicated way to type the number<n>. – Hendrik Vogt Dec 22 '10 at 07:35\reftags. Herbert might reasonably argue that the old\Labelmacros (the custom ones) solve my problem, because every step that is at some point cited (which should be all but the last one) will have a number and a label, which is what I want. But, like I said, that solution just doesn't quite work they way I'd like, so I'm going to keep playing with it. I appreciate everyone's input, though! – maths Dec 22 '10 at 15:29