1

As far as I understand the subfiles for use in the subfiles package should all end with \end{document}, so that they can be built independently. However, I'm finding that, in order for each of my subfiles to be included in the output of my main.tex file, I need to delete the \end{document} line. I'm using TeXstudio.

My main file looks like this:

\documentclass{book}
\usepackage{expl3}
\usepackage{subfiles}
\begin{document}
    \subfile{title}
    \subfile{introduction}
\end{document}

If the subfiles look like this:

\documentclass[main]{subfiles}
\begin{document}
    title content OR introduction content
\end{document}

then I get only the content of the first subfile (title.tex) in main.pdf, even if the content is as simple as just the word 'content'. If they look like this instead:

\documentclass[main]{subfiles}
\begin{document}
    content

then I get the content of both.

3
  • 1
    Welcome to TeX.SX! My guess is that the cause of your problem is a version mismatch: a new subfiles package (v2.2) with an old LaTeX (older than Oct 2020), or the other way around. You find the version numbers in the log file. I see there preloaded format=pdflatex 2021.4.16 and subfiles 2020/11/14 v2.2.
    – gernot
    Jul 13, 2021 at 15:48
  • Thank you! I had a look and my pdflatex version is 2019.1.4, which would presumably be the problem.
    – Ben
    Jul 15, 2021 at 10:14
  • After fully updating MiKTeX it's all working now, so it definitely was a version mismatch.
    – Ben
    Jul 15, 2021 at 11:26

1 Answer 1

3

The observed behavior may arise from a version mismatch: a new subfiles package (v2.2) with an old LaTeX (older than Oct 2020), or the other way around. You find the version numbers in the log file. I see there preloaded format=pdflatex 2021.4.16 and subfiles 2020/11/14 v2.2.

Best use the package manager of your distribution to update all formats and packages.

You must log in to answer this question.

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