每次使用 tikzscale 时,TikZ 图都会重新编译

每次使用 tikzscale 时,TikZ 图都会重新编译

对于我的论文我有很多 Ti使用该库从 Matlab 导出 Z 图matlab2tikz

我想将该tikzscale包与绘图外部化一起使用以节省编译时间。tikzscale文档中建议使用外部化,但效果不如预期。

\includegraphics通过使用包含的图表tikzscale在每次pdflatex运行时都会重新编译,即使图形没有改变,这也不是预期的行为,并会导致编译时间变得更长。

通过 包含的图表\input,因此不使用tikzscale,功能不会被重新编译,这正是我所期望的。

我在导出matlab2tikz或包含.tikz文件的过程中是否做错了什么,\includegraphics或者这是tikzscale软件包的一个错误?

我需要的附加缩放功能tikzscale,因此我不能简单地避开该tikzscale包。

设置:WIN7+TexLive2014 / Ubuntu 14.04+TexLive2013,两个系统上的行为相同

梅威瑟:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{pgfplots}
\usepackage{tikzscale} 
\usepgfplotslibrary{external} 
\tikzexternalize[prefix=tikzTest/] 
\newlength\figureheight 
\newlength\figurewidth

\begin{document}
\begin{figure}
\tikzsetnextfilename{test}
\includegraphics[width=0.75\textwidth]{tikzTest/test.tikz}
\end{figure}

\begin{figure}
\setlength\figureheight{0.75\textwidth} 
\setlength\figurewidth{0.75\textwidth}
\tikzsetnextfilename{test2}
\input{tikzTest/test2.tikz}
\end{figure}
\end{document}

Matlab 导出

x = linspace(0,10,11);
y = x.^2;
figure(1);
plot(x,y);
cleanfigure;
%prepare figure to be included with tikzscale and \includegraphics
matlab2tikz('<pathToTexFolder>\tikzTest\Test.tikz','noSize',true,'extraTikzpictureOptions','trim axis left, trim axis right');
%prepare figure to be included with \input
matlab2tikz('<pathToTexFolder>\tikzTest\Test2.tikz','height','\figureheight','width','\figurewidth');

test.tikz

% This file was created by matlab2tikz.
% Minimal pgfplots version: 1.3
%
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\begin{tikzpicture}[%
trim axis left, trim axis right
]

\begin{axis}[%
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0,
xmax=10,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
ymin=0,
ymax=100
]
\addplot [color=black,solid,forget plot]
  table[row sep=crcr]{%
0   0\\
1   1\\
2   4\\
3   9\\
4   16\\
5   25\\
6   36\\
7   49\\
8   64\\
9   81\\
10  100\\
};
\end{axis}
\end{tikzpicture}%

test2.tikz

% This file was created by matlab2tikz.
% Minimal pgfplots version: 1.3
%
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\begin{tikzpicture}

\begin{axis}[%
width=0.95092\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0,
xmax=10,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
ymin=0,
ymax=100
]
\addplot [color=black,solid,forget plot]
table[row sep=crcr]{%
0   0\\
1   1\\
2   4\\
3   9\\
4   16\\
5   25\\
6   36\\
7   49\\
8   64\\
9   81\\
10  100\\
};
\end{axis}
\end{tikzpicture}%

答案1

编辑:我刚刚意识到这个问题是两年前问的......

你试过使用 LuaLaTeX 吗tikzexternalcheckshellescape?我以前用过。

尝试使用上面的序言:

\documentclass[11pt]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzsetexternalprefix{figurescache/} %folder for temp figures
\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -shell-escape -synctex=1 -halt-on-error -jobname "\image" "\texsource"}}
\begin{document}
[Tikz stuff in here]
\end{document}

然后编译您的文档,输入:

lualatex filename.tex

此后,filename.makefile将创建一个文件名并输入

make -f filename.makefile

然后另一个

lualatex filename.tex

相关内容