0

What causes the following error?

===== Image 'rect.tikz' is up-to-date. ====== ./rect.tikz:3: error: (file rect.tikz) (pdf backend): internal error: unknown image type ./rect.tikz:3: ==> Fatal error occurred, no output PDF file produced!

\documentclass[
addpoints,
]{exam}

\begin{filecontents}[overwrite]{rect.tikz} \begin{tikzpicture}[x=1em, y=1em,blue] \draw (0,0) rectangle node{Diaa} (4,4); \end{tikzpicture} \end{filecontents}

\usepackage{catchfile,lipsum,graphbox,array,ragged2e,booktabs,fmtcount,multicol,multirow,calc,tikz,calc,mathtools,tikzscale,lua-ul,enumitem,xfrac,siunitx,comment,matlab-prettifier,atveryend,pdfpages,afterpage,lastpage,longtable,pgfmath,xfp,ifthen}

% https://topanswers.xyz/tex?q=1562#a1814 \makeatletter \def\tikz@external@watch@store@aux#1#2{% \immediate\write@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/external/watch/stored/#1\string\endcsname{#2}}}% \def\tikz@external@watch@get@from@aux#1#2{% \ifcsname pgfk@/tikz/external/watch/stored/#1\endcsname \edef#2{\csname pgfk@/tikz/external/watch/stored/#1\endcsname}% \else \edef#2{0}% \fi} \tikzset{external/watch/.cd,store/.code 2 args={% \tikz@external@watch@store@aux{#1}{#2}}, get/.code 2 args={\tikz@external@watch@get@from@aux{#1}{#2}}, font size/.code={\tikzset{external/watch/get={font size}{\pgfutil@tempa}, external/watch/store={font size}{\f@size}}% \unless\ifnum\pgfutil@tempa=\f@size \tikzset{/tikz/external/force remake}% \fi }} \makeatother

\usetikzlibrary{external} % https://tex.stackexchange.com/a/482560/2288 % https://topanswers.xyz/transcript?room=1605&id=85129#c85129 \newcommand{\inputtikz}[1]{% \tikzset{external/export=true}% \tikzsetnextfilename{#1}% \input{#1}% \tikzset{external/export=false}% }

\usepackage[xparse,breakable,raster,skins]{tcolorbox}% xparse,breakable \tcbset{shield externalize} \tcbuselibrary{fitting}

\setlength{\parindent}{0cm}

\tikzexternalize \begin{document} % https://topanswers.xyz/transcript?room=1605&id=85129#c85129 \tikzset{external/.cd, watch/font size, export = false}

\inputtikz{rect.tikz}

\end{document}

Diaa
  • 9,599
  • Name the PDF to be produced by rect.tikz, call it, say, myrect and add a second parameter to your macro. rect.tikz is the name of the text file containing the code for the tikz picture. Name the PDF with \tikzsetnextfilename{#2} (if you make the PDF name the second parameter. Then your macro call becomes \inputtikz{rect.tikz}{myrect}. – Cicada Dec 23 '20 at 07:51
  • @Cicada You are right. Additionally, I found that spaces in names make error. Do you have any idea how to make the following work with spaces: \NewDocumentCommand{\inputtikz}{ m m }{% \tikzset{external/export=true}% \tikzsetnextfilename{#2}% \input{#1}% \tikzset{external/export=false}% } with \inputtikz{{"the rect"}.tikz}{{"my rect"}}? – Diaa Dec 23 '20 at 08:23
  • \inputtikz{"b rect.tikz"}{myrect} works for me (Windows). Ask a separate question to get a proper answer for your setup. No-one will look under errors tikz-external for a space-in-filename question buried in the comments. – Cicada Dec 23 '20 at 10:11
  • Possibly related to the secondary question: https://tex.stackexchange.com/questions/180554/how-i-can-use-iffileexistfilename-with-spaces-in-filename – Cicada Dec 23 '20 at 10:18
  • @Cicada Ulrike spoke the truth here https://chat.stackexchange.com/transcript/message/56527285#56527285 – Diaa Dec 23 '20 at 11:06
  • For reference, Ulrike's comment on the chat link is: "@Diaa file names with spaces works ok in simple conditions like inputting a graphic or a file. But you should use them in complicate setups e.g. where external tools are called, only if you, and I mean you, are willing to spent a lot time to get the quoting right. This kind of stuff breaks if there are not enough and too much quotes, and if the chain is longer every step must be adjusted to the previous. " – Cicada Dec 24 '20 at 00:15

0 Answers0