TikZ 库“外部”无法识别不同图片中的节点名称

TikZ 库“外部”无法识别不同图片中的节点名称

我正在尝试通过外部化 Ti 来缩短编译时间Z 图片。不过,我似乎能够引用命名节点。例如,考虑以下内容。

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{external}

\tikzexternalize

\begin{document}

\tikz \coordinate (A) at (0,0);
\tikz \coordinate [right=of A] (B);

\end{document}

当我尝试用编译它时pdflatex -shell-escape presention.tex,我收到消息

===== Image 'presentation-figure0' is up-to-date. ======
===== 'mode=convert with system call': Invoking 'pdflatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "presentation-figure1" "\def\tikzextern
alrealjob{presentation}\input{presentation}"' ========
\openout3 = `presentation.auxlock'.

runsystem(pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname
 "presentation-figure1" "\def\tikzexternalrealjob{presentation}\input{presentat
ion}")...executed.

\openout3 = `presentation.auxlock'.


! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "presentation-figure1" "\def\tikzexternalr
ealjob{presentation}\input{presentation}"' did NOT result in a usable output fi
le 'presentation-figure1' (expected one of .pdf:.jpg:.jpeg:.png:). Please verif
y that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-es
cape'. Sometimes it is also named 'write 18' or something like that. Or maybe t
he command simply failed? Error messages can be found in 'presentation-figure1.
log'. If you continue now, I'll try to typeset the picture.

presentation.log消息

! Package pgf Error: No shape named A is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.14     \tikz \coordinate [right=of A] (B);

在 中presentation-figure1.log。我尝试参考手册和互联网来找出问题所在,但毫无进展。我知道该external包无法轻松处理引用,但我找不到有关命名节点的任何信息。

注意命名节点在不同的 TiZ 图片,因为在我的真实代码中,我在整个文档的许多不同的图片中引用它们。

答案1

简短回答:使用“已知”技术无法做到这一点。要正确执行此操作,您需要将坐标位置保存到文件中,然后在编译开始时将其读回。

但是,如果坐标都是在文档开头的几个简单图片中定义的,则只需关闭这些图片的外部化,然后所有后续图片都可以使用这些坐标,无论是否外部化。

以下内容编译无错误,且第二张图片被外部化:

\documentclass{article}
%\url{http://tex.stackexchange.com/q/296865/86}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{external}

\tikzexternalize

\begin{document}

\tikzset{external/export next=false}
\tikz \coordinate (A) at (0,0);
\tikz \coordinate [right=of A] (B);

\end{document}

答案2

使用环境tikzpicture如果要外部化 Ti,Z图形并参考现有节点/坐标:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
Hi
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate [right=of A] (B);
\draw (A)--(B)--+(45:1);
\end{tikzpicture}
\end{document}

外化图像

相关内容