Closed ZacCranko closed 5 years ago
The easiest would simply to use the toappendix
environment:
\begin{toappendix}
\begin{lemma}
This lemma only appears in the appendix.
\end{lemma}
\end{toappendix}
If you want to automate this, so that every (say) applemma
environment is put in the appendix, you can possibly do this:
\makeatletter
\newenvironment{applemma}{%
\axp@writesection
\immediate\write\axp@proofsfile{%
\noexpand\begin{lemma}%
}\VerbatimOut
}{%
\endVerbatimOut
\immediate\write\axp@proofsfile{%
\noexpand\end{lemma}%
}}
\makeatother
and then use applemma
instead of lemma
, but I am not sure it is better that the toappendix
solution.
I could potentially implement this more generically, if there is a reason why the use of toappendix
is not ideal, let me know.
I'll have to double check this (because I'm using the alias counter trick to get autoref to work), but when I tried wrapping a lemma
environment in a toappendix
it messed up the numbering.
There shouldn't be any issue of this kind: the lemma will have a numbering appropriate to its location in the appendix, which is probably what should be done. But if you have an example where this does not behave in a reasonable manner, or where there is a bad interaction with \autoref
, let me know.
Okay I have a minimal example of this, using a theorem and lemma with a linked counter:
\documentclass{article}
\usepackage{apxproof}
\newtheoremrep{theorem}{Theorem}
\newtheoremrep{lemma}[theorem]{Lemma}
\begin{document}
\section{Here's some cool stuff}
\begin{toappendix}
\begin{lemma}
Air Jordans are cool.
\end{lemma}
\begin{proof}
Michael Jordan is cool.
\end{proof}
\end{toappendix}
\begin{theoremrep}
Nike.
\end{theoremrep}
\begin{proof}
Just look at the Air Jordans.
\end{proof}
\appendix
\end{document}
which produces: ...and in the appendix:
Thanks for the example. I understand this may be counter-intuitive, but it is working as intended:
I agree it is counter-intuitive to see Lemma 2 ahead of Theorem 1 in the main text, but I do not see what other behavior could be expected here: it would be wrong to change the counter of Theorem 1 to something else, since it is the only thing that appears in the main text; it would be wrong to number the Lemma as Lemma 1 if counters need to be shared between lemmas and theorems; it would be wrong to renumber Theorem 1 in the appendix only – one of the main points of apxproof
is to be able to restate theorems identically.
Do you have any other behavior in mind?
I agree that it is not a bug, and I understand why this particular numbering is generated, but I do not think it is desirable behaviour, or at least it is undesirable for me.
The reason for this is that I think it is good practice to use a single counter for all logical theorem-like environments, i.e., definitions, axioms, propositions, lemmas, theorems, corollaries. And then to ensure that all dependent theoremlikes have higher number than anticedent theoremlikes. For example, the proof of Theorem 3 should not reference Lemma 4, since this would be a red flag for logical consistency.
What do you think? Have I gone overboard with my theorem numbering? :)
I am going to close this issue, sorry. The solution proposed in the original message is ok for the cases where one would actually want to have theorems numbered in the way you indicate, but the idea of having numbers jumping in the main body of the text because some lemma with a lower number is hidden in the appendix sounds confusing to me :-).
I have looked into implementing this feature in apxproof all the same, but it causes some unwelcome interactions with the fact that repeated normally point to the version of the theorem in the main body, so unless other users clamor for this feature, I will not add it.
Note that a way to handle the weird 1, 2, 1 sequence of numbered results in your example is to simply use numbering by section, which is implemented in apxproof. It would yield in this special case 1.1, A.1, 1.1, which may be more intuitive.
I've found it handy for submitting to conferences where it's quite common to have a condensed overview of the results and a separate appendix that contains the main body of the proof structure. But I take your point that it can look a bit unconventional to have the numbers jumping like that.
I'm attaching my solution here in case you're interested in developing it further. It supplies another environment, theoremlikeapx
which only appears in the appendix and renumbers the counters to be consistent. The trick is to write the theoremlike environment to the proofs file with the unmodified theormlike environment, along with some extra code to advance the counter in the main body, and temporarily reset the theoremlike counter in the appendix to the current counter value in the main body.
It has a bit of extra code to handle \autoref
and doesn't support supplying a custom counter for \newtheorem
but other than that it seems to work very well including with the induced hyperrefs.
\def\axp@newtheoremrep#1[#2]#3[#4]{%
\expandafter\let\csname #1\endcsname\undefined
\expandafter\let\csname c@#1\endcsname\undefined
\axp@newtheorem{#1}{#2}{#3}{#4}%
\expandafter\pretocmd\csname #1\endcsname{\noproofinappendix}{}{}%
\axp@newtheorem*{axp@#1rp}{#3}%
\axp@forward@setup{#1}{#2}{#3}{#4}%
\NewEnviron{#1rep}[1][]{%
\ifthenelse{\equal{\axp@repeqn}{same}}{%
\setcounter{axp@equation}{\value{equation}}%
}{}%
\addtocounter{axp@rpcounter}{1}%
\ifx\relax##1\relax
\axp@with@forward{#1}{\begin{#1}}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}%
\else
\axp@with@forward{#1}{\begin{#1}[(##1)]}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}%
\fi
\global\toggletrue{axp@seenreptheorem}%
\global\expandafter\let\csname rplet\roman{axp@rpcounter}%
\endcsname
\BODY
\axp@writesection%
\ifthenelse{\equal{\axp@repeqn}{same}}{%
\immediate\write\axp@proofsfile{%
\noexpand\setcounter{axp@equationx}{\value{equation}}%
\noexpand\setcounter{equation}{\theaxp@equation}%
}%
}{}%
\immediate\write\axp@proofsfile{%
\noexpand\begin{axp@#1rp}
[\noexpand\ref{axp@r\roman{axp@rpcounter}}%
\@ifnotempty{##1}{ \unexpanded{(##1)}}]%
\noexpand\axp@forward@target{axp@fw@r\roman{axp@rpcounter}}{}%
\noexpand\axp@redefinelabels
\expandafter\noexpand\csname rplet\roman{axp@rpcounter}%
\endcsname
\noexpand\end{axp@#1rp}
}%
\ifthenelse{\equal{\axp@repeqn}{same}}{%
\immediate\write\axp@proofsfile{%
\noexpand\setcounter{equation}{\value{axp@equationx}}%
}%
}{}%
}%
\NewEnviron{#1apx}[1][]{% appendix only statement
\addtocounter{axp@rpcounter}{1}%
\global\toggletrue{axp@seenreptheorem}%
\global\expandafter\let\csname rplet\roman{axp@rpcounter}%
\endcsname
\BODY
\axp@writesection%
\immediate\write\axp@proofsfile{%
\noexpand\setcounter{#1}{\csname the#1\endcsname}%
\noexpand\begin{#1}\@ifnotempty{##1}{[\unexpanded{(##1)}]}
\expandafter\noexpand\csname rplet\roman{axp@rpcounter}%
\endcsname
\noexpand\end{#1}
}%
\ifthenelse{\equal{\axp@repeqn}{same}}{%
\immediate\write\axp@proofsfile{%
\noexpand\setcounter{equation}{\value{axp@equationx}}%
}%
}{}%
\addtocounter{#1}{1}%
}%
}
Is there any way to write a lemma that should only appear in the appendix?
I hacked something together that seems to get the job done:
where the second argument is to specify a label for the environment, and
#1cnt
is the theoremlike counter , I couldn't figure a more slick way to do this.