如何在 LaTeX 中的 \include 之后没有分页符
我的 LaTeX 在每个小节之后都会分页,因为我的小节位于单独的文件中。 我使用命令 \include{file}
在使用后添加分页符。
我希望不会因使用 \include{file}
而导致分页。
使用 include
命令后如何不分页?
My LaTeX makes me pagebreaks after each subsection because my subsections are in separate files. I use the command \include{file}
which adds a pagebreak after the use of it.
I would like to have no pagebreak caused by the use of \include{file}
.
How can you no pagebreak after the use of include
-command?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Will Robertson 建议的 newinclude 包对于避免清除页面非常有用。 看来,为了让
\includeonly
工作,必须在\documentclass{...}
之后立即调用该包。 在我的论文的复杂环境中,我也遇到了参考文献损坏的问题。当最终版本不需要 includeonly 时,一个好的解决方法是仅在草稿中使用 include:
或
第一行可以轻松地由 makefile 附加,以制作草稿或生产版本的生产 make 目标。
\includeonly{file1,file2,...}
允许指定使用\include{file1}
调用的源文件列表(其中file1
是一个示例),它将显示在结果文档中。 其他的不会显示,但当包含相应的辅助文件时,会考虑将其用于计数器、标签、目录。换句话说,通过使用
include
和includeonly
可以在草稿中保持较短的编译时间,同时拥有正确的引用。进一步阅读维基教科书。
@Will Robertson
\include
非常有用,因为它允许通过\includeonly{...}
只构建需要的部分。 在处理较长的文本时,仅包含冗长章节的一部分可能会在编译时间上产生很大的差异。 它也非常有用,因为人们在工作时不必翻阅长草稿。 最后,较小的源代码文件更容易在版本管理中处理,例如 git。The newclude package suggested by Will Robertson is rather useful to avoid the clearpage. It appears, in order for
\includeonly
to work one has to call the package immediately after\documentclass{...}
. In the complex environment of my dissertation I also ran into problems with broken references.A good workaround, when includeonly is not needed for a final version, is to use includes only in the draft:
or
The first line can be easily appended by a makefile, to make draft or production version production make targets.
\includeonly{file1,file2,...}
allows to specify a list of source files called with\include{file1}
(wherefile1
is an example) that will show in the resulting document. The others will not show up, but are considered for counters, labels, tables of contents when the corresponding aux files are included.In other words, by using
include
andincludeonly
one can keep the compile time short in a draft while having correct references.Further reading on Wikibooks.
@Will Robertson
\include
is so useful because it allows through\includeonly{...}
to build only needed sections. While working on longer text it can make quite a difference in compile time to include only a section of a lengthy chapter. It is also invaluably useful as one doesn't have to page through a long draft while working at one point. Lastly, smaller files of source code are easier to handle in version management, e.g. git.\include
始终使用\clearpage
,这是一个不完全合理的默认值。 它适用于整个章节,而不是小节(为什么要将小节放在单独的文件中?)。您可以通过使用
\input{filename}
或加载newinclude
包并写入\include*{filename}
来修复此问题。\include
always uses\clearpage
, a not entirely sensible default. It is intended for entire chapters, not for subsections (why would you want subsections in separate files, anyway?).You can fix it either by using
\input{filename}
or loading thenewclude
package and writing\include*{filename}
instead.您可以通过在
\include
前面放置\let\clearpage\relax
来阻止由\include
引起的分页。 因此,会将三个文件(以及任何随后包含的文件)的内容放在一起,并且它们之间没有分页符。 如果您想停止放宽
\clearpage
命令,则将文件包装在不带分页符的组中,如下所示:这将停止 file1 和 file2 之间的分页符,但在 file2 之后插入正常分页符。 (注意:我不知道这是否会干扰引用和页码,尽管我认为应该没问题。)
You can stop pagebreaks caused by
\include
by placing\let\clearpage\relax
before it. So,would put the contents of the three files (and any subsequently included files) together without a pagebreak between them. If you want to stop relaxing the
\clearpage
command, then wrap the files to include without pagebreaks within a group like this:This will stop a pagebreak between file1 and file2, but insert the normal pagebreak after file2. (Note: I do not know if this interferes with referencing and page numbering, though I imagine it should be OK.)
以下内容在大多数情况下都是可靠的:
第一个 \cleardoublepage 确保您的章节最终位于双面的奇数页上。
\let\clearpage\relax 禁用由 \include 插入的clearpage
\begingroup \endgroup 确保范围仅限于 include。
The following is robust in most situations:
The first \cleardoublepage ensures that your chapter ends up on an odd page for 2-sided.
The \let\clearpage\relax disables clearpage inserted by \include
The \begingroup \endgroup makes sure that the scope is just that include.
谢谢您,剑桥!
Thank you, Cambridge!