# TikZ/PGF: I can't find file tikzlibrarycircuit.code.tex' error

I am trying to use the circuit library from TikZ/PGF 2.1, but get the following error when I call LaTeX:

("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\frontendlayer\tikz\tikz.code.tex"
Package: tikz 2010/10/13 v2.10 (rcs-revision 1.76)

("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\libraries\pgflibraryplothandlers.code.tex"
File: pgflibraryplothandlers.code.tex 2010/05/31 v2.10 (rcs-revision 1.15)
\pgf@plot@mark@count=\count90
\pgfplotmarksize=\dimen140
)
\tikz@lastx=\dimen141
\tikz@lasty=\dimen142
\tikz@lastxsaved=\dimen143
\tikz@lastysaved=\dimen144
\tikzleveldistance=\dimen145
\tikzsiblingdistance=\dimen146
\tikz@figbox=\box33
\tikz@tempbox=\box34
\tikztreelevel=\count91
\tikznumberofchildren=\count92
\tikznumberofcurrentchild=\count93
\tikz@fig@count=\count94

("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\modules\pgfmodulematrix.code.tex"
File: pgfmodulematrix.code.tex 2010/08/24  (rcs-revision 1.4)
\pgfmatrixcurrentrow=\count95
\pgfmatrixcurrentcolumn=\count96
\pgf@matrix@numberofcolumns=\count97
)
\tikz@expandcount=\count98

("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\frontendlayer\tikz\libraries\tikzlibrarytopaths.code.tex"
File: tikzlibrarytopaths.code.tex 2008/06/17 v2.10 (rcs-revision 1.2)
)))
("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\frontendlayer\tikz\libraries\circuits\tikzlibrarycircuits.code.tex"
("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\frontendlayer\tikz\libraries\tikzlibrarydecorations.markings.code.tex"
("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\frontendlayer\tikz\libraries\tikzlibrarydecorations.code.tex"
("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\modules\pgfmoduledecorations.code.tex"
\pgfdecoratedcompleteddistance=\dimen147
\pgfdecoratedremainingdistance=\dimen148
\pgfdecoratedinputsegmentcompleteddistance=\dimen149
\pgfdecoratedinputsegmentremainingdistance=\dimen150
\pgf@decorate@distancetomove=\dimen151
\pgf@decorate@repeatstate=\count99
\pgfdecorationsegmentamplitude=\dimen152
\pgfdecorationsegmentlength=\dimen153
)
\tikz@lib@dec@box=\box35
)
("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\libraries\decorations\pgflibrarydecorations.markings.code.tex"))
("C:\Documents and Settings\s0237326\Application Data\MiKTeX\2.9\tex\generic\pg
f\frontendlayer\tikz\libraries\tikzlibrarycalc.code.tex"
File: tikzlibrarycalc.code.tex 2009/09/04 v2.10 (rcs-revision 1.6)
)
\tikz@lib@circ@count=\count100
\tikzcircuitssizeunit=\dimen154
)
("C:\Documents and Settings\s0237326\My Documents\LaTeX\tikz_circuit_error.aux"
)
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
ABD: EveryShipout initializing macros

! I can't find file tikzlibrarycircuit.code.tex'.
<argument> ...nput tikzlibrary\pgf@temp .code.tex
\catcode \@ =\csname tikz...
l.227 ....misc,calc,positioning,plotmarks,circuit}

Please type another input file name
! Emergency stop.
<argument> ...nput tikzlibrary\pgf@temp .code.tex
\catcode \@ =\csname tikz...
l.227 ....misc,calc,positioning,plotmarks,circuit}

*** (job aborted, file error in nonstop mode)


I am using MiKTeX 2.9 on Windows XP.

Now a file called tikzlibrarycircuits.code.tex is present in the C:\Documents and Settings\User\Application Data\MiKTeX\2.9\tex\generic\pgf\frontendlayer\tikz\libraries\circuits directory (rather than the tikzlibrarycircuit.code.tex with no s mentioned in the error). Removing the s in the file name results in the same error, so I don't think LaTeX is looking in the right directory. I also don't know how you get to see what directory LaTeX actually looked in as the command is truncated as above.

Is this an error in tikz, and how can I fix it?

# Update #

Below is a minimal example demonstrating the error:

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{circuit}

\begin{document}
\begin{tikzpicture}[circuit ee IEC, scale=1.2]
\draw (0,0) to [diode] (0,2)
\end{tikzpicture}

\end{document}


Replacing \usetikzlibrary{circuit} with \usetikzlibrary{circuits} results in the following output:

! Package pgfkeys Error: I do not know the key '/tikz/circuit ee IEC' and I am
going to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
...

l.7 \begin{tikzpicture}[circuit ee IEC, scale=1.2]

This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.

! Package pgfkeys Error: I do not know the key '/tikz/diode' and I am going to
ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
...

l.8         \draw (0,0) to [diode] (0,2)
;
(That was another \errmessage.)

[1]
("C:\Documents and Settings\s0237326\My Documents\LaTeX\tikz_circuit_error.aux"
) )

-
It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. – Thorsten May 6 '11 at 11:36
ok, will bear in mind – crobar May 6 '11 at 11:38
When you say "removing the s in the file name ..." do you mean that you change the filename on the disk or do you change the word circuit to circuits in the \usetikzlibrary in the document? – Loop Space May 6 '11 at 11:41
Actuall, I've done both, but above I have the word 'circuit' in the \usetikzlibrary command, and tried changing the filename on disk to 'tikzlibrarycircuit.code.tex'. If I use 'circuits' in \usetikzlibrary no attempt is made to load the library and I get error relating to unknown commands like resistor etc. – crobar May 6 '11 at 11:49
@Martin: To avoid that you confuse a miktex user: The equivalent to ls-R files in TeXLive are the "FNDB"s (file name data bases) in miktex. They are not updated through the package manager but in the "option manager" MikTeX Settings. Depending on the root for which you want to update the database you will have to use either the admin or the user version of MikTeX Setting. – Ulrike Fischer May 6 '11 at 12:13

I strongly suspect that you are loading the wrong TikZ library for what you intend to do.

Here's a fairly minimal working example of the circuits library from TikZ (basically copied from the manual and made in to a complete document). Try running this and see if you still get errors. In particular, note the name of the library being loaded.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0,0) to [diode={light emitting}] (3,0)
;
\end{tikzpicture}
\end{document}


Result:

-
Your example works, with the crucial difference being \usetikzlibrary{circuits.ee.IEC} rather than \ustikzlibrary{circuits}. – crobar May 6 '11 at 12:16
@crobar: Exactly so. I'll admit that it is a little confusing - as you can guess from my comments on your original question then it took me two goes to get the right library! The PGF manual also seems a little more geared to library writers than end users so it's an easy mistake to make. – Loop Space May 6 '11 at 12:23
Oh, and thanks for the help! – crobar May 6 '11 at 13:19

l.227 ....misc,calc,positioning,plotmarks,circuit}

I assume that is part of \usetikzlibrary{....misc,calc,positioning,plotmarks,circuit}. Please always add a minimal working example (MWE) that illustrates your problem, not just code snippets or error messages.

It should be circuits not circuit. Renamed the library file tikzlibrarycircuits.code.tex to tikzlibrarycircuit.code.tex manually is first of all a very bad idea and won't be noted by (La)TeX until you update the file name cache (a file called ls-R). (La)TeX doesn't search for the files directly because that would be to slow but uses such files instead. Modern version actually search the users TEXMF tree for this files in every run if no ls-R file is present there.

Simply changing circuit to circuits should fix this issue. If you can't change the code for any funny reason notify the original author. A workaround then would be to place a file called tikzlibrarycircuit.code.tex which simply hold the line \usetikzlibrary{circuits} in the same directory of your document or into your local TEXMF tree (there in a subdirectory tex/latex/pgf/).

-
I don't think this is the fix, I have added a minimal example (as I should have done) and output to show why. Thanks though. – crobar May 6 '11 at 12:07
actually, you are sort of right, sorry! – crobar May 6 '11 at 12:14