“tikzscale”和 tikz“circuits”库之间不兼容

“tikzscale”和 tikz“circuits”库之间不兼容

我想在我的文件中包括一张包含电路的图形。为了确保文件大小正确,我使用了 tikzscaleincludegraphics命令。但是,这会导致图形中的某些元素出现错误。有办法修复它吗?

考虑以下 MWE:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\usepackage{tikzscale}
\usepackage{filecontents}

\begin{filecontents}{figure1.tikz}
\begin{tikzpicture}[circuit ee IEC,set inductor graphic = var inductor IEC
graphic]
\draw (0,0) to[inductor] (2,0) to[voltage source] (4,0);
\end{tikzpicture}
\end{filecontents}

\begin{document}
\input{figure1.tikz} % Works fine
\bigskip
\includegraphics{figure1.tikz} % Breaks the inductor

\end{document}

错误信息是:

pdflatex> ! Package pgfkeys Error: I do not know the key '/tikz/var inductor IECgraphic' 
pdflatex> and I am going to ignore it. Perhaps you misspelled it.
pdflatex> 
pdflatex> See the pgfkeys package documentation for explanation.
pdflatex> Type  H <return>  for immediate help.

输出如下: 平均能量损失

答案1

显然 tikzscale 对换行符比 更敏感\input

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\usepackage{tikzscale}
\usepackage{filecontents}

\begin{filecontents}{figure1.tikz}
\begin{tikzpicture}[circuit ee IEC,set inductor graphic = var inductor IEC graphic]
\draw (0,0) to[inductor] (2,0) to[voltage source] (4,0);
\end{tikzpicture}
\end{filecontents}

\begin{document}
\input{figure1.tikz} % Works fine
\bigskip
\includegraphics{figure1.tikz} % Breaks the inductor

\end{document}

相关内容