1

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.

enter image description here

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.

5
  • 1
    Please extend your circuitikz-env only code snippet to a complete example which starts with \documentclass and contains one document environment. Commented Apr 12, 2022 at 3:44
  • Thank you. I have edited the post to show this.
    – Wind_Fire
    Commented Apr 12, 2022 at 5:02
  • After removing fancyhdr staff and replacing non-existent package preamble with circuitikz, your example compiles without errors. Commented Apr 12, 2022 at 5:07
  • 1
    In your document example you not load circuitikz package. TikZ libraries for electrical schemas are no compatible with circuitikz. 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.
    – Zarko
    Commented Apr 12, 2022 at 5:08
  • Thank you all for your suggestions. I have changed my preamble by removing the circuits ee IEC library, and it complies fine.
    – Wind_Fire
    Commented Apr 12, 2022 at 5:14

1 Answer 1

1

In drawing of electrical circuits don't mix syntax from TikZ libraries and circuitikz. If you for some reason forced to do this, then consult documentation for circuitikz package, where this is shortly addressed in subsection "10.8 An example with the compatibility option" (Note, in example is minor error: in line 7 should be \usepackage[compatibility]{circuitikz}).

A MWE (Minimal working Example) for your simple circuit using circuitikz package is:

\documentclass[12pt, margin=3mm]{standalone}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}
\draw   (0,0) to [short, *-] (6,0)
              to [R=$R_1$] (6,4);
    \end{circuitikz}
\end{document}

It works fine and generate the following image of circuit:

enter image description here

If you refer European style of drawing circuits, than add option [european] to circuitikz:

\usepackage[european]{circuitikz}

in MWE preamble or

    \begin{circuitikz}[european]

In bot cases you will get:

enter image description here

1
  • Thank you. I have implemented your MWE and it works fine.
    – Wind_Fire
    Commented Apr 12, 2022 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .