Is there any way that I can add different .tex files (From different folders) into another folder's .tex file?

I meant that all of the .tex files will be fine and separated and I just need to aggregate into one without copy & pasting these files into a single one.

enter image description here

I have saved the input file like this, but it's not working when I write in another file, like enter image description here


It's still not working. :-(

  • combine documentclass can do it. – ernesto Jul 9 '13 at 8:40
  • For a good specific answer simple MWE might help. For eg: What would be the absolute/relative paths of child1.tex,child2.tex files with respect to master.tex ? What is the preamble in child.tex files and are they self-compilable with their own \documentclass{} ? TeX UK faq website has some excellent information on it – texenthusiast Jul 9 '13 at 10:23
  • Please post the contents of the oscillonsource.tex file and of the file in which you want to include oscillonsource.tex – Red Jul 9 '13 at 11:09
  • @compex-guy If you use \input{}, you could write path to the file, e.g., if you have your tex file in the forder WORK, but there are subfolders CH1, CH2, etc., use \input{CH1/sec1.tex} and so on! Cheers. – Dox Jul 9 '13 at 13:38
  • \input{oscillon130613/oscillonsource.tex} I inserted the above one, but didn't work. My file name is oscillon13061 and tex file name is oscillonsource.tex. – Complex Guy Jul 9 '13 at 15:45

Here is a complete example of the input/include command at work:

The example consists of 3 files in a folder structure as follows:

[Parent Folder]
 +-- file1.tex
 +-- fig.jpg
 +-- [folder]

fig.jpg is just an ordinary jpg image file. The contents of file1.tex are as follows:


Note the inclusion of the (relative) path as well as the filename of file2.tex.

The contents of file2.tex are


Note that file2.tex does not have its own preamble, document class, \begin{document} etc.

Think of \input as having a similar effect to you manually copying and pasting whatever is in file2.tex into file1.tex: no need to include anything you wouldn't want to copy in this fashion. Following through this copying/pasting logic: note also that the path to fig.jpg needs to be relative to file1.tex, not file2.tex. Since fig.jpg is in the same folder as file1.tex this means that we don't have to specify any path.

Saving this file/folder structure and compiling file1.tex results in a document with fig.jpg included in it.

  • If I want to open the tex file, then I need to open three folders, my tex file name is oscillonsource.tex and it is placed on the last opened folder, oscillon130613 . – Complex Guy Jul 9 '13 at 15:42
  • \date{July 07, 2013} \begin{document} \baselineskip=16pt \input{oscillon130613/oscillonsource.tex} \end{document} But didn't work. – Complex Guy Jul 9 '13 at 15:43
  • I think problem is in my input cause when I insert it, then the tex file is not running. – Complex Guy Jul 9 '13 at 15:55

Yes, the \include{<filename>} command inserts the file after a page break. If you don't want the page break, use \input{<filename>}. The major reason you would want to use \include rather than \input is the \includeonly command, which can save compilation time when writing your document.

  • a tex file name "oscillon source.tex" and I have write in another file like this \include{<oscillon source.tex>} , but didn't work. Do I need to insert these file in thje same folder. ? – Complex Guy Jul 9 '13 at 8:52
  • 1
    You don't need the angle brackets (they're just to indicate it's a placeholder), and you don't need the extension: use \include{oscillon source} – ChrisS Jul 9 '13 at 8:54
  • 2
    Don't use filenames with spaces with \include... – karlkoeller Jul 9 '13 at 8:55
  • I wrote \include{oscillon source} and the file opened but cant see any element of that file in the new file :-( – Complex Guy Jul 9 '13 at 9:01
  • 2
    @ComplexGuy: we are plainly not understanding what you have written. rename "oscillon source.tex" as "oscillon-source.tex", and write a latex file that's as small as possible, and shows the error: that way ("minimal example") we see what your problem is, not your description of your problem. – wasteofspace Jul 9 '13 at 10:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.