Insert contents from an external text file into a latex file

Naseef Ummer picture Naseef Ummer · Mar 11, 2018 · Viewed 10k times · Source

I have a text file in the working directory of a latex document. I have created sections in the latex document. I would like to insert the contents of the text file in latex.

My reason for doing so is to simply the latex file into simple parts so that it is not over crowded. The text file may contain equations as well.

There is a verbatim package but I am not able to install it via the package manager in Miktex. I tried to install it via mpm --install verbatim in the command line but it cannot find the package.

I am not sure if that is the right way. I hope someone can guide me in the right direction.

Answer

Naseef Ummer picture Naseef Ummer · Nov 30, 2018

I am writing this answer with the help of comment from NickD.

  1. In the same working folder create a separate file foo.tex
  2. In the main file, where you need it imported, type in the code \include{foo}

After compiling it, you should be able to see the imported contents from foo.tex