如何在這樣的配置中外部化 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"}}
但是,如果再次在該 tikzset 字串中指定--output-directory ./out
,編譯將中止並出現以下錯誤:
! error: (file picturrre.pdf) (pdf backend): cannot find image file 'picturrre.pdf'
似乎帶有 tikzpicture 的全新 pdf 預計將位於專案根目錄 中,.
但./out
除了 .md5、.log 等之外,它還駐留在其中。因此,有兩種選擇:一種應該從 tikzset 字串中刪除輸出目錄,或寫入\tikzexternalize[prefix=out/]
.
第二個變體導致 tikz 外部化的 pdf 影像及其衛星轉到./out/out
dir,但它們預計位於./out
,並且出現以下錯誤:
! error: (file out/picturrre.pdf) (pdf backend): cannot find image file 'out/picturrre.pdf'
因此,我們嘗試--output-directory ./out
從 tikzset 字串中刪除,同時保留 tikz 前綴為out/
。它會導致 tikz 外部化的 pdf 圖像及其合作夥伴轉到./out
dir,所有其他垃圾都位於該目錄,但您仍然需要./out/out
dir,因為 .md5 檔案會轉到那裡(它們的路徑是./output-dir/externalize-prefix
,但其他檔案只會轉到./externalize-prefix
dir)。該文檔編譯完美。
然而,如果與 tikz/pgf 一起使用gnuplot
,.gnuplot 和 .table 檔案將轉到專案根目錄,因為--output-directory
tikzset 字串中省略了參數,因此不可能將 gnuplot 垃圾./out
也轉移到 dir (但如果實際上可以,他會寫
\pgfkeys{/pgf/plot/gnuplot call={cd out && gnuplot}}
之後\begin{document}
強制 gnuplot 自動搜尋 .gnuplot 檔案)。