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
label
to work inside tabular, even with thearray
package 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!
Best Answer
use the inline mode: