尝试构建以下内容会导致 pdflatex 挂起并一遍又一遍地构建文件:
% !TEX options=--shell-escape
\documentclass{article}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{tikzscale}
\usepgfplotslibrary{external}
% \tikzexternalize % !!! B
\pgfplotsset{compat=1.16}
\begin{document}
\begin{filecontents}[overwrite]{tex-stackexchange.tikz}
\begin{tikzpicture}
[trim axis left, trim axis right] % !!! A
\begin{axis}[
width=\textwidth,
height=0.25\textwidth,
xmin=0, xmax=5, ymin=0, ymax=5]
\addplot coordinates { (1,1) (2,3) (3,2) (4.5,4) };
\end{axis}
\end{tikzpicture}
\end{filecontents}
\begin{figure}
\includegraphics[width=\textwidth]{tex-stackexchange.tikz}
\end{figure}
This is a lot of text. This is a lot of text. This is a lot of text.
This is a lot of text. This is a lot of text. This is a lot of text.
This is a lot of text. This is a lot of text. This is a lot of text.
\end{document}
注释掉标记的行!!! A
可以使所有内容正确呈现,但没有外部化:
注释掉标记的行!!! B
使得外部化看起来有效,但现在绘图的宽度是错误的。
注释掉任何内容都不会导致 pdflatex 挂起。
这个问题可能看起来相关,但是:
- 要求获得的行为不是使用
trim axis
- 没有得到关于
externalize
标题的答案
答案1
据我所知,你只需要使用该mode=list and make
选项。当然,你还需要执行 make 文件,提示符会告诉你在你的机器上要做什么(希望如此;-)。
\documentclass{article}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{tikzscale}
\usepgfplotslibrary{external}
\tikzexternalize[mode=list and make] % !!! B
\pgfplotsset{compat=1.16}
\begin{document}
\begin{filecontents}[overwrite]{tex-stackexchange.tikz}
\begin{tikzpicture}
[trim axis left, trim axis right] % !!! A
\begin{axis}[
width=\textwidth,
height=0.25\textwidth,
xmin=0, xmax=5, ymin=0, ymax=5]
\addplot coordinates { (1,1) (2,3) (3,2) (4.5,4) };
\end{axis}
\end{tikzpicture}
\end{filecontents}
\begin{figure}
\includegraphics[width=\textwidth]{tex-stackexchange.tikz}
\end{figure}
This is a lot of text. This is a lot of text. This is a lot of text.
This is a lot of text. This is a lot of text. This is a lot of text.
This is a lot of text. This is a lot of text. This is a lot of text.
\end{document}