tcolorbox
package provides some macros for saving the content of boxes and use it later.
The simplest example could be:
\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcolorbox}[saveto=myfile.tex, lowerbox=ignored]
This is a nice theorem
\tcblower
This is the nice prove
\end{tcolorbox}
\begin{tcolorbox}[title=A nice theorem with its prove]
\input{myfile.tex}
\end{tcolorbox}
\end{document}
In previous code saveto
option, saves the whole tcolorbox
content (upper and lower parts) in file myfile.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, sections 4.3 Upper part
, 4.4 Lower part
and for more complex examples in chapter 8. Recording
. Some examples here: https://tex.stackexchange.com/a/257455/1952 and
https://tex.stackexchange.com/a/224429/1952
Update
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
in tcolorbox
nomenclature) as OP wanted.
The document with theorems and proof is called TestTheorems.tex
and its content is:
\documentclass{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\NewTColorBox[auto counter,number within=section]{theorem}{+O{}}{ %
enhanced, blankest,
coltitle=black,
title={Theorem~\thetcbcounter:},
label={theorem@\thetcbcounter},
attach title to upper=\quad,
theorem style=standard,
lowerbox=ignored,
saveto=theorems/theorem-\thetcbcounter.tex,
record={\string\proof{\thetcbcounter}{theorems/theorem-\thetcbcounter.tex}},
#1
}
\begin{document}
\section{Some theorems without proof}
\tcbstartrecording
Some theorems are shown in this document. All proofs are also written here, but not printed. They will be printed in another document.
\begin{theorem}
This is the first theorem
\tcblower
This is the proof of the first theorem\end{theorem}
\begin{theorem}
This is the second theorem
\tcblower
This is the proof of the second theorem\end{theorem}
\begin{theorem}
This is the third theorem
\tcblower
This is the proof of the third theorem\end{theorem}
\begin{theorem}
This is the fourth theorem
\tcblower
This is the proof of the fourth theorem\end{theorem}
\tcbstoprecording
\end{document}
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 called TestTheorems.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 file TestTheorems.records
into main folder.
The second file TestProofs.tex
contains the definition of tcolorbox
which will read all recorded theorems and proofs. And with xr
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.
\documentclass{article}
\usepackage{xr}
\externaldocument{TestTheorems}
\usepackage[most]{tcolorbox}
\NewTotalTColorBox{\proof}{mm}{ %
enhanced, blankest,
coltitle=black,
theorem style=plain,
title={Theorem~\ref{theorem@#1}:},
phantomlabel={proof@#1},
attach title to upper=\par,
before lower={Proof:\par}
}{\input{#2}}
\begin{document}
\section{Phnatom section}
\section{Theorems and proofs}
This document shows already printed theorems but it also includes all proofs.
\tcbinputrecords[TestTheorems.records]
\end{document}
The result is:
Best Answer
\IfRestatementTF{<true>}{<false>}
will leave<true>
when it's used in a restatement, and<false>
otherwise. Be careful to only use it inthmtools
-defined theorems, since its implementation is not so robust.