Latex、TikZ 以及章节和图的单独编译
我有相当大的 Latex 文档,里面有很多 TikZ 图形。我有频繁重新编译的习惯,使用 pdflatex 编译它需要很长时间。 TikZ 中的人物占据了大部分时间。
我的问题是,将文档拆分为单独的 tex 文件(图/章节)以实现图和章节的单独编译、单独的章节 pdf 和整个文档 pdf 文件的最佳方法是什么?
I have fairly large Latex document with a lot of TikZ figures inside. I have a habit of frequent recompilation and it takes forever to compile it using pdflatex. Figures in TikZ take most of the time.
My question is what is the best way to split the document into separate tex files (figures/chapters) to achieve separate compilation of figures and chapters, separate chapter pdfs, and a whole document pdf file ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否尝试过单独编译每张图片,然后将它们作为 pdf 而不是 tikz 代码包含在您的 tex 文件中?您可以使用文档类
standalone
,以便图片达到您需要的确切尺寸。所以:这样做的好处是,您可以直接包含编译此文档以获取要包含在文档中的 pdf 图,也可以使用命令 \input 通过添加将其作为 tikz 代码包含在主文档中
在您的主文档中(以及 tikz 包和库),然后
Have you tried compiling each picture on its own and then including them in your tex file as pdf rather than the tikz code? You can use the document class
standalone
so that the picture will be the exact size you need. So :The good thing about this is that you can either include the compile this document directly to get a pdf figure to include in your document, or you can use the command \input to include it in your main document as a tikz code by adding
in your main document (together with the tikz packages and libraries), and then
有一种可能更好的方法(恕我直言)来缓存 tikz-图片。将以下行添加到您的
序言:
pdflatex 运行后,您将看到子目录 ./i 中的所有图片。
如果您更新 tikz 图片的代码,只需丢弃其相应的 pdf 文件即可重新生成。有关详细信息,请参阅 PFG/TikZ 手册第 32.4 节外部化图形
可能还有32.5 在未安装 pgf 的情况下使用外部显卡。
There is a possibly better way (imho) to cache tikz-pictures. Add the following lines in your
preamble:
After a pdflatex-run you'll see all pictures in the subdirectory ./i .
If you update the code of a tikz-picture simply throw away its corresponding pdf-file and it will be regenerated. For more info see the manual of PFG/TikZ section 32.4 Externalizing Graphics
and possibly 32.5 Using External Graphics Without pgf Installed.
将每个章节放入单独的文件中,然后使用
\include
将它们放入某个主文件中怎么样?然后,您可以使用\includeonly
来仅编译您当前正在处理的章节。这至少应该节省一些时间。我预计某种基于 makefile 的解决方案会比这更好,但我对 makefile 一无所知......
How about putting each chapter in a separate file and then using
\include
to put them into some master file? Then you can use\includeonly
to only compile the chapter you're currently working on. That should save some time at least.I expect some sort of makefile based solution would be even better than this, but I don't know anything about makefiles...
我通常这样做的方法是将 Latex 应用于文件的一部分:Emacs 和其他几个 Latex 编辑器允许您编译区域:使用 Auctex,您可以运行 TeX-pin-region 来指定当前章节,然后运行 TeX- command-region 在选定区域上运行 Latex。
传统的方法是将大文件的一部分切成
\include
d 的较小部分,然后注释掉您不想处理的部分,或者在文件中添加一些宏。每个文件的开头和结尾,允许单独编译它们。The way I generally do this is to apply Latex to just part of the file: Emacs and several other Latex editors allow you to compiler regions: with Auctex, you can run TeX-pin-region to specify the current chapter, and then TeX-command-region to run Latex on the selected region.
The traditional way to do this is cut parts of the big file into smaller parts that are
\include
d, and then either comment out parts you don't want to work on, or put some macrology at the beginning and end of each file that allows them to be compiled separately.