I state a theorem in the main body of a document and prove it in the appendix. I use thmtools's restatable environment to restate the theorem there. However, I now need to have my appendix in a separate pdf file (hence a separate tex document). I'm using xr and xcite to get the cross-references and bibliographical references to play nicely.
But the commands created by restatable are not carried. Is there any way to to the restating of the theorem in the appendix in a separate document?
Here's a MWE:
main document: main.tex
\documentclass{article}
\usepackage{thmtools}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{restatable}{theorem}{thmcmd}\label{thmlabel}
Here is the statement of the theorem.
\end{restatable}
The above is Theorem~\ref{thmlabel}.
In this way I can restate it:
\thmcmd*
\end{document}
appendix: appendix.tex
\documentclass{article}
\usepackage{xr}
\externaldocument{main}
\usepackage{thmtools}
\newtheorem{theorem}{Theorem}
\begin{document}
I can refer to Theorem~\ref{thmlabel}.
But I cannot restate it like this:
% \thmcmd*
\end{document}
Best Answer
tcolorbox
package provides some macros for saving the content of boxes and use it later.The simplest example could be:
In previous code
saveto
option, saves the wholetcolorbox
content (upper and lower parts) in filemyfile.tex
. It saves only the contents, not the format of the box.Option
lowerbox=ignored
makes that the lower part (the prove in this case) doesn't appears, but it is saved.Later on into the same document, or into another document,
myfile.tex
can be restated as a tcolorbox content.More information about these commands can be found in
tcolorbox
documentation, sections4.3 Upper part
,4.4 Lower part
and for more complex examples in chapter8. Recording
. Some examples here: https://tex.stackexchange.com/a/257455/1952 and https://tex.stackexchange.com/a/224429/1952Update
I'll try to show that example shown in https://tex.stackexchange.com/a/224429/1952 can be also applied with an external document. The first document will contain theorems and proofs, although only theorems will be printed, while the second one will show theorems and proofs. This solution applies an
invisible
box (blankest
intcolorbox
nomenclature) as OP wanted.The document with theorems and proof is called
TestTheorems.tex
and its content is:It declares a
theorem
tcolorbox whose contents will be saved (saveto
option) in different files, one for each theorem. The name of this files is alse recorded (record
option) into an auxiliary file calledTestTheorems.record
. This auxiliary file is created with comman\tcbstartrecording
and is closed with command\tcbstoprecording
.After processing this file the result is:
but also a folder
theorems
with four files in it, one for each theorem, and the fileTestTheorems.records
into main folder.The second file
TestProofs.tex
contains the definition oftcolorbox
which will read all recorded theorems and proofs. And withxr
help, they will keep their original names and numbers. Command\tcbinputrecords
declares which file will be read. Being an external file, it's necessary to indicate the name as an option.The result is: