Preprocess a .tex file and save it as a new file












0















I have several .tex files that I would like to share with other people. I've included in them (with the command input) several files with macros that I've written myself. However, I would like to send only a self-contained .tex file.



What I need to do is generating another .tex file where the input command is replaced with the content of the file, pretty much like you would do by calling just the preprocessor in C.



I guess this could be done (relatively) easily with a bit of scripting, but I would like to know if there were a builtin option in a LaTeX compiler.










share|improve this question




















  • 2





    no (there are existing answers on site about this) latex never holds the source in memory or constructs the combined file.

    – David Carlisle
    Mar 9 at 10:40











  • @DavidCarlisle so you're saying that I have to do it by myself?

    – Mauro F.
    Mar 9 at 10:41











  • tex.stackexchange.com/questions/474203/… tex.stackexchange.com/questions/25713/… tex.stackexchange.com/questions/184152/… etc

    – David Carlisle
    Mar 9 at 10:42






  • 1





    I'm saying latex won't do it, but there are lots of tools that do (or claim to do) this for you. (it is trivial to write a few lines of perl to do this on any normal document, writing a general tool that gets it right on any document and copes with the string input in verbatim or comments etc is trickier but usually not needed)

    – David Carlisle
    Mar 9 at 10:44
















0















I have several .tex files that I would like to share with other people. I've included in them (with the command input) several files with macros that I've written myself. However, I would like to send only a self-contained .tex file.



What I need to do is generating another .tex file where the input command is replaced with the content of the file, pretty much like you would do by calling just the preprocessor in C.



I guess this could be done (relatively) easily with a bit of scripting, but I would like to know if there were a builtin option in a LaTeX compiler.










share|improve this question




















  • 2





    no (there are existing answers on site about this) latex never holds the source in memory or constructs the combined file.

    – David Carlisle
    Mar 9 at 10:40











  • @DavidCarlisle so you're saying that I have to do it by myself?

    – Mauro F.
    Mar 9 at 10:41











  • tex.stackexchange.com/questions/474203/… tex.stackexchange.com/questions/25713/… tex.stackexchange.com/questions/184152/… etc

    – David Carlisle
    Mar 9 at 10:42






  • 1





    I'm saying latex won't do it, but there are lots of tools that do (or claim to do) this for you. (it is trivial to write a few lines of perl to do this on any normal document, writing a general tool that gets it right on any document and copes with the string input in verbatim or comments etc is trickier but usually not needed)

    – David Carlisle
    Mar 9 at 10:44














0












0








0








I have several .tex files that I would like to share with other people. I've included in them (with the command input) several files with macros that I've written myself. However, I would like to send only a self-contained .tex file.



What I need to do is generating another .tex file where the input command is replaced with the content of the file, pretty much like you would do by calling just the preprocessor in C.



I guess this could be done (relatively) easily with a bit of scripting, but I would like to know if there were a builtin option in a LaTeX compiler.










share|improve this question
















I have several .tex files that I would like to share with other people. I've included in them (with the command input) several files with macros that I've written myself. However, I would like to send only a self-contained .tex file.



What I need to do is generating another .tex file where the input command is replaced with the content of the file, pretty much like you would do by calling just the preprocessor in C.



I guess this could be done (relatively) easily with a bit of scripting, but I would like to know if there were a builtin option in a LaTeX compiler.







macros input include






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 10:40









JouleV

6,21121650




6,21121650










asked Mar 9 at 10:33









Mauro F.Mauro F.

1




1








  • 2





    no (there are existing answers on site about this) latex never holds the source in memory or constructs the combined file.

    – David Carlisle
    Mar 9 at 10:40











  • @DavidCarlisle so you're saying that I have to do it by myself?

    – Mauro F.
    Mar 9 at 10:41











  • tex.stackexchange.com/questions/474203/… tex.stackexchange.com/questions/25713/… tex.stackexchange.com/questions/184152/… etc

    – David Carlisle
    Mar 9 at 10:42






  • 1





    I'm saying latex won't do it, but there are lots of tools that do (or claim to do) this for you. (it is trivial to write a few lines of perl to do this on any normal document, writing a general tool that gets it right on any document and copes with the string input in verbatim or comments etc is trickier but usually not needed)

    – David Carlisle
    Mar 9 at 10:44














  • 2





    no (there are existing answers on site about this) latex never holds the source in memory or constructs the combined file.

    – David Carlisle
    Mar 9 at 10:40











  • @DavidCarlisle so you're saying that I have to do it by myself?

    – Mauro F.
    Mar 9 at 10:41











  • tex.stackexchange.com/questions/474203/… tex.stackexchange.com/questions/25713/… tex.stackexchange.com/questions/184152/… etc

    – David Carlisle
    Mar 9 at 10:42






  • 1





    I'm saying latex won't do it, but there are lots of tools that do (or claim to do) this for you. (it is trivial to write a few lines of perl to do this on any normal document, writing a general tool that gets it right on any document and copes with the string input in verbatim or comments etc is trickier but usually not needed)

    – David Carlisle
    Mar 9 at 10:44








2




2





no (there are existing answers on site about this) latex never holds the source in memory or constructs the combined file.

– David Carlisle
Mar 9 at 10:40





no (there are existing answers on site about this) latex never holds the source in memory or constructs the combined file.

– David Carlisle
Mar 9 at 10:40













@DavidCarlisle so you're saying that I have to do it by myself?

– Mauro F.
Mar 9 at 10:41





@DavidCarlisle so you're saying that I have to do it by myself?

– Mauro F.
Mar 9 at 10:41













tex.stackexchange.com/questions/474203/… tex.stackexchange.com/questions/25713/… tex.stackexchange.com/questions/184152/… etc

– David Carlisle
Mar 9 at 10:42





tex.stackexchange.com/questions/474203/… tex.stackexchange.com/questions/25713/… tex.stackexchange.com/questions/184152/… etc

– David Carlisle
Mar 9 at 10:42




1




1





I'm saying latex won't do it, but there are lots of tools that do (or claim to do) this for you. (it is trivial to write a few lines of perl to do this on any normal document, writing a general tool that gets it right on any document and copes with the string input in verbatim or comments etc is trickier but usually not needed)

– David Carlisle
Mar 9 at 10:44





I'm saying latex won't do it, but there are lots of tools that do (or claim to do) this for you. (it is trivial to write a few lines of perl to do this on any normal document, writing a general tool that gets it right on any document and copes with the string input in verbatim or comments etc is trickier but usually not needed)

– David Carlisle
Mar 9 at 10:44










0






active

oldest

votes











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%2f478562%2fpreprocess-a-tex-file-and-save-it-as-a-new-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f478562%2fpreprocess-a-tex-file-and-save-it-as-a-new-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

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?