在这样的配置中,如何外部化 TikZ?这是我的 MWE:
序言.tex:
\documentclass[a4paper, 10pt]{article}
\usepackage[left=30mm, right=10mm, top=15mm, bottom=25mm]{geometry}
\usepackage[english, russian]{babel}
\usepackage{amsmath, amssymb, mathrsfs, bm}
\usepackage{indentfirst, graphicx}
\usepackage[labelsep = period]{caption}
\usepackage[labelformat=simple]{subcaption}
\endofdump
文档.tex:
\endofdump
\usepackage{fontspec}
\setmainfont{FreeSerif}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{pgfplots.external}
\tikzset{external/system call={lualatex -fmt=preamble.fmt \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzexternalize
\begin{document}
lorem ipsum $x^2 + y^2 = 4$
\tikzsetnextfilename{picturrre}
\begin{tikzpicture}
\draw (0, 0) -- (2, 2);
\end{tikzpicture}
\end{document}
命令行:
luatex -ini -jobname="preamble" "&lualatex" mylatexformat.ltx preamble.tex
lualatex --shell-escape -synctex=1 -interaction=nonstopmode --fmt preamble --output-directory ./out "document".tex
错误信息:document.log(摘录):
...
\openout3 = picturrre.md5
\openout3 = document.auxlock
===== 'mode=convert with system call': Invoking 'lualatex -fmt=preamble.fmt -she
ll-escape -halt-on-error -interaction=batchmode -jobname "picturrre" "\def\tikze
xternalrealjob{document}\input{document}"' ========
\openout3 = document.auxlock
! Package tikz Error: Sorry, the system call 'lualatex -fmt=preamble.fmt -shell
-escape -halt-on-error -interaction=batchmode -jobname "picturrre" "\def\tikzex
ternalrealjob{document}\input{document}"' did NOT result in a usable output fil
e 'picturrre' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you h
ave enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Somet
imes it is also named 'write 18' or something like that. Or maybe the command s
imply failed? Error messages can be found in 'picturrre.log'. If you continue n
ow, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.29 \end{tikzpicture}
This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.
...
picturrre.log(完整):
This is LuaTeX, Version 1.0.4 (TeX Live 2017/Debian) (format=preamble 2019.12.3) 3 DEC 2019 12:54
system commands enabled.
**\def\tikzexternalrealjob{document}\input{document}
Lua module: luaotfload-main 2017/01/29 2.80001 OpenType layout system.
Lua module: lualibs 2017-02-01 2.5 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2017-02-01 2.5 ConTeXt Lua libraries -- extended collection.(using write cache: /home/cloun/.texlive2017/texmf-var/luatex-cache/generic)(using read cache: /var/lib/texmf/luatex-cache/generic /home/cloun/.texlive2017/texmf-var/luatex-cache/generic)
luaotfload | conf : Root cache directory is /home/cloun/.texlive2017/texmf-var/luatex-cache/generic/names.
luaotfload | init : Loading fontloader “fontloader-2017-02-11.lua” from kpse-resolved path “/usr/share/texlive/texmf-dist/tex/luatex/luaotfload/fontloader-2017-02-11.lua”.
Lua-only attribute luaotfload@state = 5
Lua-only attribute luaotfload@noligature = 6
Lua-only attribute luaotfload@syllabe = 7
luaotfload | init : Context OpenType loader version “3.027”
Inserting `luaotfload.node_processor' at position 1 in `pre_linebreak_filter'.
Inserting `luaotfload.node_processor' at position 1 in `hpack_filter'.
Inserting `luaotfload.define_font' at position 1 in `define_font'.
Lua-only attribute luaotfload_color_attribute = 8
luaotfload | conf : Root cache directory is /home/cloun/.texlive2017/texmf-var/luatex-cache/generic/names.
Inserting `luaotfload.aux.set_sscale_dimens' at position 1 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.patch_cambria_domh' at position 2 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.fixup_fontdata' at position 1 in `luaotfload.patch_font_unsafe'.
Inserting `luaotfload.aux.set_capheight' at position 3 in `luaotfload.patch_font'.
Inserting `luaotfload.rewrite_fontname' at position 4 in `luaotfload.patch_font'.
luaotfload | main : initialization completed in 0.094 seconds
==============================================================================
JOB NAME : "picturrre"
CUSTOMISED FORMAT: "preamble"
PRELOADED FILES:
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
geometry.sty 2010/09/12 v5.6 Page Geometry
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
ifpdf.sty 2017/03/15 v3.2 Provides the ifpdf switch
ifvtex.sty 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
babel.sty 2018/02/14 3.18 The Babel package
english.ldf 2017/06/06 v3.3r English support from the babel system
russianb.ldf
amsmath.sty 2017/09/02 v2.17a AMS math features
amstext.sty 2000/06/29 v2.01 AMS text
amsgen.sty 1999/11/30 v2.0 generic functions
amsbsy.sty 1999/11/29 v1.2d Bold Symbols
amsopn.sty 2016/03/08 v2.02 operator names
amssymb.sty 2013/01/14 v3.01 AMS font symbols
amsfonts.sty 2013/01/14 v3.01 Basic AMSFonts support
mathrsfs.sty 1996/01/01 Math RSFS package v1.0 (jk)
bm.sty 2017/01/16 v1.2c Bold Symbol Support (DPC/FMi)
indentfirst.sty 1995/11/23 v1.03 Indent first paragraph (DPC)
graphicx.sty 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
trig.sty 2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg 2016/06/04 v1.11 sample graphics configuration
luatex.def 2018/01/08 v1.0l Graphics/color driver for luatex
caption.sty 2016/02/21 v3.3-144 Customizing captions (AR)
caption3.sty 2016/05/22 v1.7-166 caption3 kernel (AR)
subcaption.sty 2016/05/22 v1.1-161 Sub-captions (AR)
umsa.fd 2013/01/14 v3.01 AMS symbols A
umsb.fd 2013/01/14 v3.01 AMS symbols B
ursfs.fd 1998/03/24 rsfs font definition file (jk)
==============================================================================
! Emergency stop.
<*> ...\tikzexternalrealjob{document}\input{document}
Here is how much of LuaTeX's memory you used:
6 strings out of 490450
100000,154059 words of node,token memory allocated
469 words of node memory still in use:
6 hlist, 2 vlist, 2 rule, 1 dir, 5 glue, 1 kern, 6 attribute, 49 glue_spec, 6
attribute_list, 1 write nodes
avail lists: 2:14,3:1,4:2,5:9,7:1,8:2
7965 multiletter control sequences out of 65536+600000
57 fonts using 4052259 bytes
9i,0n,26p,0b,31s stack positions out of 5000i,500n,10000p,200000b,100000s
! ==> Fatal error occurred, no output PDF file produced!
这些错误信息没有任何帮助,我找不到我遗漏的内容,希望你能帮忙。
答案1
我准备了 MWE 来说明问题本身,但我会更深入地探讨答案,以提供一些启发。
首先,document.tex
使用 来编译预编译的前言--output-directory ./out
,这会导致将其相关的垃圾lualatex
转移到目录中,即项目根目录。document
./out
.
从现象学上来说,必须使用 \endofdump
再次指令当他调用外部 tikz 系统调用时,相应的字符串变为
\tikzset{external/system call={lualatex --shell-escape --fmt preamble --halt-on-error --output-directory ./out -jobname "\image" "\endofdump\texsource"}}
但是,如果--output-directory ./out
再次指定该 tikzset 字符串,则编译将中止并出现以下错误:
! error: (file picturrre.pdf) (pdf backend): cannot find image file 'picturrre.pdf'
似乎带有 tikzpicture 的全新 pdf 应该位于项目根目录,.
但它驻留在./out
其 .md5、.log 等文件内。因此,有两种选择:一种应该从 tikzset 字符串中删除输出目录,或者写入\tikzexternalize[prefix=out/]
。
第二种变体导致 tikz-externalized pdf 图像及其卫星进入./out/out
目录,但它们预计在./out
,并且出现以下错误:
! error: (file out/picturrre.pdf) (pdf backend): cannot find image file 'out/picturrre.pdf'
因此,我们尝试--output-directory ./out
从 tikzset 字符串中删除,同时保留 tikz 前缀为out/
。它会导致 tikz-externalized pdf 图像及其合作伙伴进入./out
dir,所有其他垃圾都位于该目录中,但您仍然需要./out/out
dir,因为 .md5 文件会进入那里(它们的路径是./output-dir/externalize-prefix
,但其他文件只会进入./externalize-prefix
dir)。该文档编译完美。
但是,如果使用gnuplot
tikz/pgf,.gnuplot 和 .table 文件将转到项目根目录,因为--output-directory
tikzset 字符串中省略了参数,因此无法将 gnuplot 垃圾转移到./out
目录中(但如果真的可以的话,他会写
\pgfkeys{/pgf/plot/gnuplot call={cd out && gnuplot}}
之后\begin{document}
强制 gnuplot 自动搜索 .gnuplot 文件)。