# circuitikz and ConTeXT

I would like to use circuitikz with ConTeXT but I have an error message, ! Undefined control sequence.

My code is:

\usemodule[tikz]

\usemodule[circuitikz][european]

\starttext

\startcircuitikz

\draw (0,0) to[R, l=$R_1$] (2,0);

\stopcircuitikz

\stoptext


A solution is proposed in a circuitikz manual:

" In actually using CircuiTikZ with TikZ version 2 in ConTEXt an error comes up, saying something like

! Undefined control sequence. \tikz@cc@mid@checks -> \pgfutil@ifnextchar!

The solution has been suggested to me by Aditya Mahajan, and involves modifying a file in TikZ:

Here is the fix. In tikzlibrarycalc.code.tex change

\def\tikz@cc@mid@checks{
\pgfutil@ifnextchar !{%AM: Added space
\tikz@cc@mid%
}{%
\tikz@cc@parse% continue
}% }
\def\tikz@cc@mid !{%AM Added space
\pgfutil@ifnextchar({%
\tikz@scan@one@point\tikz@cc@project%
4
}{%
\tikz@cc@mid@num%
}%
} "


I need to modify a file in TikZ but I don't know where I can find this file and i don't understand what I need to change in this file.

Thank you for your help.

• It would be better to update your TeX distribution so that you are no longer using version 2 of TikZ. If I've understood what you are saying correctly. – cfr Jan 24 '16 at 20:38
• Not that it works with TikZ 3 either.... – cfr Jan 24 '16 at 20:51
• Please include a link to the source of the solution you mention. – cfr Jan 24 '16 at 21:11
• That code no longer appears to be present in the current version of the file. – cfr Jan 24 '16 at 21:15
• The basic problem is that tikz assumes that ! has catcode other, while ConTeXt is assuming that ! has catcode letter. You can grep the TikZ/circuitTikZ code base for pgfutil@ifnextchar! and replace that with pgfutil@ifnextchar ! (note additional space) – Aditya Jan 25 '16 at 18:14

As a workaround, you could just set the options you want individually, since european is simply a shorthand for a collection of such options. For example:

\usemodule[circuitikz]
\ctikzset{current=european, voltage=european, resistor=european, inductor=european}

\starttext

\starttikzpicture

\draw (0,0) to[R, l=$R_1$] (2,0);

\stoptikzpicture

\stoptext


• Sorry but when I try with your code, I have an error : "error on line 16 in file /usr/local/texlive/2014/texmf-dist/tex/circuittikz/t-circuittikz.tex: ! Missing \endcsname inserted" – Mecadict Jan 25 '16 at 22:00
• I'm using TeX Live 2015. I don't know if that is the difference, but the code works OK for me. Do you get an error with just my example? – cfr Jan 25 '16 at 23:42
• The code runs okay for me as well (latest context beta plus latest circuitikz downloaded from ctan). – Aditya Jan 26 '16 at 3:10
• I have updated my version of TexLive and now, the code runs okay. I didn't find the circuitTikZ code base in the precedent version of TexLive to modify the code as Aditya has suggested... Thank you very much for your help, my problem is solved. And sorry for my ignorance of ConTeXT : i'm a beginner ! ;) – Mecadict Jan 26 '16 at 17:15
• But I believe that there is others problems with photodiode for example. – Mecadict Jan 26 '16 at 17:31

Unfortunately, the circuitikz module does not acknowledge a plain european option. It rather takes a key=value list, akin to \ctikzset. Therefore, to obtain the european resistor, one has to pass resistor=european to the module. Also, you have to load the tikz module before circuitikz or the keys will no be parsed (I guess they are being silently forwarded to tikz which simply discards them).

\usemodule[tikz]
\usemodule[circuitikz][resistor=european]
\starttext
\startcircuitikz
\draw (0,0) to[R, l=$R_1$] (2,0);
\stopcircuitikz
\stoptext