pdflatex 不允许我从另一个目录启用系统调用

pdflatex 不允许我从另一个目录启用系统调用

我正在尝试将文件中的图保存到单独的 PDF 中。我的文件名my_file.tex位于/full/path/to/my/file

这是my_file.tex

\documentclass[11pt]{article}                                                    
\usepackage{tikz}                                                                
\usetikzlibrary{external}                                                        
\usepackage{pgfplots}                                                            
                                                                                 
\tikzexternalize                                                                 
                                                                                 
\begin{document}                                                                 
\begin{figure}[h]                                                                
    \centering                                                                   
    \begin{tikzpicture}                                                          
        \begin{axis} []                                                          
        \end{axis}                                                               
    \end{tikzpicture}                                                            
\end{figure}                                                                     
\end{document}

如果我位于同一目录中,my_file.txt我可以轻松获得我想要的行为:

pdflatex -shell-escape my_file

问题是,当我想从不同的文件夹编译我的文档时,/different/path/它不起作用:

pdflatex -shell-escape /full/path/to/my/file/my_file

我得到:

===== 'mode=convert with system call': Invoking 'pdflatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "bvcocc-figure0" "\def\tikzexternalreal
job{bvcocc}\input{bvcocc}"' ========
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/Arch Linux) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
system returned with code 256

! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "bvcocc-figure0" "\def\tikzexternalrealjob
{bvcocc}\input{bvcocc}"' did NOT result in a usable output file 'bvcocc-figure0
' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled 
system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is a
lso named 'write 18' or something like that. Or maybe the command simply failed
? Error messages can be found in 'bvcocc-figure0.log'. If you continue now, I'l
l try to typeset the picture.

See the tikz package documentation for explanation.

答案1

更新获取图形的正确文件名,例如 myfile-figure0.pdf

初始设置(Windows 操作系统树)

b

myfile.tex并在其自己的目录中进行适当的配置。

%%%% file myfile.tex

\documentclass[11pt]{article}                                                    
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{tikz}

\usetikzlibrary{external}
\tikzexternalize[%
up to date check={simple},
prefix=./different/tikzfiles/]% Folder needs to be created before compiling

\tikzset{external/system call={%
        pdflatex \tikzexternalcheckshellescape
        -halt-on-error -shell-escape -interaction=batchmode -output-directory=./different/ 
        -jobname "\image" "\texsource"}}              

\begin{document}                                                                 
    \begin{figure}[h]                                                                
        \centering                                                                   
        \begin{tikzpicture}                                                          
            \begin{axis} []                                                          
            \end{axis}                                                               
        \end{tikzpicture}                                                            
    \end{figure}                                                                     
\end{document}

从空的命令提示符运行WorkingDirectory。注意使用选项指向输出目录-output-directory=。所有中间文件和最终文件都将存放在那里。

pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=./different/ ./different/myfile.tex

平方厘米

要得到

自动对焦

相关内容