TikZ:图像是最新的。错误:(文件)(pdf 后端):内部错误:未知图像类型

TikZ:图像是最新的。错误:(文件)(pdf 后端):内部错误:未知图像类型

什么原因导致以下错误?

===== 图像“rect.tikz”是最新的。 ====== ./rect.tikz:3:错误:(文件 rect.tikz)(pdf 后端):内部错误:未知图像类型 ./rect.tikz:3:==> 发生致命错误,未生成输出 PDF 文件!

\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}

相关内容