I seem to be having difficulty preventing my document from overwriting \doublespacing commands. I have a document using a subfiles structure (a Main.tex) that calls a number of subfile .tex's for each chapter of the document, each of which begin something like:






Each subfile that requires double spacing sets \doublespacing rather than setting it once in Main.tex, so as not to affect the various single-spaced lists of symbols, acronyms, etc, that are subfile'd in Main.tex prior to the main chapters.

However, something appears to be overwriting each chapter's internal \doublespacing command, as everything is single spaced when Main.tex is pdflatex'd. Of course, the individual subfiles have the correct double spacing when compiled. This only occurred after an update to MikTex, and it did not happen before. So my thought is that a newer version of a certain package is interfering with either subfiles or setspace, but am unsure where it's happening. I hesitate to include my preamble, as it's a custom .cls used by Main.tex that I made, with a very large number of packages. Is this a simple fix?

EDIT: so I've stripped everything away in the pre-amble, yet it still doesn't work. I have two files, in totality:

% Main.tex





% Subfile #X





My older version of MikTex didn't ignore the \doublespacing within the subfile. Can I change this somehow?

  • By very large number of packages, what sort of number? Might be best to create a new subfile and main.tex that doesn't call any package i.e. no commands or settings, include your custom .cls and then comment out half of the packages, if the error goes away keep reducing the amount of packages you comment out until you find the one causing the issue. Not an expert but I am certain it would be very difficult to diagnose your issue without more details or what packages have been updated, so trial and error it with the comments and locate the specific package first so someone can help better.
    – user245306
    Commented Aug 28, 2021 at 0:18
  • 1
    I've stripped it down to the minimal subfile configuration, as above in the edit, with no luck still. This must be a change in the default behavior of either setspace or subfiles, then.
    – Jerome
    Commented Aug 28, 2021 at 0:51

2 Answers 2


I don't know if it's a recent change, but subfiles' documentation suggests this is by design.

Now there are two possibilities.

  • If LaTeX is run on the subfile, the line \documentclass[..]{subfiles} is replaced by the preamble of the main file (including its \documentclass command). The rest of the subfile is processed normally.

  • If LaTeX is run on the main file, the subfile is loaded like with an \input command, except that the preamble of the subfile up to \begin{document} as well as \end{document} and the lines following it are ignored.

How much beyond \doublespacing do you have in your subfiles' preambles? If it's just the \doublespacing command, can you define a command like \newcommand[1]{\doublespacedfile}{\begingroup\doublespacing\subfile{#1}\endgroup}? And then indicate in your main.tex which files should be doublespaced by choice of \subfile or \doublespacedfile?

  • 1
    Ah, I found the answer in the documentation, it was a recent change! And it can be reverted with an additional option. I'll post an answer for archival purposes, but thanks for pointing me in the right direction!
    – Jerome
    Commented Aug 28, 2021 at 5:30

I found the answer in the documentation of subfiles:

   For reasons of compatibility, the option v1 restores the behaviour of previous[v1]


This will have three effects.
   Code after the end of the main document is added to the preamble of the sub-
files, but is ignored when typesetting the main file. Here, one can add commands
that are to be processed as part of the preamble when the subfiles are typeset on
their one. But this also means that any syntax error after \end{document} will
ruin the LATEXing of the subfile(s).
   Code in the preamble of a subfile is processed as part of the text when typeset-
ting the main file, but as part of the preamble when typesetting the subfile. This
means that with the option v1, the preamble of a subfile can only contain stuff
that is acceptable for both, the preamble and the text area. One should also keep
in mind that each subfile is input within a group, so definitions made here may
not work outside.

This was changed in November 2020.

You must log in to answer this question.

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