Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a main LaTeX file which inputs many other LaTeX files i.e. for example

\documentclass{article}
\begin{document}
\input{input1.tex}
\input{./Input_folder_1/input2.tex}
\input{input3.tex}
\input{./Input_folder_2/Input_folder_3/input4.tex}
\end{document}

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 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.

share|improve this question
5  
You have many tools that seem to do what you want listed here: tex.stackexchange.com/questions/21838/… –  Salem May 25 '13 at 22:34

1 Answer 1

This solution should work.

perl latexpand main.tex > newarticle.tex
share|improve this answer
2  
@guntbert I don't believe this is a "thank you" answer as it is the only answer here. The comment it is referencing points to an answer on TeX - LaTeX so I think this is fine. (I'm guessing you posted that comment from review and couldn't see this things, one of review's failings, I guess) –  Seth yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.