Restate theorem in separate file












8















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}









share|improve this question

























  • Yes, there is, but I don't know how.

    – JPi
    Oct 11 '16 at 2:27











  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

    – Peter Grill
    Oct 11 '16 at 5:37











  • @PeterGrill Thank you. I've added a MWE. The line that fails to compile is the call to thmcmd* on the appendix file.

    – Rui
    Oct 11 '16 at 11:23






  • 1





    If the goal is to produce a PDF file just containing the appendix, surely there are easier ways (e.g. produce the full PDF file and then extract the relevant pages). This doesn't invalidate your question, but just to say that there are work arounds.

    – Willie Wong
    Oct 12 '16 at 5:32
















8















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}









share|improve this question

























  • Yes, there is, but I don't know how.

    – JPi
    Oct 11 '16 at 2:27











  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

    – Peter Grill
    Oct 11 '16 at 5:37











  • @PeterGrill Thank you. I've added a MWE. The line that fails to compile is the call to thmcmd* on the appendix file.

    – Rui
    Oct 11 '16 at 11:23






  • 1





    If the goal is to produce a PDF file just containing the appendix, surely there are easier ways (e.g. produce the full PDF file and then extract the relevant pages). This doesn't invalidate your question, but just to say that there are work arounds.

    – Willie Wong
    Oct 12 '16 at 5:32














8












8








8








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}









share|improve this question
















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}






cross-referencing theorems thmtools xr






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 12 '16 at 4:39







Rui

















asked Oct 11 '16 at 1:52









RuiRui

554




554













  • Yes, there is, but I don't know how.

    – JPi
    Oct 11 '16 at 2:27











  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

    – Peter Grill
    Oct 11 '16 at 5:37











  • @PeterGrill Thank you. I've added a MWE. The line that fails to compile is the call to thmcmd* on the appendix file.

    – Rui
    Oct 11 '16 at 11:23






  • 1





    If the goal is to produce a PDF file just containing the appendix, surely there are easier ways (e.g. produce the full PDF file and then extract the relevant pages). This doesn't invalidate your question, but just to say that there are work arounds.

    – Willie Wong
    Oct 12 '16 at 5:32



















  • Yes, there is, but I don't know how.

    – JPi
    Oct 11 '16 at 2:27











  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

    – Peter Grill
    Oct 11 '16 at 5:37











  • @PeterGrill Thank you. I've added a MWE. The line that fails to compile is the call to thmcmd* on the appendix file.

    – Rui
    Oct 11 '16 at 11:23






  • 1





    If the goal is to produce a PDF file just containing the appendix, surely there are easier ways (e.g. produce the full PDF file and then extract the relevant pages). This doesn't invalidate your question, but just to say that there are work arounds.

    – Willie Wong
    Oct 12 '16 at 5:32

















Yes, there is, but I don't know how.

– JPi
Oct 11 '16 at 2:27





Yes, there is, but I don't know how.

– JPi
Oct 11 '16 at 2:27













Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

– Peter Grill
Oct 11 '16 at 5:37





Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

– Peter Grill
Oct 11 '16 at 5:37













@PeterGrill Thank you. I've added a MWE. The line that fails to compile is the call to thmcmd* on the appendix file.

– Rui
Oct 11 '16 at 11:23





@PeterGrill Thank you. I've added a MWE. The line that fails to compile is the call to thmcmd* on the appendix file.

– Rui
Oct 11 '16 at 11:23




1




1





If the goal is to produce a PDF file just containing the appendix, surely there are easier ways (e.g. produce the full PDF file and then extract the relevant pages). This doesn't invalidate your question, but just to say that there are work arounds.

– Willie Wong
Oct 12 '16 at 5:32





If the goal is to produce a PDF file just containing the appendix, surely there are easier ways (e.g. produce the full PDF file and then extract the relevant pages). This doesn't invalidate your question, but just to say that there are work arounds.

– Willie Wong
Oct 12 '16 at 5:32










1 Answer
1






active

oldest

votes


















1














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.



enter image description here



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={stringproof{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 theoremend{theorem}

begin{theorem}
This is the second theorem
tcblower
This is the proof of the second theoremend{theorem}

begin{theorem}
This is the third theorem
tcblower
This is the proof of the third theoremend{theorem}

begin{theorem}
This is the fourth theorem
tcblower
This is the proof of the fourth theoremend{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:



enter image description here



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:



enter image description here






share|improve this answer


























  • Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

    – Rui
    Oct 11 '16 at 11:34











  • @Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

    – Ignasi
    Oct 11 '16 at 11:42











  • fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

    – Rui
    Oct 12 '16 at 0:36











  • @Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

    – Ignasi
    Oct 12 '16 at 21:21











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f333596%2frestate-theorem-in-separate-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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.



enter image description here



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={stringproof{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 theoremend{theorem}

begin{theorem}
This is the second theorem
tcblower
This is the proof of the second theoremend{theorem}

begin{theorem}
This is the third theorem
tcblower
This is the proof of the third theoremend{theorem}

begin{theorem}
This is the fourth theorem
tcblower
This is the proof of the fourth theoremend{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:



enter image description here



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:



enter image description here






share|improve this answer


























  • Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

    – Rui
    Oct 11 '16 at 11:34











  • @Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

    – Ignasi
    Oct 11 '16 at 11:42











  • fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

    – Rui
    Oct 12 '16 at 0:36











  • @Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

    – Ignasi
    Oct 12 '16 at 21:21
















1














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.



enter image description here



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={stringproof{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 theoremend{theorem}

begin{theorem}
This is the second theorem
tcblower
This is the proof of the second theoremend{theorem}

begin{theorem}
This is the third theorem
tcblower
This is the proof of the third theoremend{theorem}

begin{theorem}
This is the fourth theorem
tcblower
This is the proof of the fourth theoremend{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:



enter image description here



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:



enter image description here






share|improve this answer


























  • Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

    – Rui
    Oct 11 '16 at 11:34











  • @Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

    – Ignasi
    Oct 11 '16 at 11:42











  • fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

    – Rui
    Oct 12 '16 at 0:36











  • @Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

    – Ignasi
    Oct 12 '16 at 21:21














1












1








1







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.



enter image description here



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={stringproof{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 theoremend{theorem}

begin{theorem}
This is the second theorem
tcblower
This is the proof of the second theoremend{theorem}

begin{theorem}
This is the third theorem
tcblower
This is the proof of the third theoremend{theorem}

begin{theorem}
This is the fourth theorem
tcblower
This is the proof of the fourth theoremend{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:



enter image description here



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:



enter image description here






share|improve this answer















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.



enter image description here



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={stringproof{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 theoremend{theorem}

begin{theorem}
This is the second theorem
tcblower
This is the proof of the second theoremend{theorem}

begin{theorem}
This is the third theorem
tcblower
This is the proof of the third theoremend{theorem}

begin{theorem}
This is the fourth theorem
tcblower
This is the proof of the fourth theoremend{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:



enter image description here



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:



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 13 '17 at 12:34









Community

1




1










answered Oct 11 '16 at 7:01









IgnasiIgnasi

93.7k4169311




93.7k4169311













  • Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

    – Rui
    Oct 11 '16 at 11:34











  • @Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

    – Ignasi
    Oct 11 '16 at 11:42











  • fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

    – Rui
    Oct 12 '16 at 0:36











  • @Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

    – Ignasi
    Oct 12 '16 at 21:21



















  • Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

    – Rui
    Oct 11 '16 at 11:34











  • @Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

    – Ignasi
    Oct 11 '16 at 11:42











  • fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

    – Rui
    Oct 12 '16 at 0:36











  • @Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

    – Ignasi
    Oct 12 '16 at 21:21

















Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

– Rui
Oct 11 '16 at 11:34





Unfortunately, it seems that this does not keep the numbering according to the original file, which is one of the main purposes of "restatable". Is it possible to do so?

– Rui
Oct 11 '16 at 11:34













@Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

– Ignasi
Oct 11 '16 at 11:42





@Rui. This is just a little example to show that tcolorbox provides these tools for saving ans reusing contents. In any case I think that the second link in my answer (which has been taken from chapter 8) shows that it's possible to save original numbers.

– Ignasi
Oct 11 '16 at 11:42













fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

– Rui
Oct 12 '16 at 0:36





fair enough. Does this package allow one to have an "invisible" box. As in, having the theorem statement and proof not in a box but according to the style of the document (say, the style guidelines of a particular journal)?

– Rui
Oct 12 '16 at 0:36













@Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

– Ignasi
Oct 12 '16 at 21:21





@Rui I've updated the answer with an example using invisible tcolorboxes and two different files. Theorems and proofs can be printed in second file while keeping original enumeration. Hope it helps. You still will have to adapt theorem and proof format to your taste.

– Ignasi
Oct 12 '16 at 21:21


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f333596%2frestate-theorem-in-separate-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents