When inputting two sub-files to a main LaTex-file by the "input" or "include" command, I encountered some problems. I will describe my problems through a series of questions as follows (PS: I apologize if the following questions have already been addressed.):

1, Should I use the package "standalone" when I use the "input" command? When I tried to compile my main tex-file containing "input" command I found that it is necessary to use the the package "standalone" for compiling the main tex-file successfully. I wonder whether the "input" command can be used in a main tex-file unconditionally.

2, Is it necessary to put the two sub-tex-files (i.e., file1.tex and file2.tex) in the folder where the main tex-file is situated? That is to say, can sub-tex-files and main tex-file be placed in separate folders?

3, Should I load all packages needed for all sub−files into preamble of the main tex-file?

4, When using \input{my tree diagram}, with two blanks in the file name, in the main tex-file, the compiler does not work. I change the file name without any blanks, and then the main tex-file can be compiled successfully. My computer system is OS X, and my TeX editor is Sublime Text 3 + LatexTools. Are there any good ways to solve this "blank interrupting" problem?

Any suggestions and comments are appreciated. Thank you.


1 Answer 1


It is best to ask one question per post but

(1) No, \input is a basic latex command unrelated to standalone or any other package.

(2) No, you can put them anywhere on the input path or use \input{path/to/folderwith/file1} or whatever you need

(3) Yes

(4) By far the best way is not to put spaces in filenames but if you really must then \input{"my tree document"} will work.

  • I set up two folders: one contains the sub-tex-file ( say Treediagram1.tex), another contains the main tex-file. On the one hand, when I use the "input" command in the main tex-file without loading "standalone" package, the tex editor does not work with the error message: LaTeX Error: File `Treediagram1.tex' not found. On the other hand, if I put the sub-file Treediagram1.tex into the folder of main tex-file then it can be successful to compile the main tex-file with using the "input" command.
    – GL_n
    Nov 11, 2016 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .