1

I want to include a figure containing an electrical circuit in my file. To ensure the correct filesize I use tikzscale includegraphics command. However, this yields an error for some of the elements in my figure. Is there a way to fix it?

Consider the following 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}

The error message is:

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.

And the output looks like this: MWE

2
  • Don't break a line in the middle of a keyword. (Why this causes a problem is another matter.) – John Kormylo Jul 25 '17 at 13:40
  • @JohnKormylo Wow, thats it. I feel incredibly stupid right now :D Thanks a lot and feel free to post it as an answer, so that I can accept it. – Paul Paulsen Jul 25 '17 at 13:42
1

Evidently tikzscale is more sensitive to line breaks than \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}

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.