Generating a single LaTeX file by merging different LaTeX files

5,995

This solution should work.

perl latexpand main.tex > newarticle.tex
Share:
5,995

Related videos on Youtube

Kevin Bowen
Author by

Kevin Bowen

I route the packets that make the Internet sing. Contributor to Xfce Desktop Environment(DE) documentation: https://docs.xfce.org I have been a casual Linux user since Slackware 3.0 (Hello Walnut Creek!) and an Ubuntu user since around version 6.06 or 6.10. My primary professional skill set has been focused on the design, implementation, operation, and daily management of enterprise networks. This includes the configuration and operation of network hardware as well as the care and feeding involved in the network monitoring systems supporting them. The hardware includes routers, switches, firewalls, wan-optimizers, and occasionally load balancers (mostly Cisco, Riverbed, and f5 systems).  Launchpad  twitter

Updated on September 18, 2022

Comments

  • Kevin Bowen
    Kevin Bowen almost 2 years

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

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

  • MERose
    MERose over 3 years
    The answer isn't complete, I believe, because an installation (or sth.) is missing. I get Can't open perl script "latexpand": No such file or directory
  • grantbow
    grantbow over 3 years
    You can install from ctan.org/pkg/latexpand.