3

I have a document with several theorems ("\begin{restatable} \label{thmA}..."). After each theorem I have the statement "see proof in section \ref{sec:thmA:proof}".

So my appendix is now a long series of sections numbered in the usual way ("7.1, 7.2, ..."). However, I would like the section numbers to be the same as the theorem numbers, except for a prefixed "A".

For example, for theorems:

Theorem 1.1

Theorem 2.1

Theorem 2.2

I would like the appendix to look like:

A1.1. Proof of theorem 1.1

A2.1. Proof of theorem 2.1

A2.2. Proof of theorem 2.2

Here is a working example, which uses the thm-restate package to restate theorems in the appendix, although this is not crucial for the question:

\documentclass[]{article}

\usepackage{amsmath,amsthm}
\usepackage{thmtools,thm-restate}

\newtheorem{thm}{Theorem}[section]

\begin{document}

\section{A section in the body}

\begin{restatable}{thm}{thmA} \label{thmA}
Statement of the theorem.
\end{restatable}

The proof of theorem \ref{thmA} can be found in the appendix (see section \ref{sec:thmA:proof}).

\newpage
\appendix

The appendix starts here.

\section{Proof of theorem \ref{thmA}} \label{sec:thmA:proof}

\thmA*

\begin{proof}
Here goes the proof.
\end{proof}

\end{document}

In the previous example, the theorem is numbered Theorem 1.1., and the first section of the appendix is titled A. Proof of theorem 1.1.. I would like it to be A1.1., which includes the information of the theorem number.

  • 2
    1st Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. 2nd . Which theorem environment do you use? \renewcommand{\thesection}{A\thetheorem} (if there is a \thetheorem command. 3rd: Do you enter the section commands or should that be done automatically? – user31729 Aug 7 '14 at 11:06
  • I'll work on this now! – gdiazc Aug 7 '14 at 11:17
  • Do you stick to the restate? – user31729 Aug 7 '14 at 11:47
  • Regarding your 2nd point, I personally require a restatement of the theorem in the appendix, to increase the readibility of the proof. However, an answer with a different theorem environment would probably still be of interest to many! Finally, for your 3rd point, it's ok if we enter the section commands manually. Thanks for the help! – gdiazc Aug 7 '14 at 11:56
  • 1
    one word of warning that applies to the solutions in both answers below: if you do have a table of contents, you will need to increase the space allowed for the section number as otherwise the section number will run into the section title in the table of contents. – greyshade Aug 7 '14 at 12:55
2

This solution redefines the thm environment and adds the proof argument to it, which is later on written to the appendix section automatically.

It will also write a \section{Proof of Number...} to the appendix, which has to be included with \CollectProofs

It is not restatable at the moment!

\documentclass{article}%

\usepackage{blindtext}%
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}

\usepackage{letltxmacro}%
\usepackage{thmtools,thm-restate}

\theoremstyle{plain}% default
\newtheorem{thm}{Theorem}[section]




\newwrite\appendixcontent%

\AtBeginDocument{%
  \immediate\openout\appendixcontent=\jobname.proofs
}%

\AtEndDocument{%
  \immediate\closeout\appendixcontent%
}%


\newcommand{\CollectProofs}{%

\immediate\closeout\appendixcontent%

\renewcommand{\thesection}{A\arabic{thm}}

\IfFileExists{\jobname.proofs}{\input{\jobname.proofs}}{False}%
}%


\LetLtxMacro\StandardTheoremBegin\thm
\let\StandardTheoremEnd\endthm


\makeatletter
\renewenvironment{thm}[1]{%
\thmt@toks{}%
\refstepcounter{thm}%
\immediate\write\appendixcontent{%
  \string\renewcommand{\noexpand\thesection}{A\thethm}%
  \string\section{Proof of \thethm}%
    \string\begin{proof}%
    \string\unexpanded{#1}%
    \string\end{proof}%
}
\addtocounter{thm}{-1}%
\StandardTheoremBegin%
}{%
  \StandardTheoremEnd%
}%



\begin{document}



\section{A section in the body}


\begin{thm}{Nothing}
\blindtext
\end{thm}


\begin{thm}{Already proven}%
  On Brontosaurs -- Part 2\par
\blindtext[2]%
\end{thm}%

\section{Other Brontosaur theories -- by Misses Ann Elk}


\begin{thm}{See excavations}
By Misses Ann Elk\par
Brontosaurs are thin at one end, thick in the middle and thin again at the other end.
\end{thm}


\clearpage

\appendix

\CollectProofs


\end{document}

enter image description here

0

One possibility would be to define a new command \proofsection which temporarily redefines \thesection:

\newcommand{\proofsection}[1]{%
    \let\origsection\thesection
    \def\thesection{\Alph{section}\ref{#1}}
    \section{Proof of theorem \ref{#1}}
    \let\thesection\origsection
}

This may not be ideal and may need some tweaking, but I think it might be a start on how to tackle the problem.

Using that, your example would become:

\documentclass[]{article}

\usepackage{amsmath,amsthm}
\usepackage{thmtools,thm-restate}

\newtheorem{thm}{Theorem}[section]

\newcommand{\proofsection}[1]{%
    \let\origsection\thesection
    \def\thesection{\Alph{section}\ref{#1}}
    \section{Proof of theorem \ref{#1}}
    \let\thesection\origsection
}

\begin{document}

\section{A section in the body}

\begin{restatable}{thm}{thmA} \label{thmA}
Statement of the theorem.
\end{restatable}

The proof of theorem \ref{thmA} can be found in the appendix (see section \ref{sec:thmA:proof}).

\newpage
\appendix

The appendix starts here.

\proofsection{thmA}\label{sec:thmA:proof}

\thmA*

\begin{proof}
Here goes the proof.
\end{proof}

\section{A non-proof section in the appendix}

\proofsection{thmA}
this would be another proof section, referring to the proof section \ref{sec:thmA:proof}.

\end{document}

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.