19

I am trying to use the \include command to import chapters into Latex. For some reason, Latex is completely ignoring files in the \include command. If I replace \include with \input they are included fine, why might this be? FOr information I am using TeXnicCenter on windows. It fails for both Latex and pdflatex.

\documentclass[10pt,twoside,openright]{report} 

\begin{document}

% Ignored
\include{./integrated_linear_generator_models.tex}

% Works
\input{./integrated_linear_generator_models.tex}

\end{document}
6
  • Have you tried taking the ./ out of the paths?
    – qubyte
    Nov 14, 2011 at 12:06
  • Did you try without the ./? I remember windows LaTeX sometimes being confused with the slash, backslash.
    – Andy
    Nov 14, 2011 at 12:08
  • Actually I've just discovered it works if I remove the '.tex' from the filename!! Is this how it's supposed to work?
    – crobar
    Nov 14, 2011 at 12:09
  • 2
    @crobar: Yes, the .tex is always optional but not allowed for \include. The reason is that it also creates a <name>.aux file and needs the name without extension for that. Nov 14, 2011 at 12:11
  • ok, I hadn't come across that in any of the places I'd found documentation on the \include command (first two results of google). Thanks, by the way.
    – crobar
    Nov 14, 2011 at 12:14

1 Answer 1

33

The issue is the .tex extension. It is always optional and will be added automatically. However, in the case of \include is is not be allowed. The reason is that it also creates a <name>.aux file and needs the name without extension for that. Otherwise it will create <name>.tex.aux and try to read `<name>.tex.tex, which causes the error.

You should also try to avoid the ./ which might cause also some issues and isn't required as well.

So simply use:

\include{integrated_linear_generator_models}
2
  • 1
    Registered to say thank you, Martin! Dec 8, 2019 at 18:25
  • Using vscode I had to go back and delete the temp files from when I include the .tex extension Apr 30, 2021 at 19:08

You must log in to answer this question.

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