I am following this very good answer that explains how to draw on an image with TikZ. Now I tried to implement this new tikz picture I got with Tikz library external but I get the error

Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e rror -interaction=batchmode -jobname "tikz/myTikzFileName" did NOT result in a usable output file 'tikz/myTikzFileName' (expected one of .pdf:.jpg:.jpeg:.png:).

I have been working for the last time on a project with ~20 figures, all made with tikz and pgfplots, and the externalization commands worked perfect, up until now when I inserted a png file into tikz.

The graphics I want to insert into my document is the file myGraphics.tikz,

% myGraphics.tikz
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{some-image.png}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
        \draw[red,ultra thick,rounded corners] (0.62,0.65) rectangle (0.78,0.75);

implemented with the tikzscale package:

% main.tex
%% To reduce compilation time


\begin{frame}{Lorem Ipsum}{dolor sit amet}
Some text


I do get a non empty md5 file, but nothing more.

Do anyone know how to fix this?

(some-image.png is this image)

  • works fine for me on a current texlive. Are you sure that you tried with this example? The error message indicates a subfolder, but your prefix has no slash. Jun 8 '21 at 16:46
  • @UlrikeFischer You are right, I changed the question.
    – tush
    Jun 8 '21 at 16:59

enter image description here

I see two possible problems in creating your output file:

  • the use of \includegraphics to invoke the .tikz file; it should rather be something like \input (see @sheß answer)
  • maybe you don't use --shell-escape option when running the document; you need something like pdflatex -synctex=1 -interaction=nonstopmode --shell-escape main.tex.

I insert the code below, but the important parts of it are borrowed from sheß's answer.

The code

\usepackage{tikz, tikzscale}

%% To reduce compilation time



  \caption{Boletus nubes}

  • Thanks a lot! What about image size specification? can I define it using \input{___.tikz} ?
    – tush
    Jun 14 '21 at 16:19
  • You can introduce a variable, something like \newcommand{myWidth}{0.5} in the main.tex and use it in myGraphics.tikz in \includegraphics[width=\myWidth\textwidth]{mushrooms.png}. But it is not very clear for me how it really works: if the value is changed, there is no effect unless I delete manually the file tikzmyGraphics.pdf that was previously created. At least this is how it works for me.
    – Daniel N
    Jun 15 '21 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.