可能的子文件/setspace 问题

可能的子文件/setspace 问题

我似乎很难阻止我的文档覆盖 \doublespacing 命令。我有一个使用子文件结构(Main.tex)的文档,它为文档的每一章调用多个子文件 .tex,每个子文件都以类似以下内容开头:

\documentclass[Main.tex]{subfiles}

\doublespacing

\begin{document}

 ...

\end{document}

每个需要双倍行距的子文件都会设置 \doublespacing,而不是在 Main.tex 中设置一次,以免影响在主要章节之前在 Main.tex 中子文件中列出的各种单倍行距的符号、首字母缩略词等列表。

然而,似乎有一些东西覆盖了每个章节的内部 \doublespacing 命令,因为一切当 Main.tex 被 pdflatex 化时是单倍行距。当然,编译时各个子文件具有正确的双倍行距。这只发生在 MikTex 更新之后,之前没有发生过。所以我的想法是某个软件包的较新版本干扰了子文件或 setspace,但不确定它发生在哪里。我犹豫是否要包含我的前言,因为它是我制作的 Main.tex 使用的自定义 .cls,其中包含大量软件包。这是一个简单的修复吗?

编辑:我删除了序言中的所有内容,但它仍然不起作用。我总共有两个文件:

% Main.tex
\documentclass{article}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{subfiles}

\begin{document}

\subfile{testsub.tex}
\newpage

\end{document}

% Subfile #X
\documentclass[Main.tex]{subfiles}

\doublespacing

\begin{document}

\section{Introduction}
\lipsum

\end{document}

我的旧版 MikTex 不会忽略子文件中的 \doublespacing。我能以某种方式改变这种情况吗?

答案1

我不知道这是否是最近的变化,但subfiles文献表明这是设计使然。

现在有两种可能性。

  • 如果在子文件上运行 LaTeX,则该行将\documentclass[..]{subfiles}被主文件的前言(包括其\documentclass命令)替换。子文件的其余部分将正常处理。

  • 如果在主文件上运行 LaTeX,则子文件将像使用\input命令一样加载,除了子文件的前言\begin{document}以及\end{document}其后的行被忽略之外。

您的子文件前言中还有多少内容\doublespacing?如果只是命令\doublespacing,您可以定义类似这样的命令 吗?然后通过选择或\newcommand[1]{\doublespacedfile}{\begingroup\doublespacing\subfile{#1}\endgroup}来指示哪些文件应该双倍行距?main.tex\subfile\doublespacedfile

答案2

我在子文件的文档中找到了答案:

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

\usepackage[v1]{subfiles}

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.

这一情况于 2020 年 11 月发生了改变。

相关内容