I have a main LaTeX file which \input{} (aka imports) many other LaTeX files.

For example:


Let's call the above file say main.tex. I want a single LaTeX file, which imports contents from input1.tex,input2.tex, input3.tex and input4.tex, so that I have only one single LaTeX file instead of the above four LaTeX files.

How do I go about writing a bash-script which does this job for me?

PS: I need to submit an article to a journal and I thought it would be good to have a single .tex file.

The issue is the following: I have different files in sub-directories in a recursive manner and hence I cannot upload these individual files since the directory structure in the input command is on the local folder on my computer.

I could of course put these manually but I thought if there would be a way out similar to the .bbl file for the bibliography.


This solution should work.

perl latexpand main.tex > newarticle.tex
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy