I am new to CircuiTikZ and I am trying to start with very simple diagrams. I have been given a preamble and the relevant parts of it for CircuiTikZ seem to be
\usepackage[americanresistors,americaninductors]{circuitikz}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{circuit declare symbol = ac current source}
\tikzset{
ac current source IEC graphic/.style={
circuit symbol lines,
circuit symbol size = width 2 height 2,
shape = generic circle IEC,
/pgf/generic circle IEC/before background={
\pgfpathmoveto{\pgfpoint{-0.8pt}{0pt}}
\pgfpathsine{\pgfpoint{0.4pt}{0.4pt}}
\pgfpathcosine{\pgfpoint{0.4pt}{-0.4pt}}
\pgfpathsine{\pgfpoint{0.4pt}{-0.4pt}}
\pgfpathcosine{\pgfpoint{0.4pt}{0.4pt}}
\pgfusepath{stroke}
},
transform shape
}
}
I read the CircuiTikZ documentation and wrote this
\documentclass[12pt]{article}
\usepackage{preamble}
\usepackage{adjustbox}
\usepackage{gensymb}
\usepackage{todonotes}
\title{}
\pagestyle{fancy}
\linespread{1}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[RE,LO]{\ifthenelse{\value{page}=0}{}{}}
\begin{document}
\begin{circuitikz}
\draw
(0,0) to [short, *-] (6,0)
to [R=$R_1$] (6,4);
\end{circuitikz}
\fancyhead{}
\vspace*{\fill}
\end{document}
This is the end result I get.
The error I get on Overleaf is as follows.
Package pgfkeys Error: I do not know the key '/tikz/$R_1$' and I am going to ignore it. Perhaps you misspelled it.
Not sure what the issue is. Tried checking out similar posts but couldn't figure out a solution. Any help would be really appreciated :).
Edit: Extended circuitikz
code snippet to show document
environment.
circuitikz
-env only code snippet to a complete example which starts with\documentclass
and contains onedocument
environment.fancyhdr
staff and replacing non-existent packagepreamble
withcircuitikz
, your example compiles without errors.circuitikz
package. TikZ libraries for electrical schemas are no compatible withcircuitikz
. For their use you need to load\usepackage[compatibility]{circuitikz}
and than use\begin{tikzpicture}[circuit ee IEC]
(see subsection An example with the compatibility option),circuitikz package documentation, page 214). However, it is better to not mix them.circuits ee IEC
library, and it complies fine.