在-output-directory中使用run时,我在外部化tikz图形时遇到了问题。虽然在我期望的位置创建了.md5文件,但创建外部化图片文件(.pdf、.log、.dpth)的命令失败了。我的假设是,发生这种情况是因为用于创建这些文件的pdflatex没有继承-output-directory选项,因此无法在正确的位置创建文件。
这是一个显示行为的最小示例。
main.tex:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
\begin{document}
Test externalize in combination with -output-directory
\tikzsetnextfilename{testpicture}
\begin{tikzpicture}
\node {Node};
\end{tikzpicture}
\end{document}bash:
mkdir -p build/tikz
pdflatex -output-directory build -shell-escape main.tex错误:
===== 'mode=convert with system call': Invoking 'pdflatex
-shell-escape -halt-on-error -interaction=batchmode -jobname
"tikz/testpicture" "\def\tikzexternalrealjob{main}\input{main}"'
======== This is pdfTeX, Version 3.14159265-2.6-1.40.16
(TeX Live 2015/Debian) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
! I can't write on file `tikz/testpicture.log'.结果目录结构(tree的输出):
.
├── build
│ ├── main.aux
│ ├── main.auxlock
│ ├── main.log
│ ├── main.pdf
│ └── tikz
│ └── testpicture.md5
└── main.tex同样,据我所知,日志文件创建失败是由于外部化执行的pdflatex命令的工作目录中缺少tikz目录。
我的假设是正确的吗?如果是,我应该如何处理?
发布于 2016-11-25 04:24:26
据我所知,最简单的解决方案是在您的主文件夹中创建一个指向build中tikz文件夹的符号链接。像这样:ln -s build/tikz .
这是我在another tikz externalizing library文档中找到的解决方案。
发布于 2018-07-30 13:19:42
tikzexternal不会检测到-output-directory参数。
这也适用于包含图像的情况。您必须在此处的图像前面加上输出目录的路径。
这两点可以在以下MWE中看到:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
\makeatletter
\tikzset{%
external/system call={%
pdflatex %
\tikzexternalcheckshellescape %
-halt-on-error %
-interaction=batchmode %
-output-directory="build" %
-jobname "\image" %
"\texsource"%
},
/pgf/images/include external/.code={%
\includegraphics{build/#1}%
},%
}
\makeatother
\begin{document}
Test externalize in combination with -output-directory
\tikzsetnextfilename{testpicture}
\begin{tikzpicture}
\node {Node};
\end{tikzpicture}
\end{document}一些额外的注意事项:
你可以在pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
"\string\def\string\tikzexternalrealjob{\tikzexternal@realjob}\string\input{path/to/tex/file/\tikzexternal@realjob}",你必须用
"\texsource"编辑
这将在\tikzexternalcheckshellescape中结束。
对于使用LuaLaTeX的两种方法(原始方法和较短的方法),您都需要\usepackage{shellesc}。
发布于 2017-03-05 05:47:30
这也可能是关于权限的问题。尝试使用
chmod 777 tikz就在你创建文件夹之后。
您还可以尝试将main.tex文件移动到build文件夹中,看看这样做是否会有所改变。
https://stackoverflow.com/questions/40768426
复制相似问题