Debian Codegraph @

texmf-dist/doc/latex/circuitikz/circuitikzmanual.tex

raw
1 % Copyright 2018-2026 by Romano Giannetti
2 % Copyright 2015-2026 by Stefan Lindner
3 % Copyright 2013-2026 by Stefan Erhardt
4 % Copyright 2007-2026 by Massimo Redaelli
5 %
6 % This file may be distributed and/or modified
7 %
8 % 1. under the LaTeX Project Public License and/or
9 % 2. under the GNU Public License.
10 %
11 % See the files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details.
12 %
13
14 \documentclass[a4paper, titlepage]{article}
15 \usepackage{iftex}
16 \usepackage{etoolbox}% for the fake-lwarp boolean
17
18 \ifPDFTeX
19 % pdfLaTeX
20 \usepackage[T1]{fontenc}
21 \usepackage[utf8]{inputenc} % optional on newer LaTeX, harmless
22 \usepackage{lmodern}
23 \else
24 % XeLaTeX or LuaLaTeX
25 \usepackage{fontspec}
26 \defaultfontfeatures{
27 Ligatures=TeX,
28 Numbers=OldStyle,
29 Mapping=tex-text,
30 SmallCapsFeatures={LetterSpace=8, Numbers=OldStyle}
31 }
32 % \setmainfont{Gentium Book Basic}
33 \fi
34 %%
35 %% The early lwarp code will be inserted here.
36 \InputIfFileExists{ctikz-lwarp-early.tex}{%
37 % this comment seems to be needed to avoid confusing lwarpmk
38 % usepackage{lwarp}
39 }{%
40 %% define a couple of fake conditional for lwarp support
41 \providebool{warpingHTML}
42 \providebool{warpingprint}
43 % Default: PDF build
44 \boolfalse{warpingHTML}
45 \booltrue{warpingprint}
46 }
47 %
48 %
49 % to check thanks to Max Chernoff https://tex.stackexchange.com/a/705682/38080
50 % \usepackage[version=latest]{pgf}
51 % do not split this line in more lines, otherwise "make git-manual" will show the wrong version
52 \usepackage[siunitx, RPvoltages]{circuitikz}
53 % Let this be the same as the chosen voltage direction for coherence
54 \def\chosenvoltoption{RPvoltages}
55 %
56 \def\tightlist{} % needed for latest pandoc-versions(pandoc used for including changelog)
57 \usepackage{microtype}
58
59 \usepackage{imakeidx}
60 \makeindex[title=Index, intoc=true]
61 \indexprologue{Here you will find, in alphabetical order, all the components, keys, and styles defined by the package. Components have the page number in straight text, while keys and styles have \emph{italic} page numbers.}
62 \renewcommand*\seealso[2]{#2, \emph{\alsoname} #1}
63 % Local utilities packages
64 \usepackage{ctikzmanutils}
65 %
66 %
67 %% The late lwarp code will be inserted here.
68 %% {{{lwarp-late}}}
69 \ifbool{warpingprint}{}{\InputIfFileExists{ctikz-lwarp-late.tex}{}{}}
70 %
71 \begin{document}
72 % change numbering to roman to avoid a duplicate hyperref target on page 1
73 % Thanks to Ulrike Fischer for helping here
74 \pagenumbering{roman}
75 \title{\Circuitikz \\{\large version \pgfcircversion{} (\pgfcircversiondate)}}
76 \author{Massimo A. Redaelli (\email{[email protected]})\\
77 Stefan Lindner (\email{[email protected]})\\
78 Stefan Erhardt (\email{[email protected]})\\
79 Romano Giannetti (\email{[email protected]})}
80 \date{\today}
81
82 %%% the email-in-tikz explodes when trying to convert to HTML
83 \ifbool{warpingHTML}{\let\emailintikz\texttt}{\let\emailintikz\email}
84
85 \pretitle{\begin{center}%
86 \begin{circuitikz}
87 \draw (0,0) node[dipchip, rotate=90, num pins=40, fill=cyan!20!white](C){%
88 \rotatebox{-90}{\LARGE\Circuitikz}%
89 };
90 \draw (C.pin 20) -- ++(0,-8) node[ground](GND){};
91 \draw (C.pin 7) to[D, fill=blue] ++(0,-1) -- ++(0.5,0) to[R] ++(2,0)
92 coordinate(a1) to[short, -*]
93 node[above left, blue, pos=1]{Massimo A. Redaelli}
94 node[below left, pos=1]{\emailintikz{[email protected]}}
95 (a1-|GND);
96 \draw (C.pin 5) to[D, fill=red] ++(0,-3)-- ++(0.5,0) to[R] ++(2,0)
97 coordinate(a2) to[short, -*]
98 node[above left, blue, pos=1]{Stefan Lindner}
99 node[below left, pos=1]{\emailintikz{[email protected]}}
100 (a2-|GND);
101 \draw (C.pin 3) to[D, fill=green] ++(0,-5)-- ++(0.5,0) to[R] ++(2,0)
102 coordinate(a3) to[short, -*]
103 node[above left, blue, pos=1]{Stefan Erhardt}
104 node[below left, pos=1]{\emailintikz{[email protected]}}
105 (a3-|GND);
106 \draw (C.pin 1) to[D, fill=yellow] ++(0,-7)-- ++(0.5,0) to[R] ++(2,0)
107 coordinate(a4) to[short, -*]
108 node[above left, blue, pos=1]{Romano Giannetti}
109 node[below left, pos=1]{\emailintikz{[email protected]}}
110 (a4-|GND);
111 \end{circuitikz}
112 \par\bigskip\vfill}
113 \posttitle{\end{center}}
114
115 \maketitle
116
117 % go back to arabic numbering after the titlepage
118 \pagenumbering{arabic}
119 \tableofcontents
120
121 \section{Introduction}
122 \label{sec:introduction}
123
124 \hfill\begin{minipage}[t]{0.5\textwidth}
125 \small\slshape\raggedleft
126 Lorenzo and Mirella, 57 years ago, started a trip that eventually lead to a lot of things --- among them, \Circuitikz{} \texttt{v1.0}.
127
128 In loving memory
129 --- R.\,G., 2020-02-04
130 \end{minipage}
131
132 \subsection{About}
133 \label{sec:about}
134 \Circuitikz{} was initiated by Massimo Redaelli in 2007, who was working as a research assistant at the Polytechnic University of Milan, Italy, and needed a tool for creating exercises and exams.
135 After he left University in 2010 the development of \Circuitikz\ slowed down, since \LaTeX\ is mainly established in the academic world. In 2015 Stefan Lindner and Stefan Erhardt, both working as research assistants at the University of Erlangen-Nürnberg, Germany, joined the team and now maintain the project together with the initial author. In 2018 Romano Giannetti, full professor of Electronics at Comillas Pontifical University of Madrid, joined the team.
136
137 The use of \Circuitikz\ is, of course, not limited to academic teaching. The package gets widely used by engineers for typesetting electronic circuits for articles and publications all over the world.
138
139 \subsection{License}
140 \label{sec:license}
141 Copyright \copyright{}
142 2007--2026 by Massimo Redaelli,
143 2013--2026 by Stefan Erhardt,
144 2015--2026 by Stefan Lindner,
145 and 2018--2026 by Romano Giannetti.
146 This package is author-maintained. Permission is granted to copy, distribute and/or modify this software under the terms of the \LaTeX\ Project Public License, version 1.3.1, or the GNU Public License. This software is provided ``as is'', without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.
147 \subsection{Loading the package}
148 \label{sec:loading-the-package}
149
150 \begin{table}[h]
151 \centering
152 \begin{tabular}{ll}\toprule
153 \LaTeX & \ConTeXt\footnotemark \\ \midrule
154 \verb!\usepackage{circuitikz}! & \verb!\usemodule[circuitikz]!\\
155 \bottomrule
156 \end{tabular}
157 \end{table}
158 \footnotetext{\ConTeXt\ support was added mostly thanks to Mojca Miklavec and Aditya Mahajan. \textbf{Please notice} that since \ConTeXt{} switched to the new \texttt{lmtx} engine (March 2023), there can be problems to compile \TikZ{} with some version; in May 2023 the problem has been fixed. Please check \href{https://github.com/circuitikz/circuitikz/issues/706}{this issue} for details.}
159
160
161 \noindent \TikZ\ will be automatically loaded; additionally, the \TikZ{} libraries \texttt{calc}, \texttt{arrows.meta}, \texttt{bending}, and \texttt{fpu} are loaded (the last one is used only on demand).
162
163 \noindent Circui\TikZ\ commands are just \TikZ\ commands, so a minimum usage example would be:
164
165 \begin{ctikzExample}
166 \tikz \draw (0,0) to[R=$R_1$] (2,0);
167 \end{ctikzExample}
168
169 There is really no support for Plain TeX --- the maintainers are willing to consider patches if somebody is interested.
170
171 \subsection{Installing a new version of the package.}
172 \label{sec:installing-a-new}
173
174 The stable version of the package should come with your \LaTeX\ distribution. Downloading the files from CTAN and installing them locally is, unfortunately, a distribution-dependent task and sometimes not so trivial. If you search for \texttt{local texmf tree} and the name of your distribution on \url{https://tex.stackexchange.com/} you will find a lot of hints.
175
176 Anyway, the easiest way of using whichever version of \Circuitikz\ is to point to the GitHub page \url{https://circuitikz.github.io/circuitikz/} of the project, and download the version you want. You will download a simple (biggish) file, called \texttt{circuitikzgit.sty}.
177
178 Now you can just put this file in your local \texttt{texmf} tree, if you have one, or simply adding it into the same directory where your main file resides, and then use
179
180 \begin{lstlisting}
181 \usepackage[...options...]{circuitikzgit}
182 \end{lstlisting}
183
184 instead of \texttt{circuitikz}. This is also advantageous for ``future resilience''; the authors try hard not to break backward compatibility with new versions, but sometimes, things happen.
185
186 \subsection{Requirements}
187 \label{sec:requirements}
188 \begin{itemize}
189 \item \texttt{latex} (if using it), version from \texttt{2019-10-01} (better from \texttt{2020-10-01});
190 \item \texttt{tikz}, version ${}\ge{}$\texttt{3.1.5b} (it \emph{should} work with any version from 3.1.4b and up, but better use a newer one);
191 \item \texttt{xstring}, not older than 2009/03/13;
192 \item \texttt{siunitx}, if using \texttt{siunitx} option (better \texttt{v2} or newer).
193 \end{itemize}
194
195 A similar approach for \ConTeXt\ is available, with the file \texttt{t-circuitikzgit.tex}; the compatibility in this case is not guaranteed, but provided on a \emph{best effort} base.
196
197 This manual has been typeset with \Circuitikz{} \pgfcircversion{} (\pgfcircversiondate) on \TikZ{} \pgfversion{} (\pgfversiondate).
198
199 \subsection{Incompatible packages}\label{sec:incompatible-packages}
200
201 \TikZ's own \texttt{circuit} library, which was based on \Circuitikz, (re?)defines several styles used by this library. In order to have them work together you can use the \texttt{compatibility} package option, which basically prefixes the names of all \Circuitikz\ \texttt{to[]} styles with an asterisk.
202
203 So, if loaded with said option, one must write \verb!(0,0) to[*R] (2,0)! and, for transistors on a path, \verb!(0,0) to[*Tnmos] (2,0)!, and so on (but \verb!(0,0) node[nmos] {}!). See example at page~\pageref{ex:compatibility}.
204
205 Anyway, the compatibility code is a \emph{best effort} task and only very lightly tested --- the authors advice is to choose one or the other, without mixing them.
206
207 Another thing to take into account is that any \TikZ{} figure (and \Circuitikz{} ones qualify) \textbf{will} have problems if you use the \texttt{babel} package with a language that changes active characters (most of them). The solution is normally to add the line \verb|\usetikzlibrary{babel}| in your preamble, after loading \TikZ{} or \Circuitikz. This will normally solve the problem; some languages also require using \verb|\deactivatequoting| or the option \texttt{shorthands=off} for \texttt{babel}. Please check the documentation of \TikZ{} or this question \href{https://tex.stackexchange.com/questions/166772/problem-with-babel-and-tikz-using-draw}{on \TeX{} stackexchange site}.
208
209 Finally, the \TikZ{} library \texttt{bending} is loaded by the package, and its effects (the bending of the arrows on curved paths) will also affect the rest of your drawings.
210
211 \subsection{Related and extension packages}
212 \label{sec:related-and-extension}
213
214 \subsubsection{Related packages}
215 \label{sec:related-packages}
216
217 At the Friedrich-Alexander-Universität, a group of developers are implementing a graphical user interface to draw circuits with \Circuitikz{}.
218 You can find more information \href{https://github.com/circuitikz/circuitikz/issues/782}{in this GitHub issue} or, better, on their \href{https://circuit2tikz.tf.fau.de/}{main site}. You can try out the GUI \href{https://circuit2tikz.tf.fau.de/designer/}{here}.
219
220 \subsubsection{Extension packages}
221 \label{sec:extension-packages}
222
223 \Circuitikz{} is meant to be, as much as possible, format-agnostic (which means that it can be used from \LaTeX{}, plain \TeX{} and~\ConTeXt). It is growing in functionality and components, but not everything can be added to the package. In this section, there is a list of packages, available at CTAN, that extend or enhance \Circuitikz{} but are distributed separately.\footnote{If you have a package or know a package that should be listed here, please contact the \Circuitikz{} authors, or, better, send a pull request to the project and it will be added.}
224
225 \begin{description}
226 \item [\href{https://ctan.org/pkg/tikzquads}{tikzquads}] is a package for easily drawing the equivalent electrical circuits for quadrupoles and similar blocks. \LaTeX{} only.
227 \item [\href{https://ctan.org/pkg/tikzdotncross}{tikzdotncross}] offers a few alternative ways for declaring and marking coordinates and drawing a line with "jumps" over an already existent path\footnote{\dots read the introduction: try not to overuse the jumping symbol; it's not a standard for the last 25 years. Nevertheless, sometimes is very useful, especially for didactic reasons (Romano's personal opinion in this comment).}. \LaTeX{} only.
228 \end{description}
229
230
231 \subsection{Known bugs and limitation}\label{sec:bugs}
232
233 \Circuitikz{} will \textbf{not work} correctly with global (in the main \texttt{circuitikz} environment, or in \texttt{scope} environments) \emph{negative} scale parameters (\texttt{scale}, \texttt{xscale} or \texttt{yscale}), unless \texttt{transform shape} is also used, and even in this cases the behavior is not guaranteed.
234 Neither will it work with angle-changing scaling (when \texttt{xscale} is different form \texttt{yscale}) and with the global \texttt{rotate} parameter.
235
236 Correcting this will need a big rewrite of the path routines, and although the authors are thinking about solving it, don't hold your breath; it will need changing a lot of interwoven code (labels, voltages, currents and so on). Contributions and help would be highly appreciated.
237
238 Hopefully most of the issues with compatibility between \Circuitikz{} and the \texttt{pic} \TikZ{} feature should have been solved in \texttt{v1.8.0}, but the feature is only lightly tested (see example~\ref{sec:example-pics}).
239
240 Also, notice that several components will interact in a funny way with global path options. Depending on the specific component, some parameters are inherited by the internal shape, and some others are reset. This is not easy to fix in general. We want some options to go through --- fill color, dashed pattern for example --- and some others to stay only in the outer path; and if the background shape needs some option for drawing the internal shape, like for example a rounded corner, it \emph{must} reset the external option. So there is no perfect solution, although since \texttt{v1.5.0} the shapes have been ``robustified'', so that by default arced corners and arrows parameters will \emph{not} be propagated into the shape.
241 Arrows with \texttt{to[]} components don't work, anyway, so basically avoid this situation.
242 In some cases, also the engine you are using (as \texttt{pdflatex}, \texttt{xelatex}, and so on) can impact coloring in corner cases (or even not so in the corner, like in \href{https://tex.stackexchange.com/q/709273/38080}{american-style voltage source signs}).
243
244 \begin{ctikzExample}
245 \begin{circuitikz}[]
246 \draw (0,3) to[R] ++(3,0) node[npn, anchor=B]{};
247 % arrows will not work and give strange results
248 % so basically do not use them!
249 \draw[<->] (0,1.5) to[R] ++(3,0) node[npn, anchor=B]{};
250 \draw[shorten <=10pt] (0,0) to[R] ++(3,0)
251 node[npn, anchor=B]{};
252 \end{circuitikz}
253 \end{ctikzExample}
254
255 Lastly, voltage styles interacts in strange ways with general (such as \IndexKey{american}, \IndexKey{european} style), in the sense that sometimes the order in which you enact them is important. That should be arguably fixed, but it will change (read break) a lot of existing code, so it'll stay; more information and workarounds in section~\ref{sec:mixing-voltage-styles}.
256
257 As a final notice, if you want to use the \texttt{externalize} library, do not use the \texttt{circuitikz} environment: use \texttt{tikzpicture} (which is really the same thing, see the FAQ~\ref{faqs:externalize}).
258
259 \subsection{Scale factor inaccuracies}\label{sec:usefpu}
260
261 Sometimes, when using fractional scaling factors and big values for the coordinates, the basic layer inaccuracies from \TeX{} can bite you, producing results like the following one:
262
263 \begin{ctikzExample}
264 \begin{circuitikz}[scale=1.2, transform shape,
265 ]
266 \draw (60,1) to [battery2, v_=$V_{cc}$, name=B] ++(0,2);
267 \node[draw,red,circle,inner sep=4pt] at(B.left) {};
268 \node[draw,red,circle,inner sep=4pt] at(B.right) {};
269 \end{circuitikz}
270 \end{ctikzExample}
271
272 A general solution for this problem is difficult to find; probably the best approach is to use a \verb|scalebox| command to scale the circuit instead of relying on internal scaling.
273
274 Nevertheless, \href{https://tex.stackexchange.com/a/529159/38080}{Schrödinger's cat} found a solution which has been ported to \Circuitikz: you can use the key \IndexKey[fpu]{use fpu reciprocal} which will patch a standard low-level math routine with a more precise one.
275
276 \begin{ctikzExample}
277 \begin{circuitikz}[scale=1.2, transform shape,
278 use fpu reciprocal,
279 ]
280 \draw (60,1) to [battery2, v_=$V_{cc}$] ++(0,2);
281 \end{circuitikz}
282 \end{ctikzExample}
283
284 The \texttt{use fpu reciprocal} key seems to have no side effects, but given that it is patching an internal interface of \TikZ{} it can break any time, so it is advisable to use it only if and when needed.
285
286
287 \subsection{Incompatibilities between versions}\label{sec:incompatible-changes}
288 Here, we will provide a list of incompatibilities between different versions of \Circuitikz. We will try to hold this list short, but sometimes it is easier to break with old syntax than include a lot of switches and compatibility layers. In general, changes that would invalidate a circuit (changes of polarity of components and so on) are almost always protected by a flag; the same is not true for purely aesthetic changes.
289 If unsure, you can check the version in your local installation by using the macro \verb!\pgfcircversion{}!.
290 \begin{itemize}
291 \item In version \texttt{1.8.2}, all the text anchors of the components have been made stable, meaning they are meaningful after the component has been drawn.\footnote{The problem has been noticed by \href{https://github.com/circuitikz/circuitikz/pull/876}{user \texttt{@JPWiedemann} on GitHub}.} That was the case only for part of the components. It \emph{shouldn't} affect anything for standard usage, but according to the \TikZ{} manual, \href{https://github.com/circuitikz/circuitikz/pull/876#issuecomment-3005428742}{``this is the way''}. Almost no text\IndexKey[text anchors]{} (see below) should change position (see also section~\ref{sec:node-text-anchors}).
292
293 Two minor changes are that the previously \emph{incorrectly} described \texttt{text} anchor for \texttt{flowarrow} is not where it used to be shown (use anchor \texttt{center} instead); and that the anchors for \texttt{oscillator} and \texttt{gridnode}, which were completely bogus, have been fixed.
294 \item In version \texttt{1.8.0}, the path routines changed to allow using path-style components in \TikZ{}'s \texttt{pic}. The change is a big one, so a rollback point (see below) for \texttt{v1.7.2} has been added.
295 \item In version \texttt{1.7.2}, the drawing of the ``double-zero'' source components \IndexKey{voosource}, \IndexKey{ioosource}, and \IndexKey{oosourcetran} changed so that now the circle radius depend on the height and not on the width. If you didn't play with internal parameters, that should be invisible.
296 \item In version \texttt{1.7.1}, the default widths of \IndexKey{barrier} and \IndexKey{openbarrier} were reduced so that no wire is drawn as part of the symbols by default.
297 This is accompanied by a change to the meanings of the configuration keys \texttt{bipoles/barrier/width}, \texttt{bipoles/barrier/height} and \texttt{bipoles/openbarrier/gap} (as well as the new key \texttt{bipoles/openbarrier/width}).
298 The change avoids problems when using barriers on short pieces of path or as nodes, cf.~the details in \href{https://github.com/circuitikz/circuitikz/pull/835}{the relevant pull request on GitHub}.
299 The new default values are chosen such that the components are identical to the default appearance before the change.
300 \item Since version \texttt{1.6.3} the default symbol for the minus sign changed from the simple \verb|$-$| to \verb|$\vphantom{+}-$|. The reason is that in some (most?) font, the minus sign is enclosed in a smaller bounding box than the plus sign and that leads to poorly aligned minus symbols in \texttt{american} and \texttt{raised} voltages. This was not noticed before because the two symbols share the same bounding box in the default Computer Modern font. You can look at \href{https://github.com/circuitikz/circuitikz/issues/721}{this issue on GitHub} for more details; if you want to go back to the previous definitions you can write
301 % notice that you have to close listings in items on the last line
302 %see https://tex.stackexchange.com/a/167315/38080
303 \begin{lstlisting}
304 \ctikzset{amplifiers/minus=$-$}
305 \ctikzset{bipoles/cvsourceam/inner minus=$-$}
306 \ctikzset{bipoles/vsourceam/inner minus=$-$}
307 \ctikzset{voltage/american minus=$-$}
308 \end{lstlisting}
309 \item Since version \texttt{1.6.3} the size of the solder dot and the connection dot of the body diodes for transistors has changed (now they are the same and are configurable). The new default scale of~\texttt{0.7} makes the dots \emph{area} more or less one half the one of the external connections. You can go back to the previous values with
310 \begin{lstlisting}
311 \ctikzset{transistor bodydiode/dot scale=0.5,
312 transistor solderdot scale=1.0}
313 \end{lstlisting}
314 \item Since version \texttt{1.6.2} \texttt{siunitx} will \textbf{not} work anymore with \ConTeXt{} (it was a very poor simulation layer, anyway); it has been disabled in upstream \ConTeXt, in favor of \href{https://www.pragma-ade.nl/general/manuals/units-mkiv.pdf}{its own \texttt{units} module}.
315 \item Version \texttt{1.6.0} has a big rewrite of the block's code. In principle the changes are backward-compatible, but there were several bugs (wrong anchors, errors with rotations, and so on) that have been fixed in the process.
316 \item Since \texttt{v1.5.1}\footnote{Do not use \texttt{v1.5.0}, it's buggy.} color management (see section~\ref{sec:colors}) and the details of how the shapes are drawn and protected by the external drawing options has changed. There should be no substantial changes to the circuits, though.
317 \item The \TikZ{} fix for \texttt{to[...] +(x,y)} behavior (see~\ref{sec:path-relative-coordinates}) uncovered a bug in the positioning of the labels in \Circuitikz{} that had been present since \texttt{v0.8}. So you \textbf{must} upgrade to \texttt{v1.4.1} or better if you have \TikZ{} newer than \texttt{3.1.8} (and you want/need to use the \texttt{+(x,y)} syntax).
318 \item There have been changes in (internal) parameters for capacitors in \texttt{v1.4.1}; now to change them you should use the style interface (see~\ref{sec:capacitors-styling}).
319 \item \Circuitikz{} \texttt{v1.4.0} introduced the rollback system for the package when using LaTeX; that (at least in principle) should be completely backward-compatible.
320 \item The path construction in \texttt{v1.4.0} has been changed a bit (again). The change shouldn't break any circuit and will correct a behavior that should have been fixed with the \texttt{v1.2.1} change (see below).
321 \item Version 1.3.6 fixes several problems with the stacked labels; the most important change is that now the bracing of arguments is respected as in version 1.3.0 for the other labels. The special treatment in stacked labels (and only in stacked labels!) for the (still experimental\footnote{and, really, not advised\dots}) \texttt{siunitx} compact syntax \texttt{<...>} has been removed: it was completely buggy before, and silently ignored, now will throw an error.
322 \item Version 1.3.3 fixes the direction of the arrows in tunable elements; before this version, they were more or less random, now the arrow goes from bottom left to top right. You have the option to go back to the old behavior with \IndexKey[fix tunable direction]{\textbackslash ctikzset\{bipoles/fix tunable direction=false\}}. As a compensation for the fuss, now the arrows are configurable. To learn more, see the FAQ:~\ref{faq:tunable-arrow}.
323 \item Version 1.3.1 removes the warning if you do not specify a voltage direction.
324 \item Version 1.3.0 fixes the buggy stripping of braces from labels and annotations (see~\ref{sec:bracing-of-labels}).
325 \item After 1.2.7 a big code reorganization (which had the collateral effect of fixing some bugs) has been made; no changes should be visible, but a fallback point at 1.2.7 has been added.
326 \item You \textbf{must} upgrade to v1.2.7 or newer if you use a \TikZ{} 3.1.8 or 3.1.8a (but better upgrade both packages to the current version). You can check the \TikZ{} version installed using the macro \verb|\pgfversion|.
327 \item After v1.2.1: \textbf{Important:} the routine that implements the \texttt{to[...]} component positioning has been rewritten. That should enhance the line joins in paths, and it's safer, but it can potentially change some old behavior.
328
329 One of the changes is that the previous routine did the wrong thing if you used \texttt{(node) to[...]} (you should use an anchor or a coordinate, not a node there --- like \texttt{(node.anchor) to[...]}).
330
331 The other one was that in the structure \texttt{... to[...] node[pos=\emph{something}] (coord)} the value of \texttt{pos} was completely wrong (even if you don't use \texttt{pos} explicitly, remember it's \texttt{pos=0.5} by default).
332
333 Additionally, the old code disrupted the \TikZ{} path-fill mechanism, so that you could get away with using the \texttt{fill} option on paths and having just the components filled, not the path. That was incorrect, although sometime it was handy (sorry).
334
335 See the FAQ at section~\ref{faqs:nodes} for more information.
336
337 \item After v1.2.0: voltage arrows, symbols and label positions are calculated with a rewritten routine. There should be little change, \emph{unless} you touched internal values\dots
338 \item After v1.1.3: from version 1.1.0 to version 1.1.2, the inverted Schmitt buffer in IEEE style ports was called \texttt{inv schmitt} (with an additional space). The correct name is \texttt{invschmitt port} (the same as the legacy american port).
339 \item After v1.1.2: the position of \texttt{american} voltages for the \IndexKey{open} bipoles changed (you can revert to the old behavior, see section~\ref{sec:sub-voltage-position}).
340 \item After v0.9.7: the position of the text of transistor nodes has changed; see section~\ref{sec:transistors-labels}.
341 \item After v0.9.4: added the concept of styling of circuits. It should be backward compatible, but it's a big change, so be ready to use the \texttt{0.9.3} snapshot (see below for details).
342 \item After v0.9.0: the parameters \texttt{tripoles/american or port/aaa}, \texttt{...bbb}, \texttt{...ccc} and \texttt{...ddd} are no longer used and are silently ignored; the same stands for the similarly named parameters in \texttt{nor}, \texttt{xor}, and \texttt{xnor} ports.
343 \item After v0.9.0: voltage and current directions/signs (plus and minus signs in case of \texttt{american voltages} and arrows in case of \texttt{european voltages}) have been rationalized with a couple of new options (see details in section~\ref{curr-and-volt}). The default case is still the same as v0.8.3, to avoid potentially wrong circuits, but you would be better off with one of the new voltage directions (\texttt{EFvoltages} or \texttt{RPvoltages}) for newer circuits.
344 \item Since v0.8.2: voltage and current label directions (\texttt{v<=} / \texttt{i<=}) do NOT change the orientation of the drawn source shape anymore. Use the \texttt{invert} option to rotate the shape of the source. Furthermore, from this version on, the current label (\texttt{i=}) at current sources can be used independent of the regular label (\texttt{l=}).
345 \item Since v0.7: The label behavior at mirrored bipoles has changed, this fixes the voltage drawing, but perhaps you will have to adjust your label positions.
346 \item Since v0.5.1: The parts \IndexKey{pfet}, \IndexKey{pigfete}, \IndexKey{pigfetebulk}, and \IndexKey{pigfetd} are now mirrored by default. Please adjust your yscale-option to correct this.
347 \item Since v0.5: New voltage counting direction, there exists an option to use the old behavior.
348 \end{itemize}
349
350 If you have older projects that show compatibility problems, you have two options:
351 \begin{itemize}
352 \item you can use an older version locally using the git-version and picking the correct commit from the repository (branch gh-pages) or the main GitHub site directly;
353 \item if you are using \LaTeX, the distribution has embedded several important old versions: \texttt{0.4}, \texttt{0.6}, \texttt{0.7}, \texttt{0.8.3}, \texttt{0.9.3}, \texttt{0.9.6}, \texttt{1.0}, \texttt{1.1.2}, \texttt{1.2.7}, \texttt{1.4.6}, and \texttt{1.7.2}.
354 To switch to use them, since \texttt{v1.4.0} you simply use the \href{https://www.latex-project.org/publications/2018-FMi-TUB-tb122mitt-version-rollback.pdf}{new LaTeX kernel rollback system}, changing your \verb|\usepackage| invocation to something like:
355 \begin{lstlisting}[numbers=none]
356 % or v0.4, v0.6, ...
357 \usepackage[]{circuitikz}[=v0.8.3]
358 \end{lstlisting}
359 You can also specify a date instead of a version number: if you write
360 \begin{lstlisting}[numbers=none]
361 \usepackage[]{circuitikz}[=2020/02/05]
362 \end{lstlisting}
363 the rollback system will load the version that was current on February 5th,~2020 (in this case it will be \texttt{v1.0} which was released the day before).
364
365 If for whatever reasons your kernel is older, you can still use the old method of loading the \emph{package-version} package; for example:
366 \begin{lstlisting}[numbers=none]
367 % or circuitikz-0.4, 0.6...
368 \usepackage[]{circuitikz-0.8.3}
369 \end{lstlisting}
370 which is an inferior solution because it can fool any package you use that depend on \texttt{circuitikz}.
371
372 Either way, you have to take care of the options that may have changed between versions (and sometime styles, if you use them).
373 \item if you are using \ConTeXt, only versions \texttt{0.8.3}, \texttt{0.9.3}, \texttt{0.9.6}, \texttt{1.0}, \texttt{1.1.2}, \texttt{1.2.7}, \texttt{1.4.6}, and \texttt{1.7.2} are packaged; you can use it with
374 \begin{lstlisting}[numbers=none]
375 \usemodule[circuitikz-0.8.3]
376 \end{lstlisting}
377 \end{itemize}
378
379
380 \subsection{Feedback}
381 \label{sec:feedback}
382 The easiest way to contact the authors is via the official GitHub repository: \url{https://github.com/circuitikz/circuitikz/issues}. For general help question, a lot of nice people are quite active on \url{https://tex.stackexchange.com/questions/tagged/circuitikz} --- be sure to read the help pages for the site and ask!
383
384 \subsection{Package options}
385 \label{sec:package-options}
386
387 Circuit people are very opinionated about their symbols. In order to satisfy the individual taste you can set a bunch of package options.
388
389 There are arguably way too many options in \Circuitikz, as you can see in the following list. Since version \texttt{1.0}, it is recommended to just use the basic ones --- voltage directions (you \textbf{should} specify one of them), \texttt{siunitx} (only for \LaTeX{}), the global style (\texttt{american} or \texttt{european}) and use styles (see~\ref{sec:styling}) for the remaining options.
390
391 The standard options are set by historical reason, and reflect the preferences of the author that introduced them. For example you get this:
392
393 \begin{ctikzExample}
394 \begin{circuitikz}
395 \draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) --
396 (2,2) to[V<=84<\volt>] (0,2)
397 -- (0,0);
398 \end{circuitikz}
399 \end{ctikzExample}
400
401 Feel free to load the package with your own cultural options:
402
403 \begin{center}
404 \begin{tabular}{ll}\toprule
405 \LaTeX & \ConTeXt \\ \midrule
406 \verb!\usepackage[american]{circuitikz}! & \verb!\usemodule[circuitikz][american]!\\
407 \bottomrule
408 \end{tabular}
409 \end{center}
410
411 \begin{ctikzExample}
412 \begin{circuitikz}
413 [circuitikz/voltage=american, circuitikz/resistor=american] % line not printed
414 \draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) --
415 (2,2) to[V<=84<\volt>] (0,2)
416 -- (0,0);
417 \end{circuitikz}
418 \end{ctikzExample}
419
420 \textbf{However}, most of the global package options are not available in \ConTeXt; in that case you can always use the appropriate \verb|\tikzset{}| or \verb|\IndexKey{}| command after loading the package.
421
422 \medskip{}
423
424 \noindent Here is the list of all the options:
425 {\sloppy % for the big lists of \texttt here
426 \begin{itemize}
427 \item \IndexKey{europeanvoltages}: uses arrows to define voltages, and uses european-style voltage sources;
428 \item \IndexKey{straightvoltages}: uses arrows to define voltages, and and uses straight voltage arrows;
429 \item \IndexKey{americanvoltages}: uses $-$ and $+$ to define voltages, and uses american-style voltage sources;
430 \item \IndexKey{europeancurrents}: uses european-style current sources;
431 \item \IndexKey{americancurrents}: uses american-style current sources;
432 \item \IndexKey{europeanresistors}: uses rectangular empty shape for resistors, as per european standards;
433 \item \IndexKey{americanresistors}: uses zig-zag shape for resistors, as per american standards;
434 \item \IndexKey{europeaninductors}: uses rectangular filled shape for inductors, as per european standards;
435 \item \IndexKey{americaninductors}: uses ``4-bumps'' shape for inductors, as per american standards;
436 \item \IndexKey{cuteinductors}: uses my personal favorite, ``pig-tailed'' shape for inductors;
437 \item \IndexKey{americanports}: uses triangular logic ports, as per american standards;
438 \item \IndexKey{europeanports}: uses rectangular logic ports, as per european standards;
439 \item \IndexKey{americangfsurgearrester}: uses round gas filled surge arresters, as per american standards;
440 \item \IndexKey{europeangfsurgearrester}: uses rectangular gas filled surge arresters, as per european standards;
441 \item \IndexKey{european}: equivalent to \texttt{europeancurrents}, \texttt{europeanvoltages}, \texttt{europeanresistors}, \texttt{europeaninductors}, \texttt{europeanports}, \texttt{europeangfsurgearrester};
442 \item \IndexKey{american}: equivalent to \texttt{americancurrents}, \texttt{americanvoltages}, \texttt{americanresistors}, \texttt{americaninductors}, \texttt{americanports}, \texttt{americangfsurgearrester};
443 \item \IndexKey{siunitx}: integrates with \texttt{SIunitx} package. If labels, currents or voltages are of the form \verb!#1<#2>! then what is shown is actually \verb!\SI{#1}{#2}! (not supported in \ConTeXt; it has been disabled in upstream \ConTeXt, in favor of \href{https://www.pragma-ade.nl/general/manuals/units-mkiv.pdf}{its own \texttt{units} module});
444 \item \IndexKey{nosiunitx}: labels are not interpreted as above;
445 \item \IndexKey{fulldiode}: the various diodes are drawn \emph{and} filled by default, i.e. when using styles such as \texttt{diode}, \texttt{D}, \texttt{sD}, \ldots Other diode styles can always be forced with e.g. \texttt{Do}, \texttt{D-}, \ldots
446 \item \IndexKey{strokediode}: the various diodes are drawn \emph{and} stroke by default, i.e. when using styles such as \texttt{diode}, \texttt{D}, \texttt{sD}, \ldots Other diode styles can always be forced with e.g. \texttt{Do}, \texttt{D*}, \ldots
447 \item \IndexKey{emptydiode}: the various diodes are drawn \emph{but not} filled by default, i.e. when using styles such as \texttt{D}, \texttt{sD}, \ldots Other diode styles can always be forced with e.g. \texttt{Do}, \texttt{D-}, \ldots
448 \item \IndexKey{arrowmos}: pmos and nmos have arrows analogous to those of pnp and npn transistors;
449 \item \IndexKey{noarrowmos}: pmos and nmos do not have arrows analogous to those of pnp and npn transistors;
450 \item \IndexKey{fetbodydiode}: draw the body diode of a FET;
451 \item \IndexKey{nofetbodydiode}: do not draw the body diode of a FET;
452 \item \IndexKey{fetsolderdot}: draw solderdot at bulk-source junction of some transistors;
453 \item \IndexKey{nofetsolderdot}: do not draw solderdot at bulk-source junction of some transistors;
454 \item \IndexKey{emptypmoscircle}: the circle at the gate of a pmos transistor does not get filled;
455 \item \IndexKey{lazymos}: draws lazy nmos and pmos transistors. Chip designers with huge circuits prefer this notation;
456 \item \IndexKey{legacytransistorstext}: the text of transistor nodes is typeset near the collector;
457 \item \IndexKey{nolegacytransistorstext} or \texttt{centertransistorstext}: the text of transistor nodes is typeset near the center of the component;
458 \item \IndexKey{straightlabels}: labels on bipoles are always printed straight up, i.e.~with horizontal baseline;
459 \item \IndexKey{rotatelabels}: labels on bipoles are always printed aligned along the bipole;
460 \item \IndexKey{smartlabels}: labels on bipoles are rotated along the bipoles, unless the rotation is very close to multiples of \SI{90}{\degree};
461 \item \IndexKey{compatibility}: makes it possibile to load \Circuitikz\ and \TikZ\ circuit library together.
462 \item Voltage directions: until v0.8.3, there was an error in the coherence between american and european voltages styles (see section~\ref{curr-and-volt}) for the batteries. This has been fixed, but to guarantee backward compatibility and to avoid nasty surprises, the fix is available with new options:
463 \begin{itemize}
464 \item \IndexKey{oldvoltagedirection}: Use old way of voltage direction having a difference between european and american direction, with wrong default labeling for batteries;
465 \item \IndexKey{nooldvoltagedirection}: The standard from 0.5 onward, utilizes the (German?) standard of voltage arrows in the direction of electric fields (without fixing batteries);
466 \item \IndexKey{RPvoltages} (meaning Rising Potential voltages): the arrow is in the direction of rising potential, like in \texttt{oldvoltagedirection}, but batteries and current sources are fixed to follow the passive/active standard;
467 \item \IndexKey{EFvoltages} (meaning Electric Field voltages): the arrow is in the direction of the electric field, like in \texttt{nooldvoltagedirection}, but batteries are fixed;
468 \end{itemize}
469 If none of these option are given, the package will default to \texttt{nooldvoltagedirection}. The behavior is also selectable circuit by circuit with the \texttt{voltage dir} style.
470 \item \texttt{betterproportions}\footnote{May change in the future!}: nicer proportions of transistors in comparision to resistors; notice that this option is superseded by styles and it's kept just for compatibility, do not use it in new projects;
471 \end{itemize}
472
473 The old options in the singular (like \texttt{american voltage}) are still available for compatibility, but are discouraged.
474
475 \medskip
476
477 Loading the package with no options is equivalent to the following options:
478 \texttt{[nofetsolderdot, europeancurrents, europeanvoltages, americanports,
479 americanresistors, cuteinductors, europeangfsurgearrester, nosiunitx, noarrowmos,
480 smartlabels, nocompatibility, centertransistorstext]}.
481
482 \medskip
483
484 In \ConTeXt\ the options are similarly specified: \texttt{current= european|american}, \texttt{voltage= european|american}, \texttt{resistor= american|european}, \texttt{inductor= cute|american|european}, \texttt{logic= american|european}, \texttt{arrowmos= false|true}.
485
486 } %\stop the \sloppy processing
487
488 \section{Tutorials}
489 \label{sec:tutorials}
490
491 Before even starting with \Circuitikz{} you should be sure to have understood the basics of \TikZ{}. It is \emph{hightly recommended} that you read and go through \emph{at least} the following parts of the \TikZ{} manual:
492 \begin{itemize}
493 \item \href{https://tikz.dev/tutorial}{``Tutorial: A Picture for Karl's Students''} (around page 30);
494 \item \href{https://tikz.dev/tikz-coordinates}{``Specifying Coordinates''} (around page 131)
495 \item \href{https://tikz.dev/tikz-shapes}{``Nodes and their shapes''} (around page 220)
496 \end{itemize}
497 \dots but obviously a good knowledge of \TikZ{} will help you a lot. Remember, a circuit drawn with \Circuitikz{} is nothing more than a \texttt{tikzpicture} with an (albeit powerful and extended) set of shapes and commodity macros.
498
499 Said that, to draw a circuit, you have to load the \Circuitikz{} package; this can be done with
500 \begin{lstlisting}
501 \usepackage[siunitx, RPvoltages]{circuitikz}
502 \end{lstlisting}
503 somewhere in your document preamble. It will load automatically the needed packages if not already done before.
504
505 \subsection{Getting started with \Circuitikz: a current shunt}
506 \label{sec:getting-started-with}
507
508 Let's say we want to prepare a circuit to teach how a current shunt works; the idea is to draw a current generator, a couple of resistors in parallel, and the indication of currents and voltages for the discussion.
509
510 A circuit in \Circuitikz{} is drawn into a \texttt{circuitikz} environment (which is really an alias for \texttt{tikzpicture}). In this first example we will use absolute coordinates.
511 The electrical components can be divided in two main categories: the ones that are bipoles and are placed along a path (also known as \texttt{to}-style component, for their usage), and components that are nodes and can have any number of poles or connections.
512
513 Let's start with the first type of component, and build a basic mesh:
514
515 \begin{ctikzExample}
516 \begin{circuitikz}[]
517 \draw (0,0) to[isource] (0,3) -- (2,3)
518 to[R] (2,0) -- (0,0);
519 \end{circuitikz}
520 \end{ctikzExample}
521
522 The symbol for the current source might surprise some; this is actually the european-style symbol, and the type of symbol chosen reflects the default options of the package (see section~\ref{sec:package-options}). Let's change the style for now (the author of the tutorial, Romano, is European --- but he has always used American-style circuits, so\dots); and while we're at it, let's add the other branch and some labels.
523
524 \begin{ctikzExample}
525 \begin{circuitikz}[american]
526 \draw (0,0) to[isource, l=$I_0$] (0,3) -- (2,3)
527 to[R=$R_1$] (2,0) -- (0,0);
528 \draw (2,3) -- (4,3) to[R=$R_2$]
529 (4,0) -- (2,0);
530 \end{circuitikz}
531 \end{ctikzExample}
532
533 You can use a single path or multiple paths when drawing your circuit, it's just a question of style (but be aware that closing paths perfectly could be non-trivial, see section~\ref{sec:line-joins}), and you can use standard \TikZ\ lines (\verb|--|, \verb+|-+ or similar) for the wires. Nonetheless, sometime using the \Circuitikz{} specific \IndexKey{short} component for the wires can be useful, because then we can add labels and poles to them, as for example in the following circuit, where we add a current (with the key \texttt{i=...}, see section~\ref{sec:currents}) and a connection dot (with the special shortcut \texttt{-*} which adds a \IndexKey{circ} node at the end of the connection, see sections~\ref{sec:terminals} and~\ref{sec:bipole-nodes}).
534
535 \begin{ctikzExample}
536 \begin{circuitikz}[american]
537 \draw (0,0) to[isource, l=$I_0$] (0,3)
538 to[short, -*, i=$I_0$] (2,3)
539 to[R=$R_1$, i=$i_1$] (2,0) -- (0,0);
540 \draw (2,3) -- (4,3)
541 to[R=$R_2$, i=$i_2$]
542 (4,0) to[short, -*] (2,0);
543 \end{circuitikz}
544 \end{ctikzExample}
545
546 One of the problems with this circuit is that we would like to have the current labels in a different position, such as for example on the upper side of the resistors, so that Kirchhoff's Current Law at the node is better shown to students. No problem; as you can see in section~\ref{curr-and-volt} you can use the position specifiers \verb|<>^_| after the key \IndexKey{i}:
547
548 \begin{ctikzExample}
549 \begin{circuitikz}[american]
550 \draw (0,0) to[isource, l=$I_0$] (0,3)
551 to[short, -*, i=$I_0$] (2,3)
552 to[R=$R_1$, i>_=$i_1$] (2,0) -- (0,0);
553 \draw (2,3) -- (4,3)
554 to[R=$R_2$, i>_=$i_2$]
555 (4,0) to[short, -*] (2,0);
556 \end{circuitikz}
557 \end{ctikzExample}
558
559 Finally, we would like to add voltages indication for carrying out the current formulas; as the default position of the voltage signs seems a bit cramped to me, I am adding the \IndexKey{voltage shift} parameter to make a bit more space for it\dots
560
561 \begin{ctikzExample}
562 \begin{circuitikz}[american, voltage shift=0.5]
563 \draw (0,0)
564 to[isource, l=$I_0$, v=$V_0$] (0,3)
565 to[short, -*, i=$I_0$] (2,3)
566 to[R=$R_1$, i>_=$i_1$] (2,0) -- (0,0);
567 \draw (2,3) -- (4,3)
568 to[R=$R_2$, i>_=$i_2$]
569 (4,0) to[short, -*] (2,0);
570 \end{circuitikz}
571 \end{ctikzExample}
572
573 \emph{Et voila!}. Remember that this is still \LaTeX, which means that you have done a description of your circuit, which is, in a lot of way, independent of the visualization of it. If you ever have to adapt the circuit to, say, a journal that forces European style and flows instead of currents, you just change a couple of things and you have what seems a completely different diagram:
574
575 \begin{ctikzExample}
576 \begin{circuitikz}[european, voltage shift=0.5]
577 \draw (0,0)
578 to[isourceC, l=$I_0$, v=$V_0$] (0,3)
579 to[short, -*, f=$I_0$] (2,3)
580 to[R=$R_1$, f>_=$i_1$] (2,0) -- (0,0);
581 \draw (2,3) -- (4,3)
582 to[R=$R_2$, f>_=$i_2$]
583 (4,0) to[short, -*] (2,0);
584 \end{circuitikz}
585 \end{ctikzExample}
586
587 And finally, this is still \TikZ, so that you can freely mix other graphics element to the circuit.
588
589 \begin{ctikzExample}
590 \begin{circuitikz}[american, voltage shift=0.5]
591 \draw (0,0)
592 to[isource, l=$I_0$, v=$V_0$] (0,3)
593 to[short, -*, f=$I_0$] (2,3)
594 to[R=$R_1$, f>_=$i_1$] (2,0) -- (0,0);
595 \draw (2,3) -- (4,3)
596 to[R=$R_2$, f>_=$i_2$]
597 (4,0) to[short, -*] (2,0);
598 \draw[red, thick] (0.6,2.1) rectangle (4.2,3.8)
599 node[pos=0.5, above]{KCL};
600 \end{circuitikz}
601 \end{ctikzExample}
602
603 \clearpage
604
605 \subsection{A non-inverting op-amp amplifier}
606 \label{sec:a-non-inverting}
607
608 \begin{minipage}[t]{0.55\linewidth}
609 Let's now try to draw a non-inverting amplifier based on op-amps; the canonical implementation can be, for example, \href{https://www.electronics-tutorials.ws/opamp/opamp_3.html}{this one from ``electronics tutorials''}.
610 Obviously, the style and form of drawing a circuit is often a matter of personal tastes and, maybe even more important, of the details you are focusing on; drawing a non-inverting amplifier will be different if you are drawing it to \emph{explain how it works} or if you are simply using it in a more complex circuit, assuming its operation well known by the reader. Anyway, the final objective is to have a circuit like the one on the right, drawn so that it is easy to reuse.
611 \end{minipage}\hfill
612 \begin{minipage}[t]{0.4\linewidth}
613 \begin{circuitikz}[baseline=(OA.+), ]
614 \ctikzset{amplifiers/fill=cyan!20, component text=left}
615 \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
616 node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
617 (OA.-) -- ++(0,-1) coordinate(FB)
618 to[R=$R_1$] ++(0,-2) node[ground]{}
619 (FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
620 to [short, *-o] ++(1,0) node[above]{$v_o$}
621 ;
622 \end{circuitikz}
623 \end{minipage}
624
625 We have to start the drawing from a generic point. Given that the idea is to have a reusable block, instead of positioning the op-amp and build around it, we will start from the input ``pole'':
626
627 \begin{ctikzExample}
628 \begin{circuitikz}[]
629 \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
630 node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
631 ;
632 \end{circuitikz}
633 \end{ctikzExample}
634
635 In this snippet, notice that the only absolute coordinate is the first one; that will enable us to ``copy and paste'' the circuit in several places, or create a macro for it. We position a text node above it, and then draw a wire with a pole to a relative \texttt{(1,0)} coordinate: in other words, we \emph{move} 1~unit to the right drawing a short-circuit, which is the same as a wire. The usage of \texttt{to[short...]} simplifies the position of the pole, but notice that we could have also written:
636 \begin{lstlisting}[numbers=none]
637 \draw (0,0) node[above]{$v_i$} node[ocirc]{} -- ++(1,0) ...
638 \end{lstlisting}
639 with the same result.
640
641 The second step is to position the op-amp. We can check the manual and see the component's description (section~\ref{sec:amplifiers}):
642
643 \begin{groupdesc}
644 \circuitdesc*{op amp}{Operational amplifier}{}( +/180/0.2, -/180/0.2, out/0/
645 0.2, up/90/0.2, down/-90/0.2 )
646 \end{groupdesc}
647
648 where we notice the type of the component (it is a node-type component, so we have to use
649 \texttt{node} to position it) and the available ``anchors'': points we can use to position the shape or to connect to. Not all the anchors are \emph{explicitly} printed in the description box; you should read further in the manual and you'll see a ``\emph{component} anchors'' (\ref{sec:amplifiers-anchors}) section with the relevant information.
650
651 Anyway, the op-amp must be connected with the \texttt{+} anchor to our input wire, so we say \texttt{anchor=+} in the option lists; this shifts the whole element so that the named anchor will lie at the current position of the path. Moreover, normally the shape has the inverting input on the bottom side, and we want it the other way around, so we use also \texttt{noinv input up} in the keys defining the node. We could also have flipped the shape with \texttt{yscale=-1}, but in this case we would need to consider the effects on anchors and on the text; see section~\ref{sec:mirroring-and-flipping}.
652
653 Now we can draw the resistors; let's start with $R_1$. We will draw it going down vertically from the \texttt{-} anchor --- we have named the node \texttt{OA} so that will be \texttt{OA.-}. We will need to connect the $R_2$ also, so we do the following:
654 \begin{itemize}
655 \item draw a wire going down, and mark a point where we want the feedback resistor to connect;
656 \item then draw $R_1$ and finally
657 \item draw the ground node.
658 \end{itemize}
659
660 \begin{ctikzExample}
661 \begin{circuitikz}[scale=0.8, transform shape]
662 \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
663 node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
664 (OA.-) -- ++(0,-1) coordinate(FB)
665 to[R=$R_1$] ++(0,-2) node[ground]{}
666 ;
667 \end{circuitikz}
668 \end{ctikzExample}
669
670 We are only missing the feedback resistor now. We will use \emph{orthogonal coordinates}, writing:
671 \begin{lstlisting}[numbers=none]
672 \draw (FB) to[R=$R_2$] (FB -| OA.out) -- (OA.out)
673 \end{lstlisting}
674
675 The meaning is the following:
676 \begin{itemize}
677 \item move the current point to the coordinate named \texttt{FB};
678 \item put a resistor, with label $R_2$, from here \textbf{to}\dots
679 \item the coordinates, which are at the intersection of a horizontal line through \texttt{FB} and a vertical line through \texttt{OA.out}: the \texttt{-|} coordinate operation is quite mnemonic;
680 \item then continue drawing to \texttt{OA.out}.
681 \end{itemize}
682
683 You can use a separate \verb|\draw| command or just continue the path you were writing; the choice is just personal preference, but be warned that it can affect the drawing of poles (see section~\ref{sec:bipole-nodes} about this if you notice strange things).
684
685 Finally, we add the output and a couple of nodes:
686
687 \begin{ctikzExample}
688 \begin{circuitikz}[scale=0.8, transform shape]
689 \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
690 node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
691 (OA.-) -- ++(0,-1) coordinate(FB)
692 to[R=$R_1$] ++(0,-2) node[ground]{}
693 (FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
694 to [short, *-o] ++(1,0) node[above]{$v_o$}
695 ;
696 \end{circuitikz}
697 \end{ctikzExample}
698
699 The last step to obtain the final look is to add a bit of styling. We want the op-amp filled with a light cyan color, and we prefer to have the label aligned with the left side of the device:
700
701 \begin{ctikzExample}
702 \ctikzset{amplifiers/fill=cyan!20, component text=left}
703 \begin{circuitikz}[scale=0.8, transform shape]
704 \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
705 node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
706 (OA.-) -- ++(0,-1) coordinate(FB)
707 to[R=$R_1$] ++(0,-2) node[ground]{}
708 (FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
709 to [short, *-o] ++(1,0) node[above]{$v_o$}
710 ;
711 \end{circuitikz}
712 \end{ctikzExample}
713
714 The \verb|\ctikzset| command choosing the style is better placed in the preamble, though. Style should be coherent for all the document body, so avoiding stating it for every circuit is normally the best strategy.
715
716 \subsubsection{Reusing the circuit: the easy way}
717 \label{sec:reusing-the-circuit}
718 \begingroup % to keep changes local
719
720 The easiest way to reuse the circuit is to put it in a macro. This is a very flexible way of doing it; the only drawback is that the only easy way to position it is using the first coordinate: you will not be able to move the component using ``anchors''; that is more complex and will need the use of subcircuits (but you will lose parameters\dots see section~\ref{sec:subcircuits}).
721
722 Defining a macro for our amplifier could be as easy as this:
723
724 \begin{ctikzExample}[exec outside]
725 \ctikzset{amplifiers/fill=cyan!20, component text=left}
726 \newcommand\myNIA[4]{%1: name of this amplifier, %2 start coordinate, %3 R1, %4 R2
727 \draw #2 coordinate(#1-in) to[short] ++(1,0)
728 node[op amp, noinv input up, anchor=+](#1-OA){\texttt{#1}}
729 (#1-OA.-) -- ++(0,-1) coordinate(#1-FB)
730 to[R=#3] ++(0,-2) node[ground]{}
731 (#1-FB) to[R=#4, *-] (#1-FB -| #1-OA.out) -- (#1-OA.out)
732 to [short, *-] ++(1,0) coordinate(#1-out)
733 ;
734 }
735 \end{ctikzExample}
736
737 We remove the open poles (it's better to draw them at the end to avoid artifacts) and then we make the names of the coordinates and of the nodes unique, by prepending a parameter that we will provide at every invocation. Then we remove the labels (for simplicity here) and add a couple of coordinates that we will be able to use from the outside when building our circuit.
738
739 And we can use it like in the following:
740
741 \begin{ctikzExample}
742 \begin{circuitikz}[scale=0.7, transform shape]
743 \myNIA{OA1}{(0,0)}{$R_1$}{$R_2$}
744 % start drawing from the output of OA1
745 \myNIA{OA2}{(OA1-out)}{$R_3$}{$R_4$}
746 \node [ocirc] at (OA1-in) {};
747 \node [above] at (OA1-in) {$v_i$};
748 \node [ocirc] at (OA2-out){};
749 \node [above] at (OA2-out) {$v_o$};
750 \draw (OA1-out) -| (OA2-in);
751 \end{circuitikz}
752 \end{ctikzExample}
753
754 \endgroup % remove the changes of the op-amp tutorial subsection
755 \clearpage
756
757 \subsection{A transistor-based amplifier}
758 \label{sec:a-transistor-based}
759 \begingroup % do not propagate to the rest of the manual
760
761 The idea is to draw a two-stage amplifier for a lesson, or exercise, on the different qualities of BJT and MOSFET transistors.
762
763 Please notice that this section uses the ``new'' position for transistor labels, enabled since version \texttt{0.9.7}. You should refer to older manuals to see how to do the same with older versions; basically the transistor's names were output using an additional \verb|node{}| command.
764
765 Also notice that this is a more ``personal'' tutorial, showing a way to draw circuits that is, in the author's opinion, highly reusable and easy to do.
766 The idea is to use relative coordinates and named nodes as much as possible, so that changes in the circuit are easily done by changing just a few numbers that select relative positions and by using symmetries. Crucially, this kind of approach makes each block reusable in other diagrams by just changing one coordinate.
767
768 First of all, let's define a handy function to show the position of nodes:
769
770 \begin{ctikzExample}[exec outside]
771 \def\normalcoord(#1){coordinate(#1)}
772 \def\showcoord(#1){coordinate(#1) node[circle, red, draw, inner sep=1pt,
773 pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm,
774 pin edge={red, overlay}]45:#1}](){}}
775 \let\coord=\showcoord
776 \end{ctikzExample}
777
778 The idea is that you can use \verb|\coord()| instead of \verb|coordinate()| in paths, and that will draw small red \emph{markers} showing them. For example:
779
780 \begin{ctikzExample}
781 \begin{circuitikz}[american]
782 \draw (0,0) node[npn](Q){};
783 \path (Q.center) \coord(center)
784 (Q.B) \coord(B) (Q.C) \coord(C)
785 (Q.E) \coord(E);
786 \useasboundingbox
787 (Q.south west) (Q.north east) +(.75,.3);
788 \end{circuitikz}
789 \end{ctikzExample}
790
791 After the circuit is drawn, simply commenting out the second \verb|\let| command will hide all the markers.
792
793 So let's start with the first stage transistor; given that my preferred way of drawing a MOSFET is with arrows, I'll start with the command \verb|\ctikzset{tripoles/mos style/arrows}|:
794
795 \ctikzset{tripoles/mos style/arrows}
796 \def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
797 \begin{ctikzExample}
798 \begin{circuitikz}[american]
799 \ctikzset{tripoles/mos style/arrows}
800 \def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
801 \path (0,0) -- (.5,0); % bounding box
802 \draw (0,0) node[nmos](Q1){\killdepth{Q1}};
803 \end{circuitikz}
804 \end{ctikzExample}
805
806 I had to do draw an invisible line to take into account the text for Q1 --- the text is not taken into account in calculating the bounding box. This is because the ``geographical'' anchors (\texttt{north}, \texttt{north west}, \dots) are defined for the symbol only. In a complex circuit, this is rarely a problem.
807
808 Another thing I like to modify with respect to the standard is the position of the arrows in transistors, which are normally in the middle of the symbol. Using the following setting (see section~\ref{sec:styling-transistors}) will move the arrows to the start or end of the corresponding pin.
809
810 \begin{ctikzExample}[exec outside]
811 \ctikzset{transistors/arrow pos=end}
812 \end{ctikzExample}
813
814 The tricky thing about \verb|\killdepth{}| macro is the finicky details. Without the \verb|\killdepth| macro, the labels of different transistors will be adjusted so that the vertical center of the box is at the \texttt{center} anchor, and as an effect, labels with descenders (like Q) will have a different baseline than labels without. You can see this here (it's really subtle):
815
816 \begin{ctikzExample}
817 \begin{circuitikz}[american,]
818 \draw (0,0) node[nmos](Q1){q1} ++(2,0)
819 node[nmos](M1){m1};
820 \draw [red] (Q1.center) ++(0,-0.7ex) -- ++(3,0);
821 \draw (0,-2)node[nmos](Q1){\killdepth{q1}} ++(2,0)
822 node[nmos](M1){\killdepth{m1}};
823 \draw [red] (Q1.center) ++(0,-0.7ex) -- ++(3,0);
824 \end{circuitikz}
825 \end{ctikzExample}
826
827 We will start connecting the first transistor with the power supply with a couple of resistors. Notice that I am naming the nodes \texttt{GND}, \texttt{VCC} and \texttt{VEE}, so that I can use the coordinates to have all the supply rails at the same vertical position (more on this later).
828
829 \begin{ctikzExample}
830 \begin{circuitikz}[american,]
831 \draw (0,0) node[nmos,](Q1){\killdepth{Q1}};
832 \draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}]
833 ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$};
834 \draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}]
835 ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
836 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$]
837 ++(0,-1.5) node[ground](GND){};
838 % show the named coordinates!
839 \path (GND) \coord(GND)
840 (VCC) \coord(VCC)
841 (VEE) \coord(VEE);
842 \end{circuitikz}
843 \end{ctikzExample}
844
845 After that, let's add the input part. I will use a named node here, referring to it to add the input source. Notice how the ground node is positioned: the coordinate \texttt{(in |- GND)} is the point with the horizontal coordinate of \texttt{(in)} and the vertical one of \texttt{(GND)}, lining it up with the ground of the capacitor $C_1$ (you can think it as ``the point aligned vertically with \texttt{in} and horizontally with \texttt{GND}'').
846
847 \begin{ctikzExample}
848 \begin{circuitikz}[american, scale=0.7, transform shape]
849 \draw (0,0) node[nmos,](Q1){\killdepth{Q1}};
850 \draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}]
851 ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$};
852 \draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}]
853 ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
854 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$]
855 ++(0,-1.5) node[ground](GND){};
856 \draw (Q1.G) to[short] ++(-1,0)
857 \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}]
858 (in |- GND) node[ground]{};
859 \draw (in) to[C, l_=$C_2$,*-o]
860 ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
861 \end{circuitikz}
862 \end{ctikzExample}
863
864 Notice that the only absolute coordinate here is the first one, \texttt{(0,0)}; so the elements are connected with relative movements and can be moved by just changing one number (for example, changing the \verb| to[C=$C_1$] ++(0,-1.5) | will move \emph{all} the grounds down).
865
866 This is the final circuit, with the nodes still marked:
867 \begin{lstlisting}[basicstyle=\small\ttfamily]
868 % this is for the blue brackets under the circuit
869 \tikzset{blockdef/.style={%
870 {Straight Barb[harpoon, reversed, right, length=0.2cm]}-{Straight Barb[harpoon, reversed, left, length=0.2cm]},
871 blue,
872 }}
873 \def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
874 \def\coord(#1){coordinate(#1)}
875 \def\coord(#1){coordinate(#1) node[circle, red, draw, inner sep=1pt,
876 pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm,
877 % we reset the arrow in pin edge to avoid carrying over the path one!
878 pin edge={red, overlay,-}]45:#1}](#1-node){}}
879 \begin{circuitikz}[american, ]
880 \draw (0,0) node[nmos,](Q1){\killdepth{Q1}};
881 \draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$}; %define VEE level
882 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
883 \draw (Q1.G) to[short] ++(-1,0) \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}] (in |- GND) node[ground]{};
884 \draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
885 \draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
886 \draw (Q1.D) to[short, -o] ++(1,0) node[right](vo1){$v_{o1}$};
887 %
888 \path (vo1) -- ++(2,0) \coord(bjt);
889 %
890 \draw (bjt) node[npn, anchor=B](Q2){\killdepth{Q2}};
891 \draw (Q2.B) to[short, -o] ++(-0.5,0) node[left](vi2){$v_{12}$};
892 \draw (Q2.E) to[R,l2^=$R_E$ and \SI{9.3}{k\ohm}] (Q2.E |- VEE) node[vee]{};
893 \draw (Q2.E) to[short, -o] ++(1,0) node[right](vo2){$v_{o2}$};
894 \draw (Q2.C) to[short] (Q2.C |- VCC) node[vcc]{};
895 %
896 \path (vo2) ++(1.5,0) \coord(load);
897 \draw (load) to[C=$C_3$] ++(1,0) \coord(tmp) to[R=$R_L$] (tmp |- GND) node[ground]{};
898 \draw [densely dashed] (vo2) -- (load);
899 %
900 \draw [densely dashed] (vo1) -- (vi2);
901 %
902 \draw [blockdef](vi1|-VEE) ++(0,-2) \coord(tmp)
903 -- node[midway, fill=white]{bloque 1} (vo1|- tmp);
904 \draw [blockdef] (vi2|-VEE) ++(0,-2) \coord(tmp)
905 -- node[midway, fill=white]{bloque 2} (vo2|- tmp);
906
907 \end{circuitikz}
908 \end{lstlisting}
909
910 \tikzset{blockdef/.style={%
911 {Straight Barb[harpoon, reversed, right, length=0.2cm]}-{Straight Barb[harpoon, reversed, left, length=0.2cm]},
912 blue, %densely dotted,
913 }}
914 \def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
915 \def\coord(#1){coordinate(#1)}
916 \def\coord(#1){coordinate(#1) node[circle, red, draw, inner sep=1pt,
917 pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm,
918 % we reset the arrow in pin edge to avoid carrying over the path one!
919 pin edge={red, overlay,-}]45:#1}](#1-node){}}
920 \begin{circuitikz}[american, ]
921 \draw (0,0) node[nmos,](Q1){\killdepth{Q1}};
922 \draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$}; %define VEE level
923 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
924 \draw (Q1.G) to[short] ++(-1,0) \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}] (in |- GND) node[ground]{};
925 \draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
926 \draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
927 \draw (Q1.D) to[short, -o] ++(1,0) node[right](vo1){$v_{o1}$};
928 %
929 \path (vo1) -- ++(2,0) \coord(bjt);
930 %
931 \draw (bjt) node[npn, anchor=B](Q2){\killdepth{Q2}};
932 \draw (Q2.B) to[short, -o] ++(-0.5,0) node[left](vi2){$v_{12}$};
933 \draw (Q2.E) to[R,l2^=$R_E$ and \SI{9.3}{k\ohm}] (Q2.E |- VEE) node[vee]{};
934 \draw (Q2.E) to[short, -o] ++(1,0) node[right](vo2){$v_{o2}$};
935 \draw (Q2.C) to[short] (Q2.C |- VCC) node[vcc]{};
936 %
937 \path (vo2) ++(1.5,0) \coord(load);
938 \draw (load) to[C=$C_3$] ++(1,0) \coord(tmp) to[R=$R_L$] (tmp |- GND) node[ground]{};
939 \draw [densely dashed] (vo2) -- (load);
940 %
941 \draw [densely dashed] (vo1) -- (vi2);
942 %
943 \draw [blockdef](vi1|-VEE) ++(0,-2) \coord(tmp)
944 -- node[midway, fill=white]{bloque 1} (vo1|- tmp);
945 \draw [blockdef] (vi2|-VEE) ++(0,-2) \coord(tmp)
946 -- node[midway, fill=white]{bloque 2} (vo2|- tmp);
947 \end{circuitikz}
948
949 You can see that after having found the place where we want to put the BJT transistor, we use the option \texttt{anchor=B} so that the base anchor will be put at the coordinate \texttt{bjt}.
950
951 Finally, if you like a more compact drawing, you can add the options (for example):
952 \begin{lstlisting}
953 \begin{circuitikz}[american, scale=0.8] % this will scale only the coordinates
954 \ctikzset{resistors/scale=0.7, capacitors/scale=0.6}
955 ...
956 \end{circuitikz}
957 \end{lstlisting}
958
959 and you will obtain the following diagram with the exact same code (I just removed the second \verb|\coord| definition to hide the coordinates markings).
960
961 \ctikzset{resistors/scale=0.7, capacitors/scale=0.6}
962 \def\coord(#1){coordinate(#1)}
963 \begin{circuitikz}[american, ]
964 \draw (0,0) node[nmos,](Q1){\killdepth{Q1}};
965 \draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$}; %define VEE level
966 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
967 \draw (Q1.G) to[short] ++(-1,0) \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}] (in |- GND) node[ground]{};
968 \draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
969 \draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
970 \draw (Q1.D) to[short, -o] ++(1,0) node[right](vo1){$v_{o1}$};
971 %
972 \path (vo1) -- ++(2,0) \coord(bjt);
973 %
974 \draw (bjt) node[npn, anchor=B](Q2){\killdepth{Q2}};
975 \draw (Q2.B) to[short, -o] ++(-0.5,0) node[left](vi2){$v_{12}$};
976 \draw (Q2.E) to[R,l2^=$R_E$ and \SI{9.3}{k\ohm}] (Q2.E |- VEE) node[vee]{};
977 \draw (Q2.E) to[short, -o] ++(1,0) node[right](vo2){$v_{o2}$};
978 \draw (Q2.C) to[short] (Q2.C |- VCC) node[vcc]{};
979 %
980 \path (vo2) ++(1.5,0) \coord(load);
981 \draw (load) to[C=$C_3$] ++(1,0) \coord(tmp) to[R=$R_L$] (tmp |- GND) node[ground]{};
982 \draw [densely dashed] (vo2) -- (load);
983 %
984 \draw [densely dashed] (vo1) -- (vi2);
985 %
986 \draw [blockdef](vi1|-VEE) ++(0,-2) \coord(tmp)
987 -- node[midway, fill=white]{bloque 1} (vo1|- tmp);
988 \draw [blockdef] (vi2|-VEE) ++(0,-2) \coord(tmp)
989 -- node[midway, fill=white]{bloque 2} (vo2|- tmp);
990 \end{circuitikz}
991 \endgroup
992
993 \clearpage
994 \subsection{A logic circuit}
995 \label{sec:a-logic-circuit}
996
997 \begingroup % let's keep the tutorial thing separated.
998 \tikzset{sr-ff/.style={flipflop, flipflop def={
999 t1=S, t2=CP, t3=R, t4={\ctikztextnot{Q}},t6=Q, td=~, nd=1}},
1000 }
1001 \ctikzset{
1002 logic ports=ieee,
1003 logic ports/scale=0.7,
1004 }
1005 \pushdollarcat
1006 \newcommand*{\myblock}[1]{% the parameter will be prepended to the relevant node names
1007 node[sr-ff](#1-FF){} (#1-FF.bup) node[above]{SR-FF}
1008 (#1-FF.pin 1) -- ++(-1,0) node[and port, anchor=out](#1-AND1){}
1009 % notice the second coordinate here, so that I have just one number
1010 % to change if I want more or less space
1011 (#1-FF.pin 3) -- (#1-FF.pin 3 -| #1-AND1.out) node[and port, anchor=out](#1-AND2){}
1012 % go left again to put the not insert point
1013 (#1-AND1.in 1) to[short, -*] ++(-1,0) coordinate(#1-in)
1014 % let's position the NOT in the center to be really finicky
1015 % this is using the calc tikz library
1016 % ($(not up)!0.5!(not up|- #1-AND2.in 2)$) node[not port, rotate=-90](#1-NOT){}
1017 % and connect it
1018 % (not up) -- (#1-NOT.in) (#1-NOT.out) |- (#1-AND2.in 2)
1019 % with the new path-style not
1020 to[inline not] (#1-in |- #1-AND2.in 2) -- (#1-AND2.in 2)
1021 % no ; to end the path, must add in usage!
1022 }
1023 \popdollarcat
1024 \newcommand*{\fullcirc}[1][]{%
1025 \begin{circuitikz}
1026 \draw (0,0) \myblock{A};
1027 \draw (0,-4) \myblock{B};
1028 %
1029 % do the connection
1030 %
1031 \draw (A-AND1.in 2) to[short, -*] (A-AND2.in 1)
1032 to[short, -*] (B-AND1.in 2) to[short, -*] (B-AND2.in 1)
1033 -- ++(0, -2) coordinate(down) node[below]{ENABLE};
1034 \draw (A-FF.pin 2) to[short, -*] (B-FF.pin 2)
1035 -- (B-FF.pin 2 |- down) node[below]{CP};
1036 % look at the manual again here
1037 \draw (B-FF.down) to[short, -*] ++(0,-0.3) coordinate(dd);
1038 \draw (A-FF.down) -- ++(0,-.5) -- ++(1.5,0) |- (dd)
1039 -- (dd |- down) node[below]{RESET};
1040 \draw (A-in) -- ++(-0.5, 0) node[below]{$a_0$};
1041 \draw (B-in) -- ++(-0.5, 0) node[below]{$a_1$};
1042 %
1043 #1
1044 %
1045 \end{circuitikz}%
1046 }
1047
1048 \begin{minipage}{0.45\linewidth}
1049 \parskip=6pt plus 12pt minus 2pt
1050
1051 Let's suppose we want to reproduce the circuit on the right\footnotemark, maybe as part of a more complex one.
1052
1053 Looking at the circuit to draw, I see that there is a basic block: the flip-flop with the added three-port circuit to its left, marked with the red dashed rectangle.
1054 The main distance to respect here is that we want the two ANDs in line with the flip-flop inputs, so I'll start with the flip-flop and then add the rest of the block.
1055
1056 The shapes are very similar to the IEEE logic gates (see section~\ref{sec:ieeestdports});
1057 after a first check, the standard size of the port is a bit too big with respect to the flip-flop, so I scale them down a bit.
1058
1059 \begin{lstlisting}
1060 \ctikzset{
1061 logic ports=ieee,
1062 logic ports/scale=0.7,
1063 }
1064 \end{lstlisting}
1065 \end{minipage}\hfill
1066 \begin{minipage}{0.5\linewidth}
1067 \fullcirc[{
1068 \node[draw, red, dashed, fit=(A-in) (A-FF)]{};
1069 }]
1070 \end{minipage}
1071 \footnotetext{It seems a quite popular one on \href{https://tex.stackexchange.com/q/545317/38080}{tex.stackexchange}\dots}
1072
1073 I want a reusable block, so I will start from a coordinate and then use only relative, defining coordinates along the way.
1074
1075 \begin{minipage}{0.7\linewidth}
1076 The first thing is to define a suitable flip-flop. The standard SR~(see \ref{sec:flipflops}) is \emph{almost} what we need, but not exactly the same. So let's define a new one:
1077 \begin{lstlisting}
1078 \tikzset{sr-ff/.style={flipflop, flipflop def={
1079 t1=S, t2=CP, t3=R, t4={\ctikztextnot{Q}},
1080 t6=Q, nd=1}},
1081 }
1082 \end{lstlisting}
1083 \end{minipage}\hfill
1084 \begin{minipage}{0.2\linewidth}
1085 \begin{circuitikz}[scale=0.8, transform shape]
1086 \tikzset{sr-ff/.style={flipflop, flipflop def={
1087 t1=S, t2=CP, t3=R, t4={\ctikztextnot{Q}},
1088 t6=Q, nd=1}},
1089 }
1090 \node[sr-ff]{};
1091 \end{circuitikz}
1092 \end{minipage}
1093
1094 Now we can add the ``and'' gates. For example, we can add the gates to the right like this:
1095
1096 \begin{ctikzExample}
1097 \begin{circuitikz}[]
1098 \draw (0,0) node[sr-ff](FF){} (FF.bup)
1099 node[above]{SR-FF};
1100 \draw (FF.pin 1) -- ++(-1,0) node[and port,
1101 anchor=out](AND1){}
1102 (FF.pin 3) -- ++(-1,0) node[and port,
1103 anchor=out](AND2){};
1104 \end{circuitikz}
1105 \end{ctikzExample}
1106
1107 You can notice a pair of things here: first of all, the use of the \texttt{anchor=out} in the port, to tell \TikZ{} that we want the node moved so that the \texttt{out} anchor is the reference one. The second one is that we have repeated the absolute shift (the \texttt{++(-1, 0)}) twice. This is a bad practice; it is much better to have the ``free'' parameters of a schematic just stated once, so that we can change them in just one point.
1108
1109 You can of course use a macro, like \verb|\newcommand{\andshift}{(-1,0)}| but it is much more elegant to do something like this:
1110 \begin{ctikzExample}
1111 \begin{circuitikz}[]
1112 \draw (0,0) node[sr-ff](FF){} (FF.bup)
1113 node[above]{SR-FF};
1114 \draw (FF.pin 1) -- ++(-1,0) node[and port,
1115 anchor=out](AND1){}
1116 (FF.pin 3) -- (FF.pin 3 -| AND1.out)
1117 node[and port, anchor=out](AND2){};
1118 \end{circuitikz}
1119 \end{ctikzExample}
1120
1121 In this snippet, the coordinate \texttt{(FF.pin 3 -| AND1.out)} is the \TikZ{} way to say ``the point which is horizontally straight from \texttt{FF.pin 3} and vertically form \texttt{AND1.out}''. That way one can change the number \texttt{-1} to move both AND ports nearer or farther away.
1122
1123 Now we can add the not port. Since version~\texttt{1.1.3} you can use a path-style not port, so you can just say: this:
1124
1125 \begin{ctikzExample}
1126 \begin{circuitikz}[scale=0.8, transform shape]
1127 \draw (0,0) node[sr-ff](FF){} (FF.bup)
1128 node[above]{SR-FF} (FF.pin 1) -- ++(-1,0)
1129 node[and port, anchor=out](AND1){}
1130 (FF.pin 3) -- (FF.pin 3 -| AND1.out)
1131 node[and port, anchor=out](AND2){}
1132 (AND1.in 1) to[short, -*] ++(-1,0) coordinate(in)
1133 to[inline not] (in |- AND2.in 2) -- (AND2.in 2);
1134 \end{circuitikz}
1135 \end{ctikzExample}
1136
1137 In earlier versions, you should have found the center point between the two terminal, position the ``not'' shape and ten connect it, like for example (this code must stay into the \verb|\draw| command):
1138
1139 \begin{lstlisting}
1140 % let's position the NOT in the center
1141 % this is using the calc tikz library
1142 ($(in)!0.5!(in |- AND2.in 2)$) node[not port, rotate=-90](NOT){}
1143 % and connect it
1144 (in) -- (NOT.in) (NOT.out) |- (AND2.in 2)
1145 \end{lstlisting}
1146
1147 Now we have the basic block; we have to use it twice, so one of the possible ways to do it is to prepare a command.
1148 We will change the names of the nodes and the coordinates to be different for any ``call'' of the block (another option is to use a \texttt{pic}; but this is more straightforward).
1149
1150 \begin{lstlisting}
1151 \newcommand*{\myblock}[1]{% Add #1- to the node and coord names
1152 node[sr-ff](#1-FF){} (#1-FF.bup) node[above]{SR-FF}
1153 (#1-FF.pin 1) -- ++(-1,0) node[and port, anchor=out](#1-AND1){}
1154 (#1-FF.pin 3) -- (#1-FF.pin 3 -| #1-AND1.out)
1155 node[and port, anchor=out](#1-AND2){}
1156 (#1-AND1.in 1) to[short, -*] ++(-1,0) coordinate(#1-in)
1157 to[inline not] (#1-in |- #1-AND2.in 2) -- (#1-AND2.in 2)
1158 }
1159 \end{lstlisting}
1160
1161
1162 \begin{minipage}{0.45\linewidth}
1163 \parskip=6pt plus 12pt minus 2pt
1164
1165 So now we can draw two of our blocks:
1166 \begin{lstlisting}
1167 \draw (0,0) \myblock{A};
1168 \draw (0,-4) \myblock{B};
1169 \end{lstlisting}
1170 Part of the anchors and coordinates that we have accessible are marked in red in the diagram at the side.
1171
1172 Now we have to just connect the relevant parts and add the labels. The names of the inputs are quite easy:
1173 \begin{lstlisting}
1174 \draw (A-in) -- ++(-0.5, 0) node[below]{$a_0$};
1175 \draw (B-in) -- ++(-0.5, 0) node[below]{$a_1$};
1176 \end{lstlisting}
1177 And finally:
1178 \end{minipage}\hfill
1179 \begin{minipage}{0.5\linewidth}
1180 \begingroup
1181 \def\showcoord(#1)<#2:#3>{%
1182 node[circle, red, draw, inner sep=1pt,pin={%
1183 [red, inner sep=0.5pt, font=\small,
1184 pin distance=#3cm, pin edge={red, }%
1185 ]#2:#1}](){}}
1186 \begin{circuitikz}[]
1187 \draw (0,0) \myblock{A};
1188 \draw (0,-4) \myblock{B};
1189 \foreach \b in {A, B}
1190 \foreach \n in {in, AND1.in 2, AND2.in 1, FF.pin 2, FF.down}
1191 \path (\b-\n) \showcoord(\b-\n)<45:0.6>;
1192 \end{circuitikz}
1193 \endgroup
1194 \end{minipage}
1195
1196 \begin{lstlisting}
1197 \draw (A-AND1.in 2) to[short, -*] (A-AND2.in 1)
1198 to[short, -*] (B-AND1.in 2) to[short, -*] (B-AND2.in 1)
1199 -- ++(0, -2) coordinate(down) node[below]{ENABLE};
1200 \draw (A-FF.pin 2) to[short, -*] (B-FF.pin 2)
1201 -- (B-FF.pin 2 |- down) node[below]{CP};
1202 \draw (B-FF.down) to[short, -*] ++(0,-0.3) coordinate(dd);
1203 \draw (A-FF.down) -- ++(0,-.5) -- ++(1.5,0) |- (dd)
1204 -- (dd |- down) node[below]{RESET};
1205 \end{lstlisting}
1206
1207 Will create the final diagram:
1208
1209 \begin{circuitikz}[scale=0.8, transform shape]
1210 \draw (0,0) \myblock{A};
1211 \draw (0,-4) \myblock{B};
1212 %
1213 % do the connection
1214 %
1215 \draw (A-AND1.in 2) to[short, -*] (A-AND2.in 1)
1216 to[short, -*] (B-AND1.in 2) to[short, -*] (B-AND2.in 1)
1217 -- ++(0, -2) coordinate(down) node[below]{ENABLE};
1218 \draw (A-FF.pin 2) to[short, -*] (B-FF.pin 2)
1219 -- (B-FF.pin 2 |- down) node[below]{CP};
1220 % look at the manual again here
1221 \draw (B-FF.down) to[short, -*] ++(0,-0.3) coordinate(dd);
1222 \draw (A-FF.down) -- ++(0,-.5) -- ++(1.5,0) |- (dd)
1223 -- (dd |- down) node[below]{RESET};
1224 \draw (A-in) -- ++(-0.5, 0) node[below]{$a_0$};
1225 \draw (B-in) -- ++(-0.5, 0) node[below]{$a_1$};
1226 %
1227 \end{circuitikz}
1228 \endgroup
1229
1230
1231 \section{The components: usage}
1232 \label{sec:the-components-usage}
1233
1234
1235 Components in \Circuitikz{} come in two forms: path-style, to be used in a \texttt{to[\emph{component},...} path specifications, and node-style, which will be instantiated by a \texttt{node[\emph{component},...]} specification.
1236
1237 All the shapes defined by Circui\TikZ{} are \texttt{pgf} nodes, so they are usable in both \texttt{pgf} and \TikZ.
1238
1239 \subsection{Path-style components}
1240 \label{sec:path-style-components}
1241
1242 The path-style components are used as shown below:
1243 \begin{lstlisting}
1244 \begin{circuitikz}
1245 \draw (0,0) to[#1=#2, options] (2,0);
1246 \end{circuitikz}
1247 \end{lstlisting}
1248 where \verb|#1| is the name of the component, \verb|#2| is an (optional) label, and \verb|options| are optional labels, annotations, style specifier that will be explained in the rest of the manual.
1249
1250 Transistors and some other node-style components can also be placed using the syntax for bipoles. See section~\ref{sec:transasbip}.
1251
1252 Most path-style components can be used as a node-style components; to access them, you add a \texttt{shape} to the main name of component (for example, \texttt{diodeshape}). Such a ``node-shape name'' is specified in the description of each component.
1253
1254 \subsubsection{Anchors}
1255 \label{sec:usage-anchors}
1256
1257 Normally, path-style components do not need anchors, although they have them just in case you need them. You have the basic ``geographical'' anchors (bipoles are defined horizontally and then rotated as needed):
1258 \begin{center}
1259 \begin{circuitikz}[
1260 ]
1261 \draw (0,0) to[resistor, name=R] ++(2,0);
1262 \path (R.center) \showcoord(center)<-90:0.3>;
1263 \path (R.left) \showcoord(left)<135:0.3>;
1264 \path (R.right) \showcoord(right)<45:0.3>;
1265 \draw (5,0) to[resistor, name=R] ++(2,0);
1266 \foreach \n/\a/\d in {north/90/0.3, north east/45/0.3, east/0/0.5,
1267 south east/-45/0.3, south/-90/0.3, south west/-135/0.3,
1268 west/180/0.5, north west/135/0.3}
1269 \path (R.\n) \showcoord(\n)<\a:\d>;
1270 \draw (10,-1) to[resistor, name=R] ++(0,2);
1271 \foreach \n/\a/\d in {n/135/0.3, e/45/0.3,
1272 s/-45/0.3, w/-135/0.3}
1273 \path (R.\n) \showcoord(\n)<\a:\d>;
1274 \end{circuitikz}
1275 \end{center}
1276 In the case of bipoles, also shortened geographical anchors exists. In the description, it will be shown when a bipole has additional anchors. To use the anchors, just give a name to the bipole element using the syntax \texttt{name=\emph{myname}}.
1277
1278 \begin{ctikzExample}
1279 \begin{circuitikz}
1280 \draw (0,0) to[potentiometer, name=P, mirror] ++(0,2);
1281 \draw (P.wiper) to[L] ++(2,0);
1282 \end{circuitikz}
1283 \end{ctikzExample}
1284
1285 Alternatively, that you can use the shape form, and then use the \texttt{left} and \texttt{right} anchors to do your connections.
1286
1287 \begin{ctikzExample}
1288 \begin{circuitikz}
1289 \draw (0,0) node[potentiometershape, rotate=-90](P){};
1290 \draw (P.wiper) to[L] ++(2,0);
1291 \end{circuitikz}
1292 \end{ctikzExample}
1293
1294 \subsubsection{Border anchors}\label{sec:bipoles-border-anchors}
1295
1296 \begingroup
1297 \def\showbordersfornode#1{%
1298 \begin{circuitikz}[baseline, scale=0.8, transform shape]
1299 \node[#1shape, name=bip] at(0,0) {};
1300 \foreach \a in {0,30,...,359} \draw[red] (bip.\a) -- ++(\a:0.7) node[font=\tiny, fill=white, inner sep=0.5pt]{\a};
1301 \foreach \a in {15,45,...,359} \draw[red] (bip.\a) -- ++(\a:0.4);
1302 \node [font=\ttfamily\small, black, below] at (bip.-90) {\detokenize\expandafter{#1}};
1303 \end{circuitikz}
1304 }
1305
1306 Bipoles have also installed generic border anchors --- that means, anchors that start at an angle. For complexity reason, these are for most of the components simply a generic enclosing rectangle (even for most of the round ones!\footnote{This is needed for the correct label/voltage etc. placement, and it's too much work to change it.}). They interact in a non-trivial way with the \ctikzset{mirror} and \ctikzset{invert} keys, so it's best not to use them directly.
1307
1308 \begin{quote}
1309 \showbordersfornode{generic}
1310 \showbordersfornode{resistor}
1311 \showbordersfornode{fulldiode}
1312 \showbordersfornode{vsource}
1313 \showbordersfornode{capacitivesens}
1314 \end{quote}
1315
1316 You can notice that the border anchors are a bit spaced out (this is useful because those anchors are used to position labels and annotations). You can override this if you need to reach exactly the border (whatever could that mean depends on the component) by using the key \IndexKey{bipoles/border margin}, which is a number that states how much the enclosing border is stretched out (default value is \texttt{1.1}). For example, setting
1317 \verb|\ctikzset{bipoles/border margin=1}| will make the border anchor coincide with the geographical shape:
1318
1319 \begin{quote}
1320 \ctikzset{bipoles/border margin=1}
1321 \showbordersfornode{generic}
1322 \showbordersfornode{resistor}
1323 \showbordersfornode{fulldiode}
1324 \showbordersfornode{vsource}
1325 \showbordersfornode{capacitivesens}
1326 \end{quote}
1327
1328 The above diagram has been obtained with the code:
1329
1330 \begin{lstlisting}
1331 \def\showbordersfornode#1{%
1332 \begin{circuitikz}[baseline, scale=0.8, transform shape]
1333 \node[#1shape, name=bip] at(0,0) {};
1334 \foreach \a in {0,30,...,359} \draw[red] (bip.\a) -- ++(\a:0.7)
1335 node[font=\tiny, fill=white, inner sep=0.5pt]{\a};
1336 \foreach \a in {15,45,...,359} \draw[red] (bip.\a) -- ++(\a:0.4);
1337 \node [font=\ttfamily\small, black, below] at (bip.-90)
1338 {\detokenize\expandafter{#1}};
1339 \end{circuitikz}}
1340 \ctikzset{bipoles/border margin=1}
1341 \showbordersfornode{generic} \showbordersfornode{resistor}
1342 \showbordersfornode{fulldiode} \showbordersfornode{vsource}
1343 \showbordersfornode{capacitivesens}
1344 \end{lstlisting}
1345
1346 \endgroup
1347
1348 \subsubsection{Relative coordinates}\label{sec:path-relative-coordinates}
1349
1350 As \href{https://github.com/circuitikz/circuitikz/issues/460}{noticed by user \texttt{septatrix}},
1351 although full relative coordinates after a component work as expected when using \texttt{++(x,y)}-style coordinates,
1352 often there are problems when using
1353 the \texttt{+(x,y)}-style coordinates (which are supposed to set a temporary relative coordinate and then going back to the starting point).
1354
1355 These kind of coordinate have in practice little use for the building of circuits, so have been only (very) lightly tested; avoid them if you can --- the behavior will depend not only on the \Circuitikz{} version, but also on the \TikZ{} layer underneath.
1356
1357 This behavior, although not optimal, was standard in \texttt{to} operation in plain \TikZ{} before version 3.1.8; it was changed by Henri Menke in later versions. Notice that the change revealed a problem in \Circuitikz{} that should hopefully be fixed in \texttt{v1.4.1}; for more details see \href{https://github.com/circuitikz/circuitikz/issues/569}{this issue on GitHub}.
1358
1359 You can see from the example below (notice the blue curve using a spline line). If all the vertical lines are at the left, the manual has been compiled with a new \Circuitikz{} and \TikZ. Otherwise, the red and/or blue curve will have the vertical line at the right (which in principle is wrong).
1360
1361 In the last (green) example, you can see a workaround using local path and the key \IndexKey{current point is local} that will work for older (and do not create problems in newer) versions.
1362
1363 \begin{ctikzExample}[varwidth=true, pos=t]
1364 Plotted using \TikZ\ version \pgfversion{} and Circui\TikZ\ version \pgfcircversion{}.
1365
1366 \begin{tikzpicture}
1367 \draw[color=red] (0,0) to[R] +(2,0) +(0,0) -- ++(0,-1);
1368 \end{tikzpicture}
1369 \qquad
1370 \begin{tikzpicture}
1371 \draw[color=blue] (0,0) to[out=30, in=120] +(2,0) +(0,0) -- ++(0,-1);
1372 \end{tikzpicture}
1373 \qquad
1374 \begin{tikzpicture}
1375 \draw[color=purple] (0,0) to[] +(2,0) +(0,0) -- ++(0,-1);
1376 \end{tikzpicture}
1377 \qquad
1378 \begin{tikzpicture}
1379 \draw[color=green!50!black] (0,0)
1380 {[current point is local] to[R] +(2,0)} +(0,0) -- ++(0,-1);
1381 \end{tikzpicture}
1382 \end{ctikzExample}
1383
1384
1385 \subsubsection{Customization}
1386 \label{sec:components-size}
1387
1388
1389 Pretty much all Circui\TikZ\ relies heavily on \texttt{pgfkeys} for value handling and configuration. Indeed, at the beginning of \texttt{circuitikz.sty} and in the file \texttt{pfgcirc.define.tex} a series of key definitions can be found that modify all the graphical characteristics of the package.
1390
1391 All can be varied using the \verb!\ctikzset! command, anywhere in the code.
1392
1393 Note that the details of the parameters that are not described in the manual can change in the future, so be ready to use a fixed version of the package (the ones with the specific number, like \verb|circuitikz-0.9.3|) if you dig into them.
1394
1395 \paragraph{Components size}\label{sec:pgfcircRlen}
1396 Perhaps the most important parameter is \IndexKey{bipoles/length} (default \SI{1.4}{cm}, you can use the currently set value with \verb!\ctikzvalof{bipoles/length}!), which
1397 can be interpreted as the length of a resistor (including reasonable connections): all other lengths are relative to this value. For instance:
1398
1399 \begin{ctikzExample}[pos=t,varwidth=true]
1400 \ctikzset{bipoles/length=1.4cm}
1401 \begin{circuitikz}[scale=1.2]\draw
1402 (0,0) node[anchor=east] {B}
1403 to[short, o-*] (1,0)
1404 to[R=20<\ohm>, *-*] (1,2)
1405 to[R=10<\ohm>, v=$v_x$] (3,2) -- (4,2)
1406 to[cI=$\frac{\si{\siemens}}{5} v_x$, *-*] (4,0) -- (3,0)
1407 to[R=5<\ohm>, *-*] (3,2)
1408 (3,0) -- (1,0)
1409 (1,2) to[short, -o] (0,2) node[anchor=east]{A}
1410 ;\end{circuitikz}
1411 \end{ctikzExample}
1412
1413 \begin{ctikzExample}[pos=t,varwidth=true]
1414 \ctikzset{bipoles/length=.8cm}
1415 \begin{circuitikz}[scale=1.2]\draw
1416 (0,0) node[anchor=east] {B}
1417 to[short, o-*] (1,0)
1418 to[R=20<\ohm>, *-*] (1,2)
1419 to[R=10<\ohm>, v=$v_x$] (3,2) -- (4,2)
1420 to[cI=$\frac{\si{\siemens}}{5} v_x$, *-*] (4,0) -- (3,0)
1421 to[R=5<\ohm>, *-*] (3,2)
1422 (3,0) -- (1,0)
1423 (1,2) to[short, -o] (0,2) node[anchor=east]{A}
1424 ;\end{circuitikz}
1425 \end{ctikzExample}
1426
1427 The changes on \IndexKey{bipoles/length} should, however, be globally applied to every path, because they affect every element --- including the poles. So you can have artifacts like the one in the second line below:
1428
1429 \begin{ctikzExample}
1430 \begin{circuitikz}[
1431 bigR/.style={R, bipoles/length=3cm}
1432 ]
1433 \draw (0,3) to [bigR, o-o] ++(4,0);
1434 \draw (0,1.5) to [bigR, o-o] ++(4,0)
1435 to[R, o-o] ++(2,0); % will fail here
1436 \draw (0,0) to [R, o-o] ++(4,0);
1437 \end{circuitikz}
1438 \end{ctikzExample}
1439
1440 Several groups of components, on the other hand, have a special \IndexKey{scale} parameter that can be used safely in this case (starting with 0.9.4 --- more groups of components will be added going forward); the key to use will be explained in the specific description of the components. For example, in the case of resistors you have \IndexKey{resistors/scale} available:
1441
1442 \begin{ctikzExample}
1443 \begin{circuitikz}[
1444 bigR/.style={R, resistors/scale=1.8}
1445 ]
1446 \draw (0,3) to [bigR, o-o] ++(4,0);
1447 \draw (0,1.5) to [bigR, o-o] ++(4,0)
1448 to[R, o-o] ++(2,0); % ok now
1449 \draw (0,0) to [R, o-o] ++(4,0);
1450 \end{circuitikz}
1451 \end{ctikzExample}
1452
1453 Never use \texttt{scale}, \texttt{xscale} or~\texttt{yscale} in a path-style component (i.e., inside a \texttt{to[...]}) command.
1454
1455 \paragraph{Mirroring and flipping path-style components}\label{sec:mirror-flip-path}
1456
1457 To change the orientation of path-style components, \emph{never} use \texttt{xscale=-1} nor~\texttt{yscale=-1}. That will mess up the path completely. Use the \IndexKey{mirror} and \IndexKey{invert} options:
1458 \begin{ctikzExample}
1459 \begin{tikzpicture}[N/.style={
1460 font=\tiny\ttfamily, above}]
1461 \draw (0,0) to [put] ++(0,2)
1462 node[N]{no modifier};
1463 \draw (1,0) to [put, mirror] ++(0,2)
1464 node[N]{mirror};
1465 \draw (2,0) to [put, invert] ++(0,2)
1466 node[N]{invert};
1467 \draw (3,0) to [put, mirror, invert] ++(0,2)
1468 node[N]{both};
1469 \end{tikzpicture}
1470 \end{ctikzExample}
1471
1472 \paragraph{Thickness of the lines}\label{sec:legacy-thickness} (globally)
1473
1474 The best way to alter the thickness of components is using styling, see section~\ref{sec:styling-thickness}. Alternatively, you can use ``legacy'' classes like \texttt{bipole}, \texttt{tripoles} and so on ---
1475 for example changing the parameter \IndexKey{bipoles/thickness} (default 2). The number is relative to the thickness of the normal lines leading to the component.
1476
1477 \begin{ctikzExample}[varwidth=true]
1478 \ctikzset{bipoles/thickness=1}
1479 \tikz \draw (0,0) to[C=1<\farad>] (2,0); \par
1480 \ctikzset{bipoles/thickness=4}
1481 \tikz \draw (0,0) to[C=1<\farad>] (2,0);
1482 \end{ctikzExample}
1483
1484 \paragraph{Shape of the components} (on a per-component-class basis)
1485 \label{par:shape-of-the}
1486
1487 The shape of the components are adjustable with a lot of parameters; in this manual we will comment the main ones, but you can look into the source files specified above to find more.
1488 Notice however that the ``internal'' parameters, the ones not commented in this manual, are not part of the public interface so they can disappear or change in future versions.
1489
1490 It is recommended to use the styling parameters to change the shapes; they are not so fine-grained (for example, you can change the width of resistor), but they are more stable and coherent across your circuit.
1491
1492 \begin{ctikzExample}[varwidth=true]
1493 \tikz \draw (0,0) to[R=1<\ohm>] (3,0); \par
1494 \ctikzset{resistors/width=2}
1495 \tikz \draw (0,0) to[R=1<\ohm>] (3,0);
1496 \end{ctikzExample}
1497
1498 To change the height, you can use (locally) the class scale parameter and the width; you can even define a style that will work across the resistor styles:
1499
1500 \begin{ctikzExample}[varwidth=true]
1501 \ctikzset{american}
1502 \tikz \draw (0,0) to[R=1<\ohm>] (4,0);
1503
1504 \ctikzset{tallR/.style={
1505 resistors/scale=2, resistors/width=0.4}}
1506 \tikz \draw (0,0) to[R=1<\ohm>, tallR] (4,0);
1507
1508 \ctikzset{european}
1509 \tikz \draw (0,0) to[R=1<\ohm>, tallR] (4,0);
1510 \end{ctikzExample}
1511
1512 \subsubsection{Descriptions}
1513 \label{sec:usage-descriptions}
1514
1515 The typical entry in the component list will be like this:
1516
1517 \begin{groupdesc}
1518 \circuitdescbip{resistor}{resistor, american style}{R, american resistor}
1519 \circuitdescbip[potentiometer]{pR}{potentiometer, american style}{pR, american potentiometer}( wiper/0/0.3 )
1520 \end{groupdesc}
1521
1522 where you have all the needed information about the bipole, with also no-standard anchors. If the component can be filled it will be specified in the description. In addition, as an example, the component shown will be filled with the option \texttt{fill=cyan!30!white}:
1523
1524 \begin{groupdesc}
1525 \circuitdescbip*{ammeter}{Ammeter}{}
1526 \end{groupdesc}
1527
1528 The \emph{Class} of the component (see section~\ref{sec:styling}) is printed at the end of the description.
1529
1530 Most path-style components can be used as a node-style components; to access them, normally you add a \texttt{shape} to the main name of component (for example, \texttt{diodeshape}). Sometimes though the ``node name'' is different, so it is specified in the description of each component.
1531
1532 \subsection{Node-style components}
1533 \label{sec:node-style-components}
1534 Node-style components (monopoles, multipoles) can be drawn at a specified point with this syntax, where \verb!#1! is the name of the component:
1535 \begin{lstlisting}
1536 \begin{circuitikz}
1537 \draw (0,0) node[#1,#2] (#3) {#4};
1538 \end{circuitikz}
1539 \end{lstlisting}
1540 \noindent
1541 Explanation of the parameters:\\
1542 \texttt{\#1}: component name\footnote{For using bipoles as nodes, the name of the node is \texttt{\#1shape}.} (mandatory)\\
1543 \texttt{\#2}: list of comma-separated options (optional)\\
1544 \texttt{\#3}: name of an anchor (optional)\\
1545 \texttt{\#4}: text written to the text anchor of the component (optional)\\
1546
1547
1548 \begin{framed}
1549 \noindent \textbf{Notice:} Nodes must have curly brackets at the end, even when empty. An optional anchor (\texttt{\#3}) can be defined within round brackets to be addressed again later on. And please don't forget the semicolon to terminate the \texttt{\textbackslash draw} command.
1550 \end{framed}
1551
1552 \begin{framed}
1553 \noindent\textbf{Also notice:} If using the \verb!\tikzexternalize! feature, as of \TikZ\ 2.1 all pictures must end with \verb!\end{tikzpicture}!. Thus you \emph{cannot} use the \verb!circuitikz! environment.
1554
1555 \noindent Which is OK: just use the environment \verb!tikzpicture!: everything will work there just fine.
1556 \end{framed}
1557
1558 \subsubsection{Mirroring and flipping}\label{sec:mirroring-and-flipping}
1559
1560 Mirroring and flipping of node components is obtained by using the \TikZ\ keys \IndexKey{xscale} and \IndexKey{yscale}. Notice that these parameters also affect text labels, so they need to be un-scaled by hand. Notice that you \textbf{do not} use \texttt{xscale} or~\texttt{yscale} in a path-style component, see section~\ref{sec:mirror-flip-path} for that case.
1561
1562 \begin{ctikzExample}
1563 \begin{circuitikz}[scale=0.7, transform shape]
1564 \draw (0,3) node[op amp]{OA1};
1565 \draw (3,3) node[op amp, xscale=-1]{OA2};
1566 \draw (0,0) node[op amp]{OA3};
1567 \draw (3,0) node[op amp, xscale=-1]{%
1568 \scalebox{-1}[1]{OA4}};
1569 \end{circuitikz}
1570 \end{ctikzExample}
1571
1572 To simplify this task, \Circuitikz{} has three helper macros ---\IndexKey[ctikzflip]{}\verb|\ctikzflipx{}|,
1573 \verb|\ctikzflipy{}|, and \verb|\ctikzflipxy{}|, that can be used to ``un-rotate''
1574 the text of nodes drawn with, respectively,
1575 \texttt{xscale=-1}, \texttt{yscale=-1}, and \texttt{scale=-1} (which is equivalent to
1576 \texttt{xscale=-1, yscale=-1}).
1577
1578 \begin{ctikzExample}
1579 \begin{circuitikz}[scale=0.7, transform shape]
1580 \draw (0,3) node[op amp]{OA1};
1581 \draw (3,3) node[op amp, xscale=-1]{\ctikzflipx{OA2}};
1582 \draw (0,0) node[op amp, yscale=-1]{\ctikzflipy{OA3}};
1583 \draw (3,0) node[op amp, scale=-1]{\ctikzflipxy{OA4}};
1584 \end{circuitikz}
1585 \end{ctikzExample}
1586
1587
1588 \subsubsection{Anchors}
1589 \label{sec:anchors}
1590
1591 Node components anchors vary a lot across the various kinds of components, so they will be described better after each category is presented in the manual. In general all components have geographic anchors (\texttt{north}, \texttt{north west}, \dots), but most of the other anchors are very component-specific.
1592
1593 \paragraph{Text anchors}\label{sec:node-text-anchors}
1594 Starting from version \texttt{v1.8.2}, you can always refer to the node text of a component using the anchor \texttt{.text} which will point to the baseline of the left edge of the typeset text. Using these anchors is considered an advanced topic, and should be avoided in the normal usage of the package.
1595
1596 \subsubsection{Descriptions}
1597 \label{sec:descriptions}
1598
1599 The typical entry in the component list will be like this:
1600 \begin{groupdesc}
1601 \circuitdesc{cute spdt down arrow}{Cute spdt down with arrow}{}
1602 \circuitdesc{npn}{\scshape npn}{}( B/180/0.2,C/0/0.2,E/0/0.2 )
1603 \end{groupdesc}
1604
1605 If the component can be filled it will be specified in the description. In addition, as an example, the component shown will be filled with the option \texttt{fill=cyan!30!white}:
1606
1607 \begin{groupdesc}
1608 \circuitdesc*{plain amp}{Plain amplifier}{}( out/45/0.3 )
1609 \end{groupdesc}
1610
1611 Sometime, components will expose internal (sub-)shapes that can be accessed with the syntax \texttt{\textsl{<node name>}-\textsl{<internal node name>}} (a dash is separating the node name and the internal node name); that will be shown in the description as a blue ``anchor'':
1612
1613 \begin{groupdesc}
1614 \circuitdesc{rotaryswitch}{Rotary switch}{}(in/-180/0.2, cin/145/0.2, center/-90/0.2, mid/0/0.4, out 1/0/0.2,
1615 cout 1/180/0.2)[out 1.n/90/0.2, out 4.w/0/0.3]
1616 \end{groupdesc}
1617
1618 The \emph{Class} of the component (see section~\ref{sec:styling}) is printed at the end of the description.
1619
1620 \subsection{Styling circuits and components}\label{sec:relative-size}\label{sec:styling}
1621
1622 You can change the visual appearance of a circuit by using a circuit style different from the default. For styling the circuit, the concept of \emph{class} of a component is key: almost every component has a class, and a style change will affect all the components of that class.
1623
1624 \begingroup % protect from style change the rest of the manual
1625
1626 Let's see the effect over a simple circuit\footnote{This is a just an example, the circuit is not intended to be functional.}.
1627
1628 \begin{lstlisting}[basicstyle=\scriptsize\ttfamily]
1629 \begin{circuitikz}[american, cute inductors]
1630 \node [op amp](A1){\texttt{OA1}};
1631 \draw (A1.-) to[short] ++(0,1) coordinate(tmp) to[R, l_=$R$] (tmp -| A1.out) to[short] (A1.out);
1632 \draw (tmp) to[short] ++(0,1) coordinate(tmp) to[C=$C$] (tmp -| A1.out) to[short] (A1.out);
1633 \draw (A1.+) to [battery2, invert] ++(0,-2.5) node[ground](GND){};
1634 \draw (A1.-) to [L=$L$] ++(-2,0) coordinate(tmp) to[sV, l=$v_s$, fill=yellow] (tmp |-GND) node[ground]{};
1635 \draw (A1.out) to[R=$R_s$] ++(2,0) coordinate(bb) to[I, l_=$I_B$, invert] ++(0,2) node[vcc](VCC){};
1636 \draw (bb) to[D, l=$D$, *-] ++(0,-2) coordinate(bb1) to[R=$R_m$] ++(0,-2) node[vee](VEE){};
1637 \draw (bb) --++(1,0) node[npn, anchor=B](Q1){Q1};
1638 \draw (bb1) --++(1,0) node[pnp, anchor=B](Q2){Q2};
1639 \draw (Q1.E) -- (Q2.E) ($(Q1.E)!0.5!(Q2.E)$) to [short, *-o, name=S] ++(2.5,0)
1640 node[right]{$v_{o_Q}$};
1641 \draw (S.s) to[european resistor, l=$Z_L$, *-] (S.s|-GND) node[ground]{};
1642 \draw (Q1.C) -- (Q1.C|-VCC) node[vcc]{\SI{5}{V}};
1643 \draw (Q2.C) -- (Q2.C|-VEE) node[vee]{\SI{-5}{V}};
1644 \end{circuitikz}
1645 \end{lstlisting}
1646
1647 This code, with the default parameters, will render like the following image.
1648
1649 \long\def\tmpcirc#1#2{% Define the circuit to reuse it
1650 % \begin{center}
1651 \begin{circuitikz}[american, cute inductors, #1]
1652 #2
1653 \node [op amp](A1){\texttt{OA1}};
1654 \draw (A1.-) to[short] ++(0,1) coordinate(tmp) to[R, l_=$R$] (tmp -| A1.out) to[short] (A1.out);
1655 \draw (tmp) to[short] ++(0,1) coordinate(tmp) to[C=$C$] (tmp -| A1.out) to[short] (A1.out);
1656 \draw (A1.+) to [battery2, invert, l=$v_{io}$] ++(0,-2.5) node[ground](GND){};
1657 \draw (A1.-) to [L=$L$] ++(-2,0) coordinate(tmp) to[sV, l=$v_s$, fill=yellow] (tmp |-GND) node[ground]{};
1658 \draw (A1.out) to[R=$R_s$] ++(2,0) coordinate(bb) to[I, l_=$I_B$, invert] ++(0,2) node[vcc](VCC){};
1659 \draw (bb) to[D, l=$D$, *-] ++(0,-2) coordinate(bb1) to[R=$R_m$] ++(0,-2) node[vee](VEE){};
1660 \draw (bb) --++(1,0) node[npn, anchor=B](Q1){Q1};
1661 \draw (bb1) --++(1,0) node[pnp, anchor=B](Q2){Q2};
1662 % this explodes in LWARP. Too complex to solve correctly, let's cheat
1663 % \draw (Q1.E) -- (Q2.E) ($(Q1.E)!0.5!(Q2.E)$) to [short, *-o, name=S] ++(2.5,0) node[right]{$v_{o_Q}$};
1664 \path (Q1.E) -- (Q2.E) coordinate[pos=0.5] (Qmid);
1665 \draw (Q1.E) -- (Q2.E) (Qmid) to[short,*-o,name=S] ++(2.5,0) node[right]{$v_{o_Q}$};
1666 \draw (S.s) to[european resistor, l=$Z_L$, *-] (S.s|-GND) node[ground]{};
1667 \draw (Q1.C) -- (Q1.C|-VCC) node[vcc]{\SI{5}{V}};
1668 \draw (Q2.C) -- (Q2.C|-VEE) node[vee]{\SI{-5}{V}};
1669 \end{circuitikz}%
1670 % \end{center}
1671 }
1672
1673 \tmpcirc{}{}
1674
1675 \subsubsection{Relative size}\label{sec:styling-scale}
1676
1677 Component size can be changed globally (see section~\ref{sec:pgfcircRlen}), or you can change their relative size by scaling a family of components by setting the key \texttt{\emph{class}/scale}; for example, you can change the size of all the diodes in your circuit by setting \IndexKey{diodes/scale} to something different from the default \texttt{1.0}.
1678
1679 Remember that if you use a global scale (be sure to read section~\ref{sec:bugs}!) you change the coordinate only, so using \texttt{scale=0.8} in the environment options you have:
1680
1681 \tmpcirc{scale=0.8}{}
1682
1683 If you want to scale all the circuit, you have to use also \IndexKey{transform shape}:
1684
1685 \tmpcirc{scale=0.8, transform shape}{}
1686
1687 Using relative sizes as described in section~\ref{sec:pgfcircRlen} enables your style for the circuit. For example, setting:
1688
1689 \begin{lstlisting}
1690 \ctikzset{resistors/scale=0.8, % smaller R
1691 capacitors/scale=0.7, % even smaller C
1692 diodes/scale=0.6, % small diodes
1693 transistors/scale=1.3} % bigger BJTs
1694 \end{lstlisting}
1695
1696 Will result in a (much more readable in Romano's opinion) circuit:
1697
1698 \tmpcirc{scale=0.8, transform shape}{\ctikzset{resistors/scale=0.8, capacitors/scale=0.7, diodes/scale=0.6, transistors/scale=1.3}}
1699
1700 \textbf{Warning:} relative scaling is meant to work for a reasonable range of stretching and shortening, so try to keep your scale parameter in the \texttt{0.5} to~\texttt{2.0} range (more or less). Bigger or smaller value can result in awkward shapes.
1701
1702 \subsubsection{Fill color}\label{sec:styling-fillcolor}
1703
1704 You can also set a default fill color for the components. You can use the keys \texttt{\emph{class}/fill} (which defaults to \texttt{none}, no fill, i.e. transparent component) for all fillable components in the library.
1705
1706 If you add to the previous styles the following commands:
1707
1708 \begin{lstlisting}
1709 \ctikzset{
1710 amplifiers/fill=cyan,
1711 sources/fill=green,
1712 diodes/fill=red,
1713 resistors/fill=violet,
1714 }
1715 \end{lstlisting}
1716
1717 you will have the following circuit (note that the first generator is \emph{explicitly} set to be yellow,
1718 so if will not be colored green!):
1719
1720 \tmpcirc{scale=0.8, transform shape}{\ctikzset{resistors/scale=0.8, capacitors/scale=0.7, diodes/scale=0.6, transistors/scale=1.3,%
1721 amplifiers/fill=cyan, sources/fill=green, diodes/fill=red, resistors/fill=violet,}}
1722
1723 Please use this option with caution. Although two-colors circuits can be nice, using more than that can become rapidly unbearable.
1724 Old textbooks used the two-color style quite extensively, filling with a kind of light blue like \texttt{blue!30!white} ``closed'' components, but that was largely to hinder black-and-white photocopying\dots
1725
1726 \subsubsection{Line thickness}\label{sec:styling-thickness}
1727
1728 You can change the line thickness for any class of component in an independent way. The default standard thickness of components is defined on a loose ``legacy'' category (like \texttt{bipoles}, \texttt{tripoles} and so on, see section~\ref{sec:legacy-thickness}); to override that you set the key \texttt{\emph{class}/thickness} to any number. The default is \texttt{none}, which means that the old way of selecting thickness is used.
1729
1730 For example, \emph{amplifiers} have the legacy class of \texttt{tripoles}, as well as transistors and tubes. By default they are drawn with thickness 2 (relative to the base linewidth). To change them to be thicker, you can for example add to the previous style
1731
1732 \begin{lstlisting}
1733 \ctikzset{amplifier/thickness=4}
1734 \end{lstlisting}
1735
1736 \tmpcirc{scale=0.8, transform shape}{\ctikzset{resistors/scale=0.8, capacitors/scale=0.7, diodes/scale=0.6, transistors/scale=1.3,%
1737 amplifiers/fill=cyan, sources/fill=green, diodes/fill=red, resistors/fill=violet,
1738 amplifiers/thickness=4}}
1739
1740 \textbf{Caveat:} not every component has a ``class'', so you have to play with the available ones (it's specified in the component description) and with the absolute values to have the circuit following your taste. A bit of experimentation will create a kind of \emph{style options} that you could use in all your documents.
1741
1742 \subsubsection{Style files}
1743 \label{sec:style-files}
1744
1745 When using styles, it is possible to use \emph{style files} (see section~\ref{sec:writingstylefiles}), that then you can load with the command \verb|\ctikzloadstyle|\IndexKey[ctikzloadstyle]{}. For example, in the distribution you have a number of style files: \texttt{legacy}, \texttt{romano}, \texttt{example}. When you load a style name \texttt{\emph{name}}, you will have available a style called \texttt{\emph{name} circuit style} that you can apply to your circuits.
1746 The last style loaded is not enacted --- you have to explicitly do it if you want the style used by default, by putting for example in the preamble:
1747
1748 \begin{lstlisting}[numbers=none]
1749 \ctikzloadstyle{romano}
1750 \tikzset{romano circuit style}
1751 \end{lstlisting}
1752
1753 Please notice that the style is at \TikZ{} level, not \Circuitikz --- that let's you use it in the top option of the circuit, like:
1754
1755 \begin{lstlisting}[numbers=none]
1756 \begin{circuitikz}[legacy circuit style,
1757 ..., ]
1758 ...
1759 \end{circuitikz}
1760 \end{lstlisting}
1761
1762 If you just want to use one style, you can load and activate it in one command with
1763
1764 \begin{lstlisting}[numbers=none]
1765 \ctikzsetstyle{romano}
1766 \end{lstlisting}
1767
1768 The \texttt{example} style file will simply make the amplifiers filled with light blue:
1769
1770 \begin{ctikzExample}
1771 \begin{circuitikz}
1772 \draw (0,0) node[op amp]{OA1};
1773 \end{circuitikz}
1774 \ctikzloadstyle{example}
1775 \begin{circuitikz}[example circuit style]
1776 \draw (0,0) node[op amp]{OA1};
1777 \end{circuitikz}
1778 \end{ctikzExample}
1779 \ctikzloadstyle{legacy}
1780 \ctikzloadstyle{romano}
1781
1782 The style \texttt{legacy} is a style that set (most) of the style parameters to the default, and \texttt{romano} is a style used by one of the authors; you can use these styles as is or you can use them to learn to how to write new file style following the instructions in section~\ref{sec:writingstylefiles}. In the next diagrams, the left hand one is using the \texttt{romano circuit style} and the rigth hand one the legacy style.
1783
1784 \fbox{\tmpcirc{scale=0.6, transform shape, romano circuit style}{}}
1785 \fbox{\tmpcirc{scale=0.6, transform shape, legacy circuit style}{}}
1786
1787 \endgroup % restore state before example of sizing
1788
1789 \subsubsection{Style files: how to write them}\label{sec:writingstylefiles}
1790
1791 The best option is to start from \texttt{ctikzstyle-legacy.tex} and edit your style file from it. Then you just put it in your input path and that's all. If you want, you can contribute your style file to the project.
1792
1793 Basically, to write the style \texttt{example}, you edit a file named \texttt{ctikzstyle-romano.tex} with will define and enact \TikZ\ style with name \texttt{example circuit style}; basically it has to be something along this:
1794
1795 \lstinputlisting[frame=single, framesep=10pt]{ctikzstyle-example.tex}
1796
1797 This kind of style will \emph{add} to the existing style. If you want to have a style that \emph{substitutes} the current style, you should do like this:
1798
1799 \begin{lstlisting}[frame=single, framesep=10pt]
1800 \ctikzloadstyle{legacy}% start from a known state
1801 \tikzset{romano circuit style/.style={%
1802 legacy circuit style, % load the legacy style
1803 \circuitikzbasekey/.cd,%
1804 % Resistors
1805 resistors/scale=0.8,
1806 [...]
1807 }}
1808 \end{lstlisting}
1809
1810 If you want to add a setting to your style file that has been recently added to the package (for example, the thyristor compact shapes added in \texttt{1.3.5}), but you want your style file to be still compatible with older versions of \Circuitikz, you can use the \texttt{.try} statement:
1811
1812 \begin{lstlisting}[frame=single, framesep=10pt]
1813 % Diodes
1814 diodes/scale=0.6,
1815 diodes/thickness=1.0,
1816 thyristor style/.try=compact,
1817 \end{lstlisting}
1818
1819 Or, in case of new values of existing ``choice'' keys, you can use the syntax:
1820
1821 \begin{lstlisting}[frame=single, framesep=10pt]
1822 % Logic ports
1823 logic ports/ieee/.try,
1824 % this way of setting the key does nothing if ieee option
1825 % does not exist; logic ports/.try=ieee does not work
1826 % if the key exists but the value is not defined
1827 logic ports/scale=1.0,
1828 \end{lstlisting}
1829
1830
1831 \subsection{Subcircuits}\label{sec:subcircuits}
1832
1833 Starting from version \texttt{1.3.5}, there is support for generating sub-circuits, or circuit blocks. The creation and use of subcircuits is somewhat limited, to keep them simple and easy to define and maintain.
1834
1835 A subcircuit is basically a path (and just one path!) of generic \TikZ{} instructions, with a series of accessible coordinates that behave more or less like anchors in the ``real'' shapes. The basic limitation is that a subcircuit can be moved, replicated and placed around but it can't be easily personalized. Even if scaling and rotation is in principle possible, it is not easily done. Nevertheless, they can be quite useful to build complex components and reusable blocks.
1836
1837 \subsubsection{Subcircuit definition}
1838 \label{sec:subcircuit-definition}
1839
1840 To define a block you use the \verb|\ctikzsubcircuitdef| macro; this macro has 3 arguments:
1841 \begin{itemize}
1842 \item the first argument is the name of the subcircuit, and it must form a valid TeX command name when prepended with a backslash: so just letters (no spaces, nor numbers, nor symbols like underscores, etc.);
1843 \item the second one is a comma-separated list of anchor names; here you can use whatever you can use for naming a coordinate or a node (so it's much more relaxed than the first one);
1844 \item finally, the commands that will draw the circuit. You must suppose you are in a \verb|\draw| command, with the start coordinate already set-up. You can (and should) use \verb|#1| as the name of the current node, and you \emph{must} define the coordinates of all the anchors listed before as \texttt{coordinate(\#1-\emph{anchorname})}. You should \textbf{not} finish the path here and use \textbf{only relative coordinates} or \textbf{named ones}.
1845 \end{itemize}
1846
1847 Let's see that with an example:
1848
1849 \begin{ctikzExample}[exec outside]
1850 \ctikzsubcircuitdef{optovishay}{in 1, out 1, in 2, out 2, center}{%
1851 % reference anchor is -center
1852 coordinate(#1-center)
1853 (#1-center) +(-1.2,-1) rectangle +(1.2,1)
1854 (#1-center) ++(-1.2,0.8) coordinate (#1-in 1)
1855 (#1-center) ++(-1.2,-0.8) coordinate (#1-in 2)
1856 (#1-center) ++(1.2,0.8) coordinate (#1-out 1)
1857 (#1-center) ++(1.2,-0.8) coordinate (#1-out 2)
1858 (#1-center) ++(0,1) coordinate (#1-up)
1859 (#1-in 1) -- ++(0.5,0) coordinate(#1-tmp)
1860 to[leD*, diodes/scale=0.6, led arrows from cathode]
1861 (#1-tmp|- #1-in 2) -- (#1-in 2)
1862 (#1-out 1) -- ++(-0.5,0) coordinate(#1-tmp)
1863 to[pD*, diodes/scale=0.4, mirror] ++(0,-0.5)
1864 edge[densely dashed] ++(0,-0.533) ++(0,-0.566)
1865 to[pD*, diodes/scale=0.4,mirror] (#1-tmp|- #1-out 2) -- (#1-out 2)
1866 % leave the position of the path at the center
1867 (#1-center)
1868 }
1869 \end{ctikzExample}
1870
1871 Our element is a symbol for an optocoupler; in this case is the symbol used for one cell of the double \href{https://www.vishay.com/docs/84639/vo1263aa.pdf}{Vishay vo1263 device}.
1872
1873 The name of the subcircuit is \texttt{optovishay} --- notice we can use only letters here, upper or lowercase, and nothing more.
1874 Then we have a series of anchor names; here we can use letters, numbers, spaces and some symbol --- but avoid the dot (\texttt{.}) and the hyphen (\texttt{-}).
1875 Additionally, the anchor named \texttt{subckt@reference} is reserved and shouldn't be used.
1876 If you use spaces, be on the safe side and \emph{never} use two or more consecutive spaces.
1877
1878 After that, you have to draw your subcircuit as if you were into a \verb|\draw| command, starting from a generic point.
1879 In this case, we decide to draw the circuit around this generic point so that it will result to be the center of the block; so as a first thing, we ``mark'' the position of the center anchor, with \texttt{coordinate(\#1-center)}.
1880 The \texttt{\#1} will be substituted with the specific name of the subcircuit's instance later --- so if you then call one instance of the optocoupler \texttt{opto1}, that coordinate will be called \texttt{opto1-center}.
1881
1882 We continue by defining all our anchors (there is no need to do that at the start, but it's handy because then you can use them).
1883 You \textbf{must} define all the anchors!
1884
1885 \textbf{Important}: all the coordinates used must be either relative, or named in the form \texttt{\#1-something}; absolute coordinate will not work when instantiating the block.
1886 The block is thought to be used inside a path specification, so the idea is not to end the path --- that means that changing line styles or colors is at best difficult.
1887 You can still use \texttt{edge}s, though (see~\ref{faqs:dashed}).
1888
1889 After that, we draw our circuit; in this case a LED and a couple of smaller photodiodes will do.
1890 We also define a coordinate \texttt{-up} (you can define more coordinates, in addition to the anchors, or name elements with \texttt{name=\#1-\emph{something}} for later access) for adding text.
1891
1892 \subsubsection{Using the subcircuit}
1893 \label{sec:using-the-subcircuit}
1894
1895 To use the subcircuit, an additional step is needed. Somewhere you have to \emph{activate} it. This is needed to calculate the relative positions of anchors using the current set of style parameters. The normal place is to activate it just before usage; to do that you use the command \verb|\ctikzsubcircuitactivate| with the name of the subcircuit. That will define a new command, \texttt{\textbackslash\emph{nameofthesubcircuit}} that you can use then in your paths.
1896
1897 So to check your subcircuit while defining it you can use this simple snippet:
1898 \begin{ctikzExample}
1899 \ctikzsubcircuitactivate{optovishay}
1900 \begin{tikzpicture}
1901 \draw (0,0) \optovishay{one}{};
1902 \node [above] at (one-up) {O1};
1903 \draw[color=blue] (one-out 1) -- ++(1,0)
1904 \optovishay{two}{in 1};
1905 \node [above] at (two-up) {O2};
1906 \end{tikzpicture}
1907 \end{ctikzExample}
1908
1909 \paragraph{Scaling, flipping and rotating subcircuits}
1910 \label{par:scaling-flipping-and}
1911
1912 To scale and rotate a subcircuit you have to include it into a \texttt{scope} with the appropriate \texttt{scale} and rotation commands. Notice that, as in general in \Circuitikz, global scales that affect rotation works only if \IndexKey{transform shape} is issued (see~\ref{sec:bugs}); nesting \texttt{transform shape} normally works, but it has been really lightly tested.
1913
1914 \begin{ctikzExample}
1915 \ctikzsubcircuitactivate{optovishay}
1916 \begin{tikzpicture}[scale=0.8, transform shape]
1917 \draw (0,0) \optovishay{three}{};
1918 \draw (three-out 1) -- ++(0.5,0) coordinate(here);
1919 \begin{scope}[xscale=-1,rotate=-45,transform shape]
1920 \draw (here) \optovishay{four}{out 1};
1921 \end{scope}
1922 \draw[blue] (three-out 2) -| (four-out 2);
1923 \end{tikzpicture}
1924 \end{ctikzExample}
1925
1926 \subsubsection{Parameters in subcircuits}
1927 \label{sec:parameters-in-subcircuits}
1928
1929 There are no additional parameters definable for subcircuit shapes; this is a bit of a pity, because sometimes they could be useful, especially for labels of objects.
1930 Given the need to use \texttt{transform shape} to translate and rotate them, though, it is better not to add invariant-direction things (like text) into the subcircuit, unless you are sure you will just translate them.
1931 One possibility is to use additional macros and anchors for positioning, like in the following example.
1932
1933 Suppose you have defined
1934
1935 \begin{ctikzExample}[exec outside]
1936 \ctikzsubcircuitdef{divider}{in, out}{%
1937 coordinate (#1-in) to[R, l=~, name=#1-rh, -*] ++(2,0)
1938 coordinate(#1-tmp) to[R, l=~, name=#1-rl] ++(0,-2)
1939 node[tlground]{} (#1-tmp) --++(0.5,0) coordinate(#1-out)
1940 }
1941 \end{ctikzExample}
1942
1943 then you can additionally define:
1944
1945 \begin{ctikzExample}[exec outside]
1946 \newcommand{\mydiv}[4]{
1947 \divider{#1}{#2} (#1-rh.n) node[above]{#3}
1948 (#1-rl.n) node[right]{#4} (#1-out)
1949 }
1950 \end{ctikzExample}
1951
1952 And finally do:
1953 \begin{ctikzExample}
1954 \begin{tikzpicture}
1955 \ctikzsubcircuitactivate{divider}
1956 \draw (0,0) \mydiv{a}{in}{$R_1$}{$R_2$};
1957 \draw (a-out) -- \mydiv{b}{in}{$R_3$}{$R_4$};
1958 \end{tikzpicture}
1959 \end{ctikzExample}
1960
1961 \subsubsection{Using \texttt{pic}s (with parameters)}
1962 \label{sec:using-pic-s}
1963
1964 \begingroup % to isolate the definition of pics/divider
1965 \tikzset{pics/divider/.style n args={2}{
1966 code={
1967 \draw (0,0) coordinate(-in) to[R=#1, -*] ++(2,0)
1968 coordinate(-corner)
1969 to[R=#2] ++(0,-2) node[tlground]{}
1970 (-corner) -- ++(0.5,0) coordinate(-out);
1971 }}}
1972
1973 Since \texttt{v1.8.0}\footnote{See \href{https://github.com/circuitikz/circuitikz/issues/866}{this issue} for more details; be warned that they will \textbf{not} work at all in earlier versions.} you can also use the standard \TikZ{} \IndexKey{pic}s as subcircuits, with the advantage to be able to define (up to 9) parameters.
1974
1975 \begin{ctikzExample}
1976 \tikzset{pics/divider/.style n args={2}{
1977 code={
1978 \draw (0,0) coordinate(-in) to[R=#1, -*] ++(2,0)
1979 coordinate(-corner)
1980 to[R=#2] ++(0,-2) node[tlground]{}
1981 (-corner) -- ++(0.5,0) coordinate(-out);
1982 }}}
1983 \begin{tikzpicture}[]
1984 \draw (0,0) pic(one){divider={$R_1$}{$R_2$}}
1985 (one-out) pic(two){divider={$R_3$}{$R_4$}};
1986 \node [above] at (one-corner) {$v_{12}$};
1987 \end{tikzpicture}
1988 \end{ctikzExample}
1989
1990 The main limitation of \texttt{pic}s is that natively they do not have options to place them with internal anchors, like the \texttt{anchor=\dots} options of nodes. Fortunately, Andrew Stacey's fine \href{https://ctan.org/pkg/tikzmark?lang=en}{\texttt{tikzmark} library} provides that function. You have to just add \verb!\usetikzlibrary{tikzmark}! in your preamble, and then add the option to the pic invocation:
1991
1992 \begin{lstlisting}[numbers=none]
1993 ... pic[pic anchor=(-corner)] {divider=...}
1994 \end{lstlisting}
1995
1996 For example, suppose you want to attach your divider to a BJT base:
1997
1998 \begin{ctikzExample}
1999 \begin{tikzpicture}[]
2000 %% \usetikzlibrary{tikzmark}
2001 \draw (0,0) node[npn](Q){}
2002 (Q.B) pic[pic anchor=(-out)]{divider={$R_1$}{$R_2$}};
2003 \end{tikzpicture}
2004 \end{ctikzExample}
2005
2006 Notice that \IndexKey{pic anchor} needs an additional compilation pass to position the subcircuit correctly.
2007 This double pass is usually not a problem, but be prepared to have the pic positioned incorrectly after the first run.
2008 For the curious, this is needed because before drawing the pic, `tikzmark` does not know where the anchors are.
2009 So, it saves their positions and adjusts them in the next run.
2010 With native subcircuits, the call to \verb!\ctikzsubcircuitactivate! is doing the same for every possible anchor \emph{before} using it.\footnote{Native shapes do not need that because you must define the anchor positions explicitly when defining the shape.}
2011
2012 In some extreme conditions, when the \IndexKey{pic} is complex and there are many calculations (especially true in case of rotations), it could happens that the two-pass compilation can become unstable: that is, every time a slightly, invisible difference in coordinates is written out.
2013 That can confuse automatic compilations tools, like for example \texttt{latexmk}, and induce a very high number of recompilations or even errors.
2014 With a recent enough \IndexKey{tikzmark}\footnote{The version must be \textbf{greater} than \texttt{v1.15}, not yet released on May 30, 2025: see \href{https://github.com/loopspace/tikzmark/issues/21}{this GitHub issue for details}; use a development version if you need it --- the instructions are on the same GitHub project.} you can avoid this by rounding the precision of the coordinate calculations to, say, 2 decimal places (which is \qty{0.01}{pt}, basically invisible in normal conditions) with the option:
2015
2016 \begin{lstlisting}[numbers=none]
2017 ... pic[tikzmark round=2, rotate=45, pic anchor=(-corner)] {divider=...}
2018 \end{lstlisting}
2019
2020 Finally, if you want to rotate the pic (warning: lightly tested!) remember that you need \texttt{transform shape} to have a correct behavior.
2021
2022 \begin{ctikzExample}
2023 \begin{tikzpicture}[]
2024 \draw (0,0)
2025 pic(one){divider={$R_1$}{$R_2$}} (one-out)
2026 pic[rotate=45, transform shape](two)
2027 {divider={$R_A$}{$R_B$}};
2028 \end{tikzpicture}
2029 \end{ctikzExample}
2030 \endgroup % to isolate the definition of pics/divider
2031
2032 \subsubsection{Using macros}
2033 \label{sec:using-macros}
2034
2035 Sometimes, a good old \LaTeX{} macro can solve a problem instead of designing a new component.
2036 For example, GitHub's user Patrick Jansky asked for a generic ``chopper'' block;\footnote{%
2037 See \href{https://github.com/circuitikz/circuitikz/issues/828}{the original issue on GitHub}.}
2038 Unfortunately, this kind of block is quite difficult to implement as a node: it should change size and orientation on the base of the ``port'' terminals you need.
2039
2040 In this case, probably an old-fashioned macro, using partway coordinate specifiers,
2041 \footnote{See \href{https://tikz.dev/tikz-coordinates\#sec-13.5.3}{\TikZ{} manual section 13.5}}
2042 could be the best option for this task. Below, one possible example (not optimized at all!).
2043
2044 \begin{ctikzExample}[only code, store=ChopperByTerminals]
2045 \NewDocumentCommand{\ChopperByTerminals}{O{} O{0.2cm} m m m}{%
2046 % #1 -> options to the draw command
2047 % #2 -> half width
2048 % by default is drawn to the right (if vertical), to the left if #2 is negative
2049 % If horizontal, by default is above, below if #2 is negative
2050 % #3 -> terminal A on port 1
2051 % #4 -> terminal B on port 2
2052 % #5 -> name for the "anchors"
2053 \coordinate(#5-P1A) at (#3);
2054 \coordinate(#5-P1B) at (#4);
2055 % the center of the block is midway P1A to P1B, at distance #2 at 90 clockwise
2056 % degrees from the center of the line
2057 \coordinate(#5-C1) at ($(#5-P1A)!0.5!(#5-P1B)$);
2058 \coordinate(#5-C) at ($(#5-C1)!#2!90:(#5-P1B)$);
2059 \coordinate(#5-P2B) at ($(#5-P1A)!2!(#5-C)$);
2060 \coordinate(#5-P2A) at ($(#5-P1B)!2!(#5-C)$);
2061 \coordinate(#5-T1A) at ($(#5-P1B)!1.2!(#5-P1A)$);
2062 \coordinate(#5-T1B) at ($(#5-P1A)!1.2!(#5-P1B)$);
2063 \coordinate(#5-T2A) at ($(#5-P2B)!1.2!(#5-P2A)$);
2064 \coordinate(#5-T2B) at ($(#5-P2A)!1.2!(#5-P2B)$);
2065 \coordinate(#5-CKA) at ($(#5-T1A)!0.5!(#5-T2A)$);
2066 \coordinate(#5-CKB) at ($(#5-T1B)!0.5!(#5-T2B)$);
2067 \coordinate(#5-C2) at ($(#5-P2A)!0.5!(#5-P2B)$);
2068 \draw [draw, thick, fill=white, #1] (#5-T1A) rectangle (#5-T2B);
2069 \draw [draw, thick, line join=round, #1] (#5-P1A) -- (#5-P2B) --
2070 (#5-P1B) -- (#5-P2A) -- (#5-P1A);
2071 }
2072 \end{ctikzExample}
2073
2074 You can use this definition as follows, for example:
2075
2076 \begin{ctikzExample}[pos=b, restore=ChopperByTerminals, dollar]
2077 \begin{tikzpicture}[]
2078 \node[op amp](A) at (0,0) {};
2079 \ChopperByTerminals[draw=red][-0.2cm]{A.-}{A.+}{chopper in}
2080 \draw [red, <-] (chopper in-CKA) -- ++(0,.5) node[above]{$f_c$};
2081 \ChopperByTerminals[draw=red]{[xshift=1.2cm]A.-}{[xshift=1.2cm]A.+}{chopper out}
2082 \draw [red, <-] (chopper out-CKA) -- ++(0,.5) node[above]{$f_c$};
2083 %Try another one
2084 \draw (4,1) node[npn](Q1){} (7,1) node[npn, xscale=-1](Q2){};
2085 \coordinate (Qcenter) at ($(Q1.E)!0.5!(Q2.E)$);
2086 \ChopperByTerminals[][-0.2cm]{Q1.E}{Q2.E}{cE}
2087 \draw [<-] (cE-CKA) -- ++(-0.5,0) node[left]{$f_c$};
2088 % pseudo-anchors
2089 \ChopperByTerminals[draw=blue][-1cm]{4,-1.25}{7,-1.25}{C}
2090 \foreach \a in {P1A, P1B, P2A, P2B, CKA, CKB, C, C1, C2}
2091 \node[circle, draw, inner sep=1pt, pin={[font=\tiny, fill=white]60:C-\a}]
2092 at (C-\a) {};
2093 \end{tikzpicture}
2094 \end{ctikzExample}
2095
2096
2097 \section{The components: list}
2098 \label{sec:the-components-list}
2099
2100 This section is dedicated to the full list of available components.
2101
2102 \subsection{Grounds and supply voltages}
2103 \label{sec:grounds-and-supply}
2104
2105 Ground symbols and power supplies --- they have two different classes for styling.
2106
2107 \subsubsection{Grounds}
2108 \label{sec:grounds}
2109
2110 For the grounds, the \texttt{center} anchor is put on the connecting point of the symbol, so that you can use them directly in a \texttt{path} specification.
2111
2112 \begin{groupdesc}
2113 \circuitdesc{ground}{Ground}{}( center/0/0.3 )
2114 \circuitdesc{tlground}{Tailless ground}{}( center/0/0.3 )
2115 \circuitdesc{rground}{Reference ground}{}
2116 \circuitdesc*{sground}{Signal ground}{}
2117 \circuitdesc{tground}{Thicker tailless reference ground}{}
2118 \circuitdesc{nground}{Noiseless ground}{}
2119 \circuitdesc*{pground}{Protective ground}{}
2120 \circuitdesc{cground}{Chassis ground\footnotemark}{}
2121 \footnotetext{These last three were contributed by Luigi ``Liverpool''}
2122 \circuitdesc{eground}{European style ground}{}
2123 \circuitdesc{eground2}{European style ground, version 2\footnotemark}{}
2124 \footnotetext{These last two were contributed by \texttt{@fotesan}}
2125 \end{groupdesc}
2126
2127 \paragraph{Grounds anchors}
2128 \label{par:grounds-anchors}
2129
2130 Anchors for grounds are a bit strange, given that they have the \texttt{center} spot at the same location than \texttt{north} and all the ground will develop ``going down'':
2131
2132 \showanchors[baseline]{ground, scale=1.5}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
2133 south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4)
2134 \showanchors[baseline]{ground, scale=1.5}{}(left/135/0.2, right/45/0.2, center/-180/0.2)
2135
2136 \paragraph{Grounds customization}
2137 \label{par:grounds-customization}
2138
2139 You can change the scale of these components (all the ground symbols together) by setting the key \IndexKey{grounds/scale} (default \texttt{1.0}).
2140
2141 \subsubsection{Power supplies}
2142 \label{sec:power-supplies}
2143
2144 \begin{groupdesc}
2145 \circuitdesc{vcc}{VCC/VDD}{}
2146 \circuitdesc{vee}{VEE/VSS}{}
2147 \end{groupdesc}
2148
2149 The power supplies are normally drawn with the arrows shown in the list above.
2150
2151 \paragraph{Power supply anchors}
2152 \label{par:power-supply-anchors}
2153
2154 They are similar to ground anchors, and the geographical anchors are correct only for the default arrow.
2155
2156 \showanchors[baseline]{vcc, scale=1.5}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
2157 south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4)
2158 \showanchors[baseline]{vcc, scale=1.5}{}(left/135/0.2, right/45/0.2, center/-180/0.2)
2159
2160
2161 \paragraph{Power supplies customization}
2162 \label{par:power-supplies-customization}
2163
2164 You can change the scale of the power supplies by setting the key \IndexKey{power supplies/scale} (default \texttt{1.0}).
2165
2166 Given that the power supply symbols are basically arrows, you can change them using all the options of the \texttt{arrows.meta} package (see the \href{https://tikz.dev/tikz-arrows}{\TikZ\ manual} for details) by changing the keys \IndexKey{monopoles/vcc/arrow} and \IndexKey{monopoles/vee/arrow} (the default for both is \texttt{legacy}, which will use the old code for drawing them).
2167 Note that the anchors are at the start of the connecting lines, and that geographical anchors are just approximation if you change the arrow symbol!
2168
2169 \begin{ctikzExample}
2170 \begin{circuitikz}
2171 % next macro is available in ctikzmanutils.sty
2172 \def\coord(#1){\showcoord(#1)<0:0.3>}
2173 \draw (0,0)
2174 node[vcc](vcc){VCC} \coord(vcc) ++(2,0)
2175 node[vee](vee){VEE} \coord(vee);
2176 \ctikzset{monopoles/vcc/arrow={Stealth[red, width=6pt, length=9pt]}}
2177 \ctikzset{monopoles/vee/arrow={Latex[blue]}}
2178 \draw (0,-2)
2179 node[vcc](vcc){VCC} \coord(vcc) ++(2,0)
2180 node[vee](vee){VEE} \coord(vee);
2181 \end{circuitikz}
2182 \end{ctikzExample}
2183
2184 However, arrows in \TikZ{} are in the same class with the line thickness, so they do not scale with neither the class \texttt{power supplies} scale nor the global scale parameter (you should use \texttt{transform canvas=\{scale\dots\}} for this).
2185
2186 If you want the arrows to behave like the legacy symbols (which are shapes), \emph{only in the arrow definitions}, you can use the special length parameter \verb|\scaledwidth|\footnote{Thanks to @Schrödinger's cat on \href{https://tex.stackexchange.com/a/506249/38080}{\TeX{} stackexchange site}} in the arrow definition, which correspond to the width of the legacy \texttt{vcc} or \texttt{vee}. Compare the effects on the following circuit.
2187
2188 \begin{ctikzExample}[pos=t]
2189 \ctikzset{%
2190 monopoles/vcc/arrow={Triangle[width=0.8*\scaledwidth, length=\scaledwidth]},
2191 monopoles/vee/arrow={Triangle[width=6pt, length=8pt]},
2192 }
2193 \begin{circuitikz}[baseline=(vo.center)]
2194 \node [ocirc](TW) at (0,0) {};
2195 \draw (TW.east) -- ++(1,0) node[midway, above]{$v_i$} node[op amp, anchor=-](A1){};
2196 \draw (A1.up) -- ++(0, 0.3) node[vcc]{\SI{+10}{V}};
2197 \draw (A1.down) -- ++(0,-0.3) node[vee]{\SI{-10}{V}};
2198 \draw (A1.+) -- ++(-0.5,0) to[battery2, invert, l_=\SI{2}{V}] ++(0,-1) node[ground]{};
2199 \draw (A1.out) to[short, -o] ++(0.5,0) node[above](vo){$v_o$};
2200 \end{circuitikz} \qquad
2201 \begin{circuitikz}[baseline=(vo.center), scale=0.6, transform shape]
2202 \node [ocirc](TW) at (0,0) {};
2203 \draw (TW.east) -- ++(1,0) node[midway, above]{$v_i$} node[op amp, anchor=-](A1){};
2204 \draw (A1.up) -- ++(0, 0.3) node[vcc]{\SI{+10}{V}};
2205 \draw (A1.down) -- ++(0,-0.3) node[vee]{\SI{-10}{V}};
2206 \draw (A1.+) -- ++(-0.5,0) to[battery2, invert, l_=\SI{2}{V}] ++(0,-1) node[ground]{};
2207 \draw (A1.out) to[short, -o] ++(0.5,0) node[above](vo){$v_o$};
2208 \end{circuitikz}
2209 \end{ctikzExample}
2210
2211
2212 \subsection{Resistive bipoles}
2213 \label{sec:resistive-bipoles}
2214
2215 \begin{groupdesc}
2216 \circuitdescbip{short}{Short circuit}{}
2217 \circuitdescbip{open}{Open circuit}{}
2218 \circuitdescbip*{generic}{Generic (symmetric) bipole}{}
2219 \circuitdescbip*{xgeneric}{Crossed generic (symmetric) bipole}{}
2220 \circuitdescbip*{sgeneric}{Slashed generic bipole}{}
2221 \circuitdescbip*{singeneric}{Sine generic bipole\footnotemark}{}
2222 \footnotetext{Contributed by \href{https://github.com/circuitikz/circuitikz/pull/907}{Jakob Leide on GitHub}}
2223 \circuitdescbip*{tgeneric}{Tunable generic bipole}{}
2224 \circuitdescbip*{ageneric}{Generic asymmetric bipole}{}
2225 \circuitdescbip*{memristor}{Memristor}{Mr}
2226 \end{groupdesc}
2227
2228 Both \IndexKey{shortshape} and \IndexKey{openshape} are not really supposed to be used; they are dummy shapes used as placeholders for the path-drawing routines.
2229
2230 If \IndexKey{americanresistors} option is active (or the style \IndexKey[american resistors]{[american resistors]} is used --- this is the default for the package), the resistors are displayed as follows:
2231 \begin{groupdesc}
2232 \ctikzset{resistor=american}
2233 \circuitdescbip[resistor]{R}{Resistor}{american resistor}
2234 \circuitdescbip[vresistor]{vR}{Variable resistor}{variable american resistor}(wiper/180/0.3, tip/0/0.3)
2235 \circuitdescbip[potentiometer]{pR}{Potentiometer}{american potentiometer}(wiper/0/0.3, tip/135/0.2)
2236 \circuitdescbip[resistivesens]{sR}{Resistive sensor}{american resistive sensor}(label/0/0.3, wiper/180/0.3, tip/0/0.3)
2237 \circuitdescbip*[ldresistor]{ldR}{Ligth-Dependent resistor}{american light dependent resistor}(arrows/-45/0.3)
2238 \end{groupdesc}
2239
2240 If instead \IndexKey{europeanresistors} option is active (or the style \IndexKey[european resistors]{[european resistors]} is used), the resistors, variable resistors and potentiometers are displayed as follows:
2241 \begin{groupdesc}
2242 \ctikzset{resistor=european}
2243 \circuitdescbip*[generic]{R}{Resistor}{european resistor}
2244 \circuitdescbip*[tgeneric]{vR}{Variable resistor}{variable european resistor}(wiper/180/0.3, tip/0/0.3)
2245 \circuitdescbip*[genericpotentiometer]{pR}{Potentiometer}{european potentiometer}(wiper/0/0.3, tip/135/0.2)
2246 \circuitdescbip*[thermistor]{sR}{Resistive sensor}{european resistive sensor}(label/0/0.3, wiper/180/0.3, tip/0/0.3)
2247 \circuitdescbip*[ldgeneric]{ldR}{Ligth-Dependent resistor}{european light dependent resistor}(arrows/-45/0.3)
2248 \ctikzset{resistor=american} % reset default
2249 \end{groupdesc}
2250
2251 Other miscellaneous resistor-like devices:
2252 \begin{groupdesc}
2253 \circuitdescbip*{varistor}{Varistor}{}
2254 \circuitdescbip*{mov}{Metal-Oxide varistor}{}
2255 \circuitdescbip*[photoresistor]{phR}{Photoresistor}{photoresistor}(arrows/0/0.3)
2256 \circuitdescbip*[thermistor]{thR}{Thermistor}{thermistor}
2257 \circuitdescbip*[thermistorptc]{thRp}{PTC thermistor}{thermistor ptc}
2258 \circuitdescbip*[thermistorntc]{thRn}{NTC thermistor}{thermistor ntc}
2259 \end{groupdesc}
2260
2261
2262 \subsubsection{Potentiometers: wiper position}
2263 \label{sec:potentiometers-wiper-position}
2264
2265 Since version \texttt{0.9.5}, you can control the position of the wiper in potentiometers using the key \IndexKey{wiper pos}, which is a number in the range $[0,1]$. The default middle position is \texttt{wiper pos=0.5}.
2266
2267
2268 \begin{ctikzExample}
2269 \begin{circuitikz}[american]
2270 \ctikzset{resistors/width=1.5, resistors/zigs=9}
2271 \draw (0,0) to[pR, name=A] ++(0,-4);
2272 \draw (1.5,0) to[pR, wiper pos=0.3, name=B] ++(0,-4);
2273 \ctikzset{european resistors}
2274 \draw (3,0) to[pR, wiper pos=0.8, name=C] ++(0,-4);
2275 \foreach \i in {A, B, C}
2276 \node[right] at (\i.wiper) {\i};
2277 \end{circuitikz}
2278 \end{ctikzExample}
2279
2280 Since version \texttt{1.6.0}, potentiometers and variable resistors have extra anchors\footnote{Thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/663}{Dr. Matthias Jung on GitHub}}, to allow this kind of circuit (that seems to be common in some region):
2281
2282 \begin{ctikzExample}
2283 \begin{circuitikz}[european]
2284 \draw (0,0) to[battery2, l=E] ++(0,4.5)
2285 -- ++(2,0) coordinate(tmp)
2286 to[vR, l2_=$P_1$ and \SI{10}{\kohm}, mirror,
2287 invert, name=P]
2288 (0,0-|tmp) -- (0,0);
2289 \draw (0,0-|tmp) -- ++(1.5,0)
2290 to[R=$R_1$, -*] ++(0,2) coordinate(p)
2291 |- (P.wiper);
2292 \draw (p) to[rmeterwa, t=V] (tmp-|p) -- (tmp);
2293 \end{circuitikz}
2294 \end{ctikzExample}
2295
2296
2297 \subsubsection{Generic sensors anchors}\label{sec:sensors-anchors}
2298 Generic sensors have an extra anchor named \IndexKey{label} to help position the type of dependence, if needed:
2299
2300 \begin{ctikzExample}
2301 \begin{circuitikz}
2302 \draw (0,2) to[sR, l=$R$, name=mySR] ++(3,0);
2303 \node [font=\tiny, right] at(mySR.label) {-t\si{\degree}};
2304 \draw (0,0) to[sL, l=$L$, name=mySL] ++(3,0);
2305 \node [draw, circle, inner sep=2pt] at(mySL.label) {};
2306 \draw (0,-2) to[sC, l=$C$, name=mySC] ++(3,0);
2307 \node [font=\tiny, below right, inner sep=0pt] at(mySC.label) {+H\si{\%}};
2308 \end{circuitikz}
2309 \end{ctikzExample}
2310
2311 The anchor is positioned just on the corner of the segmented line crossing the component.
2312
2313 \subsubsection{Resistive components customization}
2314 \label{sec:resistive-components-customization}
2315
2316 \paragraph{Geometry.} You can change the scale of these components (all the resistive bipoles together) by setting the key \IndexKey{resistors/scale} (default \texttt{1.0}). Similarly, you can change the widths by setting \IndexKey{resistors/width} (default \texttt{0.8}).
2317 \label{par:geometry}
2318
2319 You can change the width of these components (all the resistive bipoles together) by setting the key \IndexKey{resistors/width} to something different from the default \texttt{0.8}.
2320
2321 For the american style resistors, you can change the number of ``zig-zags'' by setting the key
2322 \IndexKey{resistors/zigs} (default value \texttt{3}).
2323
2324 \begin{ctikzExample}
2325 \begin{circuitikz}[
2326 longpot/.style = {pR, resistors/scale=0.75,
2327 resistors/width=1.6, resistors/zigs=6}]
2328 \draw (0,1.5) to[R, l=$R$] ++(4,0);
2329 \draw (0,0) to[longpot, l=$P$] ++(4,0);
2330 \ctikzset{resistors/scale=1.5}
2331 \draw (0,-1.5) to[R, l=$R$] ++(4,0);
2332 \end{circuitikz}
2333 \end{ctikzExample}
2334
2335 \paragraph{Thickness.}\label{sec:resistor-thickness} The line thickness of the resistive components is governed by the class thickness; you can change it assigning a value to the key \IndexKey{resistors/thickness} (default \texttt{none}, that means \texttt{bipoles/thickness} is used, and that defaults to \texttt{2.0}; the value is relative to the base line thickness).
2336
2337 We can call \emph{modifiers} the elements that are added to the basic shape to express some characteristics of the component; for example the arrows for the variable resistors or the bar for the sensors. Normally the thickness of these elements are the same as the one chosen for the component\footnote{Due to a bug in versions before 1.3.4, that didn't happen for thermistors}. You can change their thickness with the class key \IndexKey{modifier thickness} which is relative to the main component thickness.
2338
2339 \begin{ctikzExample}
2340 \begin{circuitikz}[american]
2341 \draw (0,2) to[vR] ++(2,0) to[sR] ++(2,0);
2342 \ctikzset{resistors/thickness=4}
2343 \draw (0,1) to[vR] ++(2,0) to[sR] ++(2,0);
2344 \ctikzset{resistors/modifier thickness=0.5}
2345 \draw (0,0) to[vR] ++(2,0) to[sR] ++(2,0);
2346 \end{circuitikz}
2347 \end{ctikzExample}
2348
2349 \paragraph{Arrows}\label{sec:tunablearrows} You can change the arrow tips used in tunable resistors (\texttt{vR}, \texttt{tgeneric}) with the key \IndexKey{tunable end arrow} and in potentiometers with the key \IndexKey{wiper end arrow} (by default the key is the word ``\texttt{default}'' to obtain the default arrow, which is \texttt{latexslim} for both).
2350 Also you can change the start arrow with the corresponding \IndexKey{tunable start arrow} or \IndexKey{wiper start arrow} (the default value ``\texttt{default}'' is equivalent to \texttt{\{\}} for both, which means no arrow).
2351
2352 You can change that globally or locally, as ever. The tip specification is the one you can find in the \TikZ{} manual (\href{https://tikz.dev/tikz-arrows\#sec-16.4}{``Arrow Tip Specifications''}).
2353 For the \texttt{photoresistor} and the two ``flavors'' of the light-dependent resistor (\texttt{ldR}, american or european), the style of the arrows follow the \IndexKey[opto arrows]{opto} commands as in the photodiodes and phototransistor: see~\ref{sec:opto-arrows}.
2354
2355 \begin{ctikzExample}
2356 \begin{tikzpicture}[american]
2357 % globally all the potentiometrs
2358 \ctikzset{wiper end arrow={Kite[open]},
2359 opto arrows/color=blue, opto end arrow={Triangle}}
2360 \draw (0,0) to[tgeneric] ++(2,0) to[phR] ++(2,0)
2361 % set locally on this variable resistor
2362 to[vR, tunable end arrow={Stealth[red]},
2363 tunable start arrow={Bar}, invert] ++(0,-2)
2364 to[pR, mirror] ++(-4,0);
2365 \end{tikzpicture}
2366 \end{ctikzExample}
2367
2368 \begingroup % protect changes to resistors
2369 \newcommand\showjoin[1]{%
2370 \begin{tikzpicture}[scale=4, transform shape]
2371 \clip (0.2,-0.05) rectangle (0.6,0.3);
2372 \draw[ultra thick] (0,0) to[R, resistors/thickness=#1] ++(2,0);
2373 \end{tikzpicture}%
2374 }
2375 \ifbool{warpingprint}{}{\StartDefiningTabulars}
2376 \newcommand{\splat}{\begin{center}\ttfamily\scriptsize\begin{tabular}{cccc}
2377 \showjoin{1}&\showjoin{2}&\showjoin{3}&\showjoin{4}\\
2378 thickness=1 & thickness=2 & thickness=3 & thickness=4 \\
2379 \end{tabular}\end{center}%
2380 }
2381 \ifbool{warpingprint}{}{\StopDefiningTabulars}
2382 \newcommand{\rdivider}[1]{\begin{tikzpicture}
2383 \ctikzset{resistors/thickness=#1}
2384 \draw (0,0) node[ground]{} to[V] ++(0,2) to[R] ++(2,0)
2385 to[R] ++(0,-2) to[short,-*] (0,0);
2386 \end{tikzpicture}\qquad}
2387 \newcommand{\divsplat}[1]{#1\par
2388 \begin{center}
2389 \rdivider{1}\rdivider{2}\rdivider{3}\rdivider{4}
2390 \end{center}}
2391
2392 \paragraph{Details of American (``zig-zag'') resistors.}\label{sec:zigzag-details} American (zig-zag) resistors have a little joining problem\footnote{Noticed by \href{https://github.com/circuitikz/circuitikz/issues/811}{Jakob Leide on GitHub} and later \href{https://github.com/circuitikz/circuitikz/discussions/814}{discussed here}.} with the leading wires if the thickness is greater than two. In the following drawing you can see the problem when the thickness grows from 1 to 4.
2393 \label{par:details-of-american}
2394
2395 \splat
2396
2397 Since \texttt{v1.7.0}, one possibility to correct the problem is to change the type of joining of the zig-zag line, using the key \IndexKey{resistors/zigzag join}, which is a command that by default is void. For example, the following effect is obtained by using
2398
2399 \begin{lstlisting}[numbers=none]
2400 \ctikzset{resistors/zigzag hook/.code={\pgfsetroundcap}}
2401 \end{lstlisting}
2402 {\ctikzset{resistors/zigzag hook/.code={\pgfsetroundcap}}
2403 \splat}
2404
2405 or you can even go full rounded
2406
2407 \begin{lstlisting}[numbers=none]
2408 \ctikzset{resistors/zigzag hook/.code={\pgfsetroundcap\pgfsetroundjoin}}
2409 \end{lstlisting}
2410 {\ctikzset{resistors/zigzag hook/.code={\pgfsetroundcap\pgfsetroundjoin}}
2411 \splat}
2412
2413 Another possibility is to add a little horizontal ``stub'' to the shape, with the key \IndexKey{resistors/zigzag stub} (default \texttt{0}), which will add a first part which is a continuation of the wire:
2414 \begin{lstlisting}[numbers=none]
2415 \ctikzset{resistors/zigzag stub=0.05}% this is relative to the resistor's length
2416 \end{lstlisting}
2417 {\ctikzset{resistors/zigzag stub=0.05}
2418 \splat}
2419
2420 \dots or you can just combine all of them as you prefer. With the standard join/cap options, the look of the resistors for thickness from 1 to 4 is shown here:
2421
2422 \ctikzset{american}
2423 \divsplat{Standard drawing of American resistors}
2424 \divsplat{With a 5\% stub: \ctikzset{resistors/zigzag stub=0.05}}
2425 \divsplat{With a 20\% stub: \ctikzset{resistors/zigzag stub=0.2}}
2426
2427
2428 \bigskip
2429 Finally, here is the detailed shape with thickness 2 (red=0, blue=0.05, green=0.2), magnified six times:
2430
2431 \vspace*{2cm}% this vspace fences are needed because the transform canvas wreak havoc with the bbox
2432 \begin{tikzpicture}[transform canvas={scale=6}]
2433 \ctikzset{resistors/zigzag stub=0}
2434 \draw[red] (0,0.2) to [resistor, resistors/thickness=4] ++(2,0);
2435 \ctikzset{resistors/zigzag stub=0.05}
2436 \draw[blue] (0,0.1) to [resistor, resistors/thickness=4] ++(2,0);
2437 \ctikzset{resistors/zigzag stub=0.2}
2438 \draw[green] (0,0) to [resistor, resistors/thickness=4] ++(2,0);
2439 % \draw [very thin](1,0.5) -- (1,-0.5);
2440 % \draw [very thin](0,0) -- ++(2,0);
2441 % \draw [very thin](0,0.1) -- ++(2,0);
2442 % \draw [very thin](0,0.2) -- ++(2,0);
2443 \end{tikzpicture}
2444 \vspace*{2cm}
2445
2446 \endgroup % changes to resistors stops here
2447
2448
2449 \subsection{Capacitors and inductors: dynamical bipoles}
2450 \label{sec:capacitors-and-inductors}
2451
2452 \subsubsection{Capacitors}
2453 \label{sec:capacitors}
2454
2455 \begin{groupdesc}
2456 \circuitdescbip*{capacitor}{Capacitor}{C}
2457 \circuitdescbip*[ccapacitor]{curved capacitor}{Curved (polarized) capacitor}{cC}
2458 \circuitdescbip*{ecapacitor}{Electrolytic capacitor}{eC,elko}
2459 \circuitdescbip*[vcapacitor]{variable capacitor}{Variable capacitor}{vC}(wiper/180/0.3, tip/0/0.3)
2460 \circuitdescbip*[capacitivesens]{capacitive sensor}{Capacitive sensor}{sC}(label/0/0.3, wiper/180/0.3, tip/0/0.3)
2461 \circuitdescbip*{piezoelectric}{Piezoelectric Element}{PZ}
2462 \circuitdescbip*{cpe}{Constant Phase Element}{cpe}
2463 \circuitdescbip*[ferrocap]{feC}{Ferroelectric capacitor\footnotemark}{ferrocap}(kink left/180/0.2, kink right/0/0.2, curve left/160/0.3, curve right/-20/0.2, center/45/0.3)
2464 \footnotetext{suggested by \href{https://github.com/circuitikz/circuitikz/issues/515}{Mayeul Cantan}}
2465 \end{groupdesc}
2466
2467 Capacitors are fillable since \texttt{v1.4.1}; this is normally just a stylistic option but in the case of
2468 ferroelectric capacitors that could be used to show the state of the hysteresis of the component.
2469
2470 \begin{ctikzExample}
2471 \begin{tikzpicture}[]
2472 \ctikzset{capacitors/.cd,
2473 thickness=4, modifier thickness=0.5}
2474 \draw (0,0) to[feC, l=$C_1$, v=v1] ++(3,0)
2475 to[feC, l=$C_2$, fill=green, name=C2] ++(0,-2);
2476 \node [font=\tiny, above right, inner sep=1pt]
2477 at(C2.kink left) {$S_1$};
2478 \end{tikzpicture}
2479 \end{ctikzExample}
2480
2481 There is also the (deprecated\footnote{Thanks to \href{https://tex.stackexchange.com/questions/509594/polar-capacitor-orientation-in-circuitikz-seems-wrong}{Anshul Singhv for noticing}.} --- its polarity is not coherent with the rest of the components) \IndexKey{polar capacitor}; please do not use it.
2482
2483 \subsubsection{Capacitive sensors anchors}
2484 \label{sec:capacitive-sensors-anchors}
2485
2486 For capacitive sensors, you have the same anchors than in the case of resistive sensors, see section~\ref{sec:sensors-anchors}.
2487
2488 \subsubsection{Capacitors customizations}\label{sec:capacitors-styling}
2489
2490 You can change the scale of the capacitors by setting the key \IndexKey{capacitors/scale} to something different from the default \texttt{1.0}. For thickness, you can use the same keys (applied to the \texttt{capacitors} class) as for resistors in~\ref{sec:resistor-thickness}.
2491
2492 Variable capacitors arrow tips follow the settings of resistors, see section~\ref{sec:tunablearrows}.
2493
2494 The relative size of the capacitors is a bit of a mixed bag, because each one has historically different internal parameters that makes maintaining coherence quite difficult. In \texttt{v1.4.1} this has changed and now you can use styling options to change the way the capacitors look. The main parameter you can set is \IndexKey{capacitors/width} (default \texttt{0.2}), which controls the standard distance between plates. That will change all the components (notice that \texttt{piezoelectric} and \texttt{cpe} default width is twice the size of a standard capacitor --- although this is not evident for the \texttt{cpe} given its shape.)
2495
2496 \begin{ctikzExample}
2497 \begin{circuitikz}[european]
2498 \draw (0,1) to[C=aaa] ++(2,0) to[cpe=bbb] ++(2,0);
2499 \draw[color=red] (0,0) to [C] ++(2,0);
2500 \draw[color=blue] (0,0) to [cpe] ++(2,0)
2501 to[cpe, fill=yellow, capacitors/width=0.1] ++(2,0);
2502 \end{circuitikz}
2503 \end{ctikzExample}
2504
2505 The \IndexKey{capacitors/height} key is available also to set the height of the capacitor; the default is \texttt{0.6} for most of the capacitors, but \texttt{0.5} for electrolytic ones and \texttt{0.7} for piezoelectric. When used, it will set all of them at the same value, which is a good thing.
2506
2507 If you want that only a specific kind of capacitor has a different value for a key, you can always use a style which will have a local scope, as in the following example.
2508
2509 \begin{ctikzExample}
2510 \begin{tikzpicture}
2511 \draw (0,1) to [C] ++(1,0) to [elko] ++(1,0);
2512 \ctikzset{capacitors/width=0.15, capacitors/height=0.5}
2513 \draw (0,0) to [C] ++(1,0) to [elko] ++(1,0);
2514 \tikzset{big elko/.style={elko=#1, capacitors/width=0.3}}
2515 \draw (0,-1) to [C] ++(1,0) to[big elko] ++(1,0);
2516 \end{tikzpicture}
2517 \end{ctikzExample}
2518
2519
2520 \subsubsection{Inductors}
2521 \label{sec:inductors}
2522
2523 If the \IndexKey{cuteinductors} option is active (default behaviour), or the style \IndexKey[cute inductors]{[cute inductors]} is used, the inductors are displayed as follows:
2524 \begin{groupdesc}
2525 \ctikzset{inductor=cute}
2526 \circuitdescbip[cuteinductor]{L}{Inductor}{cute inductor}(midtap/90/0.1)
2527 \circuitdescbip[vcuteinductor]{vL}{Variable inductor}{variable cute inductor}(wiper/180/0.3, tip/0/0.3)
2528 \circuitdescbip[scuteinductor]{sL}{Inductive sensor}{cute inductive sensor}(label/0/0.3, wiper/180/0.3, tip/0/0.3)
2529 \end{groupdesc}
2530
2531 If the \IndexKey{americaninductors} option is active (or the style \IndexKey[american inductors]{[american inductors]} is used), the inductors are displayed as follows:
2532 \begin{groupdesc}
2533 \ctikzset{inductor=american}
2534 \circuitdescbip[americaninductor]{L}{Inductor}{american inductor}(midtap/90/0.3)
2535 \circuitdescbip[vamericaninductor]{vL}{Variable inductor}{variable american inductor}(core west/135/0.1, core east/45/0.1, wiper/180/0.3, tip/90/0.1)
2536 \circuitdescbip[samericaninductor]{sL}{Inductive sensor}{american inductive sensor}(label/0/0.3, wiper/180/0.3, tip/0/0.3)
2537 \end{groupdesc}
2538
2539 Finally, if the \IndexKey{europeaninductors} option is active (or the style \IndexKey[european inductors]{[european inductors]} is used), the inductors are displayed as follows:
2540 \begin{groupdesc}
2541 \ctikzset{inductor=european}
2542 \circuitdescbip[fullgeneric]{L}{Inductor}{european inductor}(midtap/90/0.1)
2543 \circuitdescbip[tfullgeneric]{vL}{Variable inductor}{variable european inductor}(wiper/180/0.3, tip/90/0.1,core west/135/0.1, core east/45/0.1)
2544 \circuitdescbip[sfullgeneric]{sL}{Inductive sensor}{european inductive sensor}(label/0/0.3, wiper/180/0.3, tip/0/0.3)
2545 \ctikzset{inductor=cute} % back to default
2546 \end{groupdesc}
2547
2548 For historical reasons, \emph{chokes} come only in the \texttt{cute}. You can use the \IndexKey{core west} and \IndexKey{core east} anchors (see~\ref{sec:inductors-core-anchors}) to build your own core lines for the other inductors.
2549
2550 \begin{groupdesc}
2551 \circuitdescbip[cutechoke]{cute choke}{Choke}{}
2552 \end{groupdesc}
2553
2554 \subsubsection{Inductors customizations}\label{sec:tweak-l}
2555
2556 You can change the scale of the inductors by setting the key \IndexKey{inductors/scale} to something different from the default \texttt{1.0}. For thickness, you can use the same keys (applied to the \texttt{inductors} class) as for resistors in~\ref{sec:resistor-thickness}.
2557
2558 Variable inductors arrow tips follow the settings of resistors, see section~\ref{sec:tunablearrows}.
2559
2560 You can change the width of these components (all the inductors together, unless you use style or scoping) by setting the key \IndexKey{inductors/width} to something different from the default, which is \texttt{0.8} for american and european inductors, and \texttt{0.6} for cute inductors.
2561
2562 Moreover, you can change the number of ``coils'' drawn by setting the key
2563 \IndexKey{inductors/coils} (default value \texttt{5} for cute inductors and \texttt{4} for american ones). \textbf{Notice} that the minimum number of \texttt{coils} is \texttt{1} for american inductors, and \texttt{2} for cute ones.
2564
2565 \begin{ctikzExample}
2566 \begin{circuitikz}[
2567 longL/.style = {cute inductor, inductors/scale=0.75,
2568 inductors/width=1.6, inductors/coils=9}]
2569 \draw (0,1.5) to[L, l=$L$] ++(4,0);
2570 \draw (0,0) to[longL, l=$L$] ++(4,0);
2571 \ctikzset{inductors/scale=1.5, inductor=american}
2572 \draw (0,-1.5) to[L, l=$L$] ++(4,0);
2573 \end{circuitikz}
2574 \end{ctikzExample}
2575
2576 \paragraph{Chokes} can have single and double lines, and can have the line thickness adjusted (the value is relative to the thickness of the inductor). In general, you should use the anchors (see~\ref{sec:inductors-core-anchors}) to add core lines to inductors.
2577 \label{par:chokes}
2578
2579 \begin{ctikzExample}
2580 \begin{circuitikz}[american]
2581 \draw (0,0) to[cute choke] ++(3,0);
2582 \draw (0,-1) to[cute choke, twolineschoke] ++(3,0);
2583
2584 \ctikzset{bipoles/cutechoke/cthick=2, twolineschoke}
2585
2586 \draw (0,-2) to[cute choke] ++(3,0);
2587 \draw (0,-3) to[cute choke, onelinechoke] ++(3,0);
2588 \end{circuitikz}
2589 \end{ctikzExample}
2590
2591
2592 \subsubsection{Inductors anchors}
2593 \label{sec:inductors-anchors}
2594
2595 For inductive sensors, you have the same anchors than in the case of resistive sensors, see section~\ref{sec:sensors-anchors}.
2596
2597 \paragraph{Taps.}
2598 \label{par:taps}
2599 Inductors have an additional anchor, called \IndexKey{midtap}, that connects to the center of the coil ``wire''. Notice that this anchor could be on one side or the other of the component, depending on the number of loops of the element; if you need a fixed position, you can use the geographical anchors.
2600
2601 \begin{ctikzExample}
2602 \begin{circuitikz}[
2603 loops/.style={circuitikz/inductors/coils=#1}]
2604 \ctikzset{cute inductors}
2605 \draw (0,2) to[L, loops=5, name=A] ++(2,0)
2606 to[L, loops=6, name=B] ++(2,0);
2607 \ctikzset{american inductors}
2608 \draw (0,0) to[L, loops=5, name=C] ++(2,0)
2609 to[L, loops=6, name=D] ++(2,0);
2610 \foreach \i in {A, B, C, D}
2611 \node[circle, fill=red, inner sep=1pt] at (\i.midtap){};
2612 \end{circuitikz}
2613 \end{ctikzExample}
2614
2615 \paragraph{Core anchors.}\label{sec:inductors-core-anchors}
2616 Inductors have additional anchors to add core lines (for historical reasons, there is a \IndexKey{cute choke} component also, but to use inductors in the chosen style you'd better use these anchors). The anchors are called \IndexKey{core west} and \IndexKey{core east} and they are positioned at a distance that you can tweak with the \texttt{\textbackslash ctikzset} key \IndexKey{bipoles/inductors/core distance} (default \texttt{2pt}).
2617
2618 \begin{ctikzExample}
2619 \begin{circuitikz}[]
2620 \ctikzset{american}
2621 \draw (0,3) to[L=$L$, name=myL] ++(2,0);
2622 \draw[thick] (myL.core west) -- (myL.core east);
2623 \ctikzset{cute inductors}
2624 \draw (0,1.5) to[L=$L$, name=myL] ++(2,0);
2625 \draw[densely dashed] (myL.core west) -- (myL.core east);
2626 \ctikzset{european, bipoles/inductors/core distance=4pt}
2627 \draw (0,0) to[L=$L$, name=myL, label distance=2pt] ++(2,0);
2628 \draw[thick, double] (myL.core west) -- (myL.core east);
2629 \end{circuitikz}
2630 \end{ctikzExample}
2631
2632 Notice that the core lines will \textbf{not} change the position of labels. You have to move them by hand if needed (or position them on the other side); see~\ref{sec:adjust-label-position}.
2633
2634 \paragraph{Dot anchors.}
2635 \label{par:dot-anchors}
2636 Inductances also have ``dot'' anchors\footnote{proposed by Romano in a discussion by \href{https://github.com/circuitikz/circuitikz/issues/618}{GitHub user AndreaDiPietro92}},
2637 to help positioning dots when specifying mutual inductance signs. The anchors are name \IndexKey{lr dot} (for lower right dot), \IndexKey{ur dot} (upper right) and so on:
2638 \begin{quote}
2639 \showanchors{cuteinductorshape}{}(lr dot/-45/0.2, ur dot/45/0.2, ll dot/-135/0.2, ul dot/135/0.2)
2640 \quad
2641 \showanchors{cuteinductorshape}{}(ur dot/-60/0.3, ul dot/-120/0.3, core west/135/0.2, core east/45/0.2)
2642 \end{quote}
2643 and as you can see, you have to be careful if you use dot anchors and core anchors together.
2644 You can change the position of the dots by changing the keys \IndexKey{bipoles/inductors/dot x distance} (default \texttt{4pt}), which represent how much the dot extends outside the component width, and the corresponding \IndexKey[bipoles/inductors/dot y distance]{dot y distance} (default \texttt{1pt}), which serves the same scope in the height direction.
2645
2646 \begin{ctikzExample}
2647 \begin{circuitikz}[]
2648 \ctikzset{bipoles/inductors/.cd, dot x distance=3pt,
2649 dot y distance=0pt}
2650 \draw (0,2) to[L=$L_1$, name=l1] ++(3,0);
2651 \draw (0,0) to[L, l_=$L_2$, name=l2, inductors/width=1.4,
2652 inductors/coils=11] ++(3,0);
2653 \path (l1.ur dot) node[circ]{} (l2.ul dot) node[circ]{};
2654 \draw ([yshift=-0.2cm]l1.south)
2655 to[out=-45, in=45] node[right]{$M$}
2656 ([yshift=0.2cm]l2.north);
2657 \end{circuitikz}
2658 \end{ctikzExample}
2659
2660 Notice that the position of the dot anchors does not coincide with the position of the dots in the transformers (see section~\ref{sec:transformers}), because there they depend on the size of the complete double-bipole more that on the size of the inductances.
2661
2662 \subsection{Diodes and such}
2663 \label{sec:diodes-and-such}
2664
2665 There are three basic styles for diodes: \texttt{empty} (fillable in color), \texttt{full} (completely filled with the draw color) and \texttt{stroke} (empty, but with a line across them).
2666
2667 You can switch between the styles setting the key \texttt{diode} (for example \verb|\ctikzset{diode=full}| or \texttt{empty} or \texttt{stroke}, or with the styles \texttt{full diodes}, \texttt{empty diodes} and \texttt{stroke diodes}.
2668
2669
2670 To use the default element, simply use the name shown for the empty diodes without the final ``o'' --- that is \texttt{D}, \texttt{sD}, and so on. The names shown in the following tables will draw the specified diode independently on the style chosen (that is, \texttt{leD*} is always a full LED diode).
2671
2672 \begin{framed}
2673 The package options \IndexKey{fulldiode}, \IndexKey{strokediode}, and \IndexKey{emptydiode} (and the styles \IndexKey{full diodes}, \IndexKey{stroke diodes}, and \IndexKey{empty diodes}) define which shape will be used by abbreviated commands such that \texttt{D}, \texttt{sD}, \texttt{zD}, \texttt{zzD}, \texttt{tD}, \texttt{pD}, \texttt{leD}, \texttt{VC}, \texttt{Ty},\texttt{Tr} (no stroke symbol available!).
2674 \end{framed}
2675
2676 \begin{groupdesc}
2677 \circuitdescbip*[emptydiode] {empty diode}{Empty diode}{Do}
2678 \circuitdescbip*[emptysdiode]{empty Schottky diode}{Empty Schottky diode}{sDo}
2679 \circuitdescbip*[emptyzdiode]{empty Zener diode}{Empty Zener diode}{zDo}
2680 \circuitdescbip*[emptyzzdiode]{empty ZZener diode}{Empty ZZener diode}{zzDo}
2681 \circuitdescbip*[emptytdiode]{empty tunnel diode}{Empty tunnel diode}{tDo}
2682 \circuitdescbip*[emptypdiode]{empty photodiode}{Empty photodiode}{pDo}(arrows/-30/0.3)
2683 \circuitdescbip*[emptylediode]{empty led}{Empty led}{leDo}(arrows/-30/0.3)
2684 \circuitdescbip*[emptylaserdiode]{empty laser diode}{Empty laser diode\footnotemark}{lasD}(arrows/-30/0.3)
2685 \footnotetext{Added by André Alves in \texttt{v1.4.4}}
2686 \circuitdescbip*[emptyvarcap]{empty varcap}{Empty varcap}{VCo}
2687 \circuitdescbip*[emptytvsdiode]{empty TVS diode}{Empty TVS diode, transorb\footnotemark}{tvsDo}
2688 \footnotetext{Transorbs were suggested by \href{https://tex.stackexchange.com/q/642219/38080}{Anisio Braga}}
2689 \circuitdescbip*[emptyshdiode]{empty Shockley diode}{Empty Shockley diode\footnotemark}{shDo}
2690 \footnotetext{Shockley diodes were suggested by \href{https://tex.stackexchange.com/q/646039/38080}{@Dauph}}
2691 \circuitdescbip*[emptybidirectionaldiode]{empty bidirectionaldiode}{Empty bidirectionaldiode}{biDo}
2692 \circuitdescbip[fulldiode] {full diode}{Full diode}{D*}
2693 \circuitdescbip[fullsdiode]{full Schottky diode}{Full Schottky diode}{sD*}
2694 \circuitdescbip[fullzdiode]{full Zener diode}{Full Zener diode}{zD*}
2695 \circuitdescbip[fullzzdiode]{full ZZener diode}{Full ZZener diode}{zzD*}
2696 \circuitdescbip[fulltdiode]{full tunnel diode}{Full tunnel diode}{tD*}
2697 \circuitdescbip[fullpdiode]{full photodiode}{Full photodiode}{pD*}(arrows/-30/0.3)
2698 \circuitdescbip[fulllediode]{full led}{Full led}{leD*}(arrows/-30/0.3)
2699 \circuitdescbip[fulllaserdiode]{full laser diode}{Full laser diode}{lasD*}(arrows/-30/0.3)
2700 \circuitdescbip[fullvarcap]{full varcap}{Full varcap}{VC*}
2701 \circuitdescbip[fulltvsdiode]{full TVS diode}{Full TVS diode, transorb}{tvsD*}
2702 \circuitdescbip[fullshdiode]{full Shockley diode}{Full Shockley diode}{shD*}
2703 \circuitdescbip[fullbidirectionaldiode]{full bidirectionaldiode}{Full bidirectionaldiode}{biD*}
2704 \end{groupdesc}
2705
2706 These shapes have no exact node-style counterpart, because the stroke line is built upon the empty variants:
2707
2708 \begin{groupdesc}
2709 \circuitdescbip*[emptydiode] {stroke diode}{Stroke diode}{D-}
2710 \circuitdescbip*[emptysdiode]{stroke Schottky diode}{Stroke Schottky diode}{sD-}
2711 \circuitdescbip*[emptyzdiode]{stroke Zener diode}{Stroke Zener diode}{zD-}
2712 \circuitdescbip*[emptyzzdiode]{stroke ZZener diode}{Stroke ZZener diode}{zzD-}
2713 \circuitdescbip*[emptytdiode]{stroke tunnel diode}{Stroke tunnel diode}{tD-}
2714 \circuitdescbip*[emptypdiode]{stroke photodiode}{Stroke photodiode}{pD-}(arrows/-30/0.3)
2715 \circuitdescbip*[emptylediode]{stroke led}{Stroke led}{leD-}(arrows/-30/0.3)
2716 \circuitdescbip*[emptylaserdiode]{stroke laser diode}{Stroke laser diode}{lasD-}(arrows/-30/0.3)
2717 \circuitdescbip*[emptyvarcap]{stroke varcap}{Stroke varcap}{VC-}
2718 \circuitdescbip*[emptytvsdiode]{stroke TVS diode}{Stroke TVS diode, transorb}{tvsD-}
2719 \end{groupdesc}
2720
2721 \subsubsection{Tripole-like diodes}\label{sec:othertrip} The following tripoles are entered with the usual command, of the form \texttt{to[Tr, \dots]}. In the following list you can see the traditional, or \texttt{legacy}, shape of the Thyristors-type devices.
2722
2723
2724 \begin{groupdesc}
2725 \ctikzset{thyristor style=legacy}
2726 \circuitdescbip[fulldiode] {full diode}{Full diode}{D*}
2727 \circuitdescbip*[emptydiode] {stroke diode}{Stroke diode}{D-}
2728 \circuitdescbip*[emptytriac]{triac}{Standard triac (shape depends on package option)}{Tr}( G/0/0.3, anode/-90/0.2, cathode/-90/0.2)
2729 \circuitdescbip*[emptytriac]{empty triac}{Empty triac}{Tro}( gate/0/0.3 )
2730 \circuitdescbip[fulltriac]{full triac}{Full triac}{Tr*}
2731 \circuitdescbip*[emptythyristor]{thyristor}{Standard thyristor (shape depends on package option)}{Ty}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2732 \circuitdescbip*[emptythyristor]{empty thyristor}{Empty thyristor}{Tyo}
2733 \circuitdescbip[fullthyristor]{full thyristor}{Full thyristor}{Ty*}
2734 \circuitdescbip*[emptythyristor]{stroke thyristor}{Stroke thyristor}{Ty-}
2735 \circuitdescbip*[emptyput]{put}{Standard Programmable Unipolar Transistor\footnotemark (shape depends on package option)}{PUT}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2736 \footnotetext{This components, and the GTO family, has been suggested by \href{https://github.com/circuitikz/circuitikz/issues/522}{GitHub user JetherReis}.}
2737 \circuitdescbip*[emptyput]{empty put}{Empty PUT}{PUTo}
2738 \circuitdescbip[fullput]{full put}{Full PUT}{PUT*}
2739 \circuitdescbip*[emptyput]{stroke put}{Stroke PUT}{PUT-}
2740 \circuitdescbip*[emptygto]{gto}{Standard GTO (shape depends on package option)}{GTO}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2741 \circuitdescbip*[emptygto]{empty gto}{Empty GTO}{GTOo}
2742 \circuitdescbip[fullgto]{full gto}{Full GTO}{GTO*}
2743 \circuitdescbip*[emptygto]{stroke gto}{Stroke GTO}{GTO-}
2744 \circuitdescbip*[emptygtobar]{gtobar}{Standard GTO with bar-type gate (shape depends on package option)}{GTOb}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2745 \circuitdescbip*[emptygtobar]{empty gtobar}{Empty GTO, bar-type}{GTObo}
2746 \circuitdescbip[fullgtobar]{full gtobar}{Full GTO, bar-type}{GTOb*}
2747 \circuitdescbip*[emptygtobar]{stroke gtobar}{Stroke GTO, bar type}{GTOb-}
2748 \circuitdescbip*[emptyagtobar]{agtobar}{Standard GTO with bar-type gate on anode (shape depends on package option)}{aGTOb}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2749 \circuitdescbip*[emptyagtobar]{empty agtobar}{Empty GTO, bar-type on anode}{aGTObo}
2750 \circuitdescbip[fullagtobar]{full agtobar}{Full GTO, bar-type on anode}{aGTOb*}
2751 \circuitdescbip*[emptyagtobar]{stroke agtobar}{Stroke GTO, bar-type on anode}{aGTOb-}
2752 \circuitdescbip*[emptyigct]{igct}{Standard IGCT\footnotemark}{IGCT}(G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2753 \footnotetext{The IGCTs family has been contributed by Paul Sacco}
2754 \circuitdescbip*[emptyigct]{empty igct}{Empty IGCT}{IGCTo}
2755 \circuitdescbip[fulligct]{full igct}{Full IGCT}{IGCT*} \circuitdescbip*[emptyigct]{stroke igct}{Stroke IGCT}{IGCT-}
2756 \end{groupdesc}
2757
2758 For basically stylistic reasons, there is a different, more compact, shape available for them, activated with the key \IndexKey[thyristor style]{thyristor style=compact} (the default is \texttt{legacy}). All the devices above are present, we will show here just the automatic version for shortness.
2759
2760 \begin{groupdesc}
2761 \ctikzset{thyristor style=compact}
2762 \circuitdescbip*[emptytriac]{triac}{Standard triac (shape depends on package option)}{Tr}(G/0/0.3, anode/-90/0.2, cathode/-90/0.2)
2763 \circuitdescbip*[emptythyristor]{thyristor}{Standard thyristor (shape depends on package option)}{Ty}(G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2764 \circuitdescbip*[emptyput]{put}{Standard Programmable Unipolar Transistor (shape depends on package option)}{PUT}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2765 \circuitdescbip*[emptygto]{gto}{Standard gto (shape depends on package option)}{GTO}(G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2766 \circuitdescbip*[emptygtobar]{gtobar}{Standard GTO with a bar symbol on the gate (shape depends on package option)}{GTOb}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2767 \circuitdescbip*[emptyagtobar]{agtobar}{Standard GTO with bar-type gate on anode (shape depends on package option)}{aGTOb}( G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2768 \circuitdescbip*[emptyigct]{igct}{Standard igct (shape depends on package option)}{IGCT}(G/0/0.3, gate/45/0.3, anode/-90/0.2, cathode/-90/0.2)
2769 \end{groupdesc}
2770
2771 \subsubsection{Thyristors anchors and customization}
2772 \label{sec:thyristors-anchors-and}
2773
2774 When inserting a thyristor, a triac or a potentiometer, one needs to refer to the third node-gate (\IndexKey{gate} or \texttt{G}) for the former two; wiper (\IndexKey{wiper} or \texttt{W}) for the latter one. This is done by giving a name to the bipole:
2775 \label{bipole-naming}
2776 \begin{ctikzExample}
2777 \begin{circuitikz} \draw
2778 (0,0) to[Tr, n=TRI] (2,0)
2779 to[pR, n=POT] (4,0);
2780 \draw[dashed] (TRI.G) -| (POT.wiper)
2781 ;\end{circuitikz}
2782 \end{ctikzExample}
2783
2784 As commented above, you can change the shape of these devices (globally or locally) setting the key \texttt{thyristor style=compact} (the default is \texttt{legacy}). Additionally, normally the plain \texttt{GTO} symbols come without the arrows, but you can add them using a syntax similar to the one explained in section~\ref{sec:tunablearrows} using the arrow group \IndexKey[gto gate arrows]{gto gate}.
2785
2786 \begin{ctikzExample}
2787 \begin{circuitikz}[]
2788 \ctikzset{thyristor style=compact}
2789 \draw (0,0) to[GTO=$G_1$] ++(0,-3);
2790 \ctikzset{gto gate end arrow=latexslim}
2791 \draw (2,0) to[GTO*=$G_2$, mirror] ++(0,-3);
2792 \draw (4,0) to[GTOb-=$G_2$, mirror] ++(0,-3);
2793 \end{circuitikz}
2794 \end{ctikzExample}
2795
2796 Notice that you can set both \texttt{gto gate end arrow} and \texttt{gto gate start arrow} --- choosing just one of the two you can decide the ``rotation'' direction of the symbol. There is little space though, so don't overdo it.
2797
2798 \subsubsection{Diode customizations}\label{sec:tweak-d}
2799
2800 You can change the scale of the diodes by setting the key \IndexKey{diodes/scale} to something different from the default \texttt{1.0}. In Romano's opinion, diodes are somewhat big with the default style of the package, so a setting like \verb|\ctikzset{diodes/scale=0.6}| is recommended.
2801
2802 \begin{ctikzExample}
2803 \begin{circuitikz}
2804 \draw (0,1) to[D, l=$D$] ++(2,0)
2805 node[npn, anchor=B]{};
2806 \ctikzset{diodes/scale=0.6}
2807 \draw (0,-1) to[D, l=$D$] ++(2,0)
2808 node[npn, anchor=B]{};
2809 \end{circuitikz}
2810 \end{ctikzExample}
2811
2812 \paragraph{Optical devices arrows}\label{sec:opto-arrows} You can change the direction of the LEDs and photodiodes' arrows by using the binary keys \IndexKey{led arrows from cathode} and \IndexKey{pd arrows to cathode} (the default are \IndexKey{led arrows from anode} and \IndexKey{pd arrows to anode}), as you can see in the following example.
2813
2814 \begin{ctikzExample}
2815 \begin{circuitikz}
2816 \ctikzset{led arrows from anode} % default
2817 \ctikzset{pd arrows to anode} % default
2818 \ctikzset{full diodes}
2819 \draw (0,0) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
2820 \ctikzset{stroke diodes}
2821 \draw (0,-1) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
2822 \ctikzset{empty diodes}
2823 \draw (0,-2) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
2824
2825 \ctikzset{led arrows from cathode}
2826 \ctikzset{pd arrows to cathode}
2827 \ctikzset{full diodes}
2828 \draw (0,-4) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
2829 \ctikzset{stroke diodes}
2830 \draw (0,-5) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
2831 \ctikzset{empty diodes}
2832 \draw (0,-6) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
2833 \end{circuitikz}
2834 \end{ctikzExample}
2835
2836 Since version \texttt{1.5.5}\footnote{Thanks to the idea by \href{https://github.com/circuitikz/circuitikz/issues/655}{Dr. Matthias Jung on GitHub}.}, you can change the arrows used for LEDs, photodiodes and laser diodes with the generic arrows options shown in~\ref{sec:tunablearrows}, using the name \IndexKey[opto arrows]{opto}, like in the following (overdone) example. Normally you want just to change the \texttt{end arrow}\dots
2837
2838 As you can see, you can also have the option to globally change the color, relative thickness, and dash pattern by setting keys with the \verb!\ctikzset! command (or, like in the following example, directly in the node instantiation) under the \texttt{opto arrows} hierarchy. The available keys are:
2839
2840 \begin{center}
2841 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{0.5\linewidth}}
2842 \toprule
2843 parameter & default & description \\
2844 \midrule
2845 relative thickness & 1.0 & multiply the class thickness \\
2846 color & default & stroke color: \texttt{default} is the same as the component \\
2847 dash & default & dash pattern: \texttt{default} means not to change the setting for the component; \texttt{none} means unbroken line; every other input is a dash pattern.\footnotemark \\
2848 \bottomrule
2849 \end{tabular}
2850 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
2851 \end{center}
2852
2853 \begin{ctikzExample}
2854 \begin{tikzpicture}
2855 \newcommand{\optos}{%
2856 to[leD] ++(1.5,0) to[pD*] ++(1.5,0)
2857 to[lasD] ++(1.5,0)}
2858 \begin{scope}
2859 \draw (0,2) \optos;
2860 \ctikzset{led arrows from cathode}
2861 \ctikzset{pd arrows to cathode}
2862 \ctikzset{opto arrows/.cd, color=red,
2863 dash={{1pt}{1pt}}}
2864 \draw (0,0) \optos;
2865 \end{scope}
2866 \begin{scope}[color=blue, yshift=-6cm]
2867 \ctikzset{opto end arrow={Triangle[angle'=45]}}
2868 \ctikzset{opto start arrow={Hooks[red]}}
2869 \draw (0,4) \optos;
2870 \ctikzset{opto arrows/color=black}
2871 \ctikzset{opto arrows/relative thickness=2}
2872 \draw (0,2) \optos;
2873 \ctikzset{led arrows from cathode}
2874 \ctikzset{pd arrows to cathode}
2875 \draw (0,0) \optos;
2876 \end{scope}
2877 \end{tikzpicture}
2878 \end{ctikzExample}
2879
2880 \paragraph{Zener and TVS diode options} You can change the shape of the Zener \texttt{ZZener} and \texttt{TVS} diodes using the flag \IndexKey{diode straight whiskers} (and reset it with the option \IndexKey{diode sloped whiskers}); this will change the ``whiskers'' of the diodes to be at a right angle\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/836}{Dr. Matthias Jung}} instead the sloped normal way.
2881 \label{par:zener-and-tvs}
2882
2883 \begin{ctikzExample}
2884 \begin{tikzpicture}
2885 \draw (0,1) to [zzDo] ++(1,0) to[zzD-] ++(1,0)
2886 to[zzD*] ++(1,0) to[tvsD-] ++(2,0);
2887 \ctikzset{diode straight whiskers}
2888 \draw (0,0) to [zzDo] ++(1,0) to[zzD-] ++(1,0)
2889 to[zzD*] ++(1,0) to[tvsD-] ++(2,0);
2890 \end{tikzpicture}
2891 \end{ctikzExample}
2892
2893 \subsection{Sources and generators}
2894 \label{sec:sources-and-generators}
2895
2896 Notice that source and generators are divided in three classes that can be styled independently: traditional battery symbols (class \IndexKey{batteries}), independent generators (class \IndexKey{sources}) and dependent generators (class \IndexKey{csources}). This is because they are often treated differently, and so you can choose to, for example, fill the dependent sources but not the independent ones.
2897
2898 \subsubsection{Batteries}
2899 \label{sec:batteries}
2900 \begin{groupdesc}
2901 \circuitdescbip{battery}{Battery}{}
2902 \circuitdescbip{battery1}{Single battery cell}{}
2903 \circuitdescbip{battery2}{Single battery cell}{}
2904 \circuitdescbip{solar}{Solar-driven battery (arrows follow the same style options as photodiodes, see \ref{sec:opto-arrows})\footnotemark}{}
2905 \footnotetext{Contributed by \href{https://github.com/circuitikz/circuitikz/pull/693}{Dr. Matthias Jung}.}
2906 \circuitdescbip{baertty}{Randall Munroe's baertty\footnotemark}{}
2907 \footnotetext{\href{https://xkcd.com/2818}{Mandatory xkcd}}
2908 \end{groupdesc}
2909
2910 \subsubsection{Stationary sources}
2911 \label{sec:stationary-sources}
2912 \begin{groupdesc}
2913 \circuitdescbip*[vsource]{european voltage source}{Voltage source (european style)}{vsource, vsourceEU}
2914 \circuitdescbip*[vsourceC]{cute european voltage source}{Voltage source (cute european style)}{vsourceC, ceV}
2915 \circuitdescbip*[vsourceAM]{american voltage source}{Voltage source (american style)}{vsourceAM}
2916 \circuitdescbip*[isource]{european current source}{Current source (european style)}{isource, isourceEU}
2917 \circuitdescbip*[isourceC]{cute european current source}{Current source (cute european style)}{isourceC, ceI}
2918 \circuitdescbip*[isourceAM]{american current source}{Current source (american style)}{isourceAM}
2919 \end{groupdesc}
2920
2921 \begin{framed}
2922 If (default behavior) \IndexKey{europeancurrents} option is active (or the style \IndexKey{european currents} is used), the shorthands \texttt{current source}, \texttt{isource}, and \texttt{I} are equivalent to \texttt{european current source}. Otherwise, if \texttt{americancurrents} option is active (or the style \texttt{[american currents]} is used) they are equivalent to \texttt{american current source}.
2923
2924 Similarly, if (default behavior) \IndexKey{europeanvoltages} option is active (or the style \texttt{european voltages} is used), the shorthands \texttt{voltage source}, \texttt{vsource}, and \texttt{V} are equivalent to \texttt{european voltage source}. Otherwise, if \IndexKey{americanvoltages} option is active (or the style \IndexKey{american voltages} is used) they are equivalent to \texttt{american voltage source}.
2925 \end{framed}
2926
2927 \subsubsection{Sinusoidal sources}\label{sec:sinusoidal-vi} These two are basically the same symbol; to distinguish among them, you have to add a label, which will be a voltage or a current. Another option would be to configure the \texttt{sinusoidal current source} as an open shape using \texttt{\textbackslash ctikzset\string{bipoles/isourcesin/angle=80\string}} similar to the \texttt{dcisource} in section~\ref{sec:dc-sources}.
2928
2929 \begin{groupdesc}
2930 \circuitdescbip*[vsourcesin]{sinusoidal voltage source}{Sinusoidal voltage source}{vsourcesin, sV}
2931 \circuitdescbip*[isourcesin]{sinusoidal current source}{Sinusoidal current source\footnotemark}{isourcesin, sI}
2932 \footnotetext{The configurable open shape of the \texttt{sinusoidal current source} has been added by \href{https://github.com/circuitikz/circuitikz/pull/737}{Maximilian Martin}}
2933 \end{groupdesc}
2934
2935 \begin{ctikzExample}
2936 \begin{circuitikz}[american]
2937 \draw (0,2) to[sV=$V$] ++(3,0);
2938 \draw (0,1) to[sI=$I$] ++(3,0);
2939 \ctikzset{bipoles/isourcesin/angle=80}
2940 \draw (0,0) to[sI] ++(3,0);
2941 \end{circuitikz}
2942 \end{ctikzExample}
2943
2944 \subsubsection{Controlled sources}
2945 \label{sec:controlled-sources}
2946 \begin{groupdesc}
2947 \circuitdescbip*[cvsource]{european controlled voltage source}{Controlled voltage source (european style)}{cvsource, cvsourceEU}
2948 \circuitdescbip*[cvsourceC]{cute european controlled voltage source}{Voltage source (cute european style)}{cvsourceC, cceV}
2949 \circuitdescbip*[cvsourceAM]{american controlled voltage source}{Controlled voltage source (american style)}{cvsourceAM}
2950 \circuitdescbip*[cisource]{european controlled current source}{Controlled current source (european style)}{cisource, cisourceEU}
2951 \circuitdescbip*[cisourceC]{cute european controlled current source}{Current source (cute european style)}{cisourceC, cceI}
2952 \circuitdescbip*[cisourceAM]{american controlled current source}{Controlled current source (american style)}{cisourceAM}
2953 \circuitdescbip*[ecsource]{empty controlled source}{Empty controlled source}{ecsource}
2954 \end{groupdesc}
2955
2956 \begin{framed}
2957 If (default behavior) \IndexKey{europeancurrents} option is active (or the style \IndexKey{european currents} is used), the shorthands \texttt{controlled current source}, \texttt{cisource}, and \texttt{cI} are equivalent to \texttt{european controlled current source}. Otherwise, if \IndexKey{americancurrents} option is active (or the style \IndexKey{american currents} is used) they are equivalent to \texttt{american controlled current source}.
2958
2959 Similarly, if (default behavior) \IndexKey{europeanvoltages} option is active (or the style \IndexKey{european voltages} is used), the shorthands \texttt{controlled voltage source}, \texttt{cvsource}, and \texttt{cV} are equivalent to \texttt{european controlled voltage source}. Otherwise, if \IndexKey{americanvoltages} option is active (or the style \IndexKey{american voltages} is used) they are equivalent to \texttt{american controlled voltage source}.
2960 \end{framed}
2961
2962 The following two behave like the corresponding independent sources, see section~\ref{sec:sinusoidal-vi}.
2963
2964 \begin{groupdesc}
2965 \circuitdescbip*[cvsourcesin]{controlled sinusoidal voltage source}{Controlled sinusoidal voltage source}{controlled vsourcesin, cvsourcesin, csV}
2966 \circuitdescbip*[cisourcesin]{controlled sinusoidal current source}{Controlled sinusoidal current source}{controlled isourcesin, cisourcesin, csI}
2967 \end{groupdesc}
2968
2969
2970
2971 \subsubsection{Noise sources}
2972 \label{sec:noise-sources}
2973
2974 In this case, the ``direction'' of the source is undefined. Noise sources are filled in gray by default, but if you choose the dashed style, they become fillable.
2975
2976 \begin{groupdesc}
2977 \circuitdescbip[vsourceN]{noise voltage source}{Sinusoidal voltage source}{vsourceN, nV}
2978 \circuitdescbip[isourceN]{noise current source}{Sinusoidal current source}{isourceN, nI}
2979 \end{groupdesc}
2980
2981 You can change the fill color with the key \IndexKey[noise sources/fillcolor]{circuitikz/bipoles/noise sources/fillcolor}:
2982 \begin{ctikzExample}
2983 \begin{circuitikz}
2984 \draw(0,0) to [nV, l=$e_n$] ++(2,0);
2985 \draw(0,-2) to [nI, l=$i_n$] ++(2,0);
2986 \begin{scope}[circuitikz/bipoles/noise sources/fillcolor=red!50]
2987 \draw(3,0) to [nV, l=$e_n$] ++(2,0);
2988 \draw(3,-2) to [nI, l=$i_n$] ++(2,0);
2989 \end{scope}
2990 \end{circuitikz}
2991 \end{ctikzExample}
2992
2993 If you prefer a patterned noise generator (similar to the one you draw by hand) you can use the fake color \texttt{dashed}:
2994 \begin{ctikzExample}
2995 \begin{circuitikz}
2996 \draw(0,0) to [nV, l=$e_n$] ++(2,0);
2997 \draw(0,-2) to [nI, l=$i_n$] ++(2,0);
2998 \begin{scope}[circuitikz/bipoles/noise sources/fillcolor=dashed]
2999 \draw(3,0) to [nV, l=$e_n$] ++(2,0);
3000 \draw(3,-2) to [nI, l=$i_n$] ++(2,0);
3001 \end{scope}
3002 \end{circuitikz}
3003 \end{ctikzExample}
3004
3005 Notice that if you choose the dashed style, the noise sources are fillable:
3006 \begin{ctikzExample}
3007 \begin{circuitikz}
3008 \ctikzset{bipoles/noise sources/fillcolor=dashed}
3009 \draw(0,0) to [nV, l=$e_n$] ++(2,0);
3010 \draw(0,-2) to [nI, l=$i_n$] ++(2,0);
3011 \begin{scope}
3012 \draw(3,0) to [nV, l=$e_n$, fill=yellow!50!red] ++(2,0);
3013 \draw(3,-2) to [nI, l=$i_n$, fill=blue!50!white] ++(2,0);
3014 \end{scope}
3015 \end{circuitikz}
3016 \end{ctikzExample}
3017
3018 \subsubsection{Special sources}
3019 \label{sec:special-sources}
3020 \begin{groupdesc}
3021 \circuitdescbip*[vsourcesquare]{square voltage source}{Square voltage source}{vsourcesquare, sqV}
3022 \circuitdescbip*{vsourcetri}{Triangle voltage source}{tV}
3023 \circuitdescbip*{esource}{Empty voltage source}{}
3024 \circuitdescbip*{pvsource}{Photovoltaic-voltage source}{}
3025 \circuitdescbip*{pvmodule}{Photovoltaic module source\footnotemark}{}
3026 \footnotetext{Added by André Alves in \texttt{v1.3.5}}
3027 \circuitdescbip*[oosource]{ioosource}{Double Zero style current source}{}
3028 \circuitdescbip*[oosource]{voosource}{Double Zero style voltage source}{}
3029 \circuitdescbip*[oosourceatrans]{oosourceatrans}{auto-transformer source\footnotemark}{}(centerprim/90/0.4, primup/30/0.2, primdown/-30/0.2)
3030 \footnotetext{The \texttt{oosourceatrans} component has been suggested by \href{https://github.com/circuitikz/circuitikz/issues/852}{Max Börjesson on GitHub}}
3031 \circuitdescbip*[oosourcetrans]{oosourcetrans}{transformer source\footnotemark}{}(centerprim/90/0.4, centersec/-90/0.4, secup/30/0.2, secdown/-30/0.2, primup/150/0.2, primdown/210/0.2)
3032 \footnotetext{The \texttt{oosourcetrans} and \texttt{ooosource} components have been added by \href{https://github.com/circuitikz/circuitikz/pull/397}{user \texttt{@olfline} on GitHub}}
3033 \begingroup
3034 \ctikzset{sources/scale=1.5}
3035 \circuitdescbip*[ooosource]{ooosource}{transformer with three windings\footnotemark}{}(left/175/0.2, right/5/0.7, prim1/130/.2, prim2/-130/.2, sec1/35/.2, sec2/60/.2, sec3/90/.2, tert1/0/.2, tert2/-45/.2, tert3/-90/.2, centerprim/92/0.8, centersec/35/0.9, centertert/-35/0.8)
3036 \footnotetext{The component here is scaled up 1.5 times to better show the anchors.}
3037 \endgroup
3038 \end{groupdesc}
3039
3040 The transformer shapes vector group options can be specified for the primary (\IndexKey[prim]{prim=\emph{value}}), the secondary (\IndexKey[sec]{sec=\emph{value}}) and tertiary (\IndexKey[tert]{tert=\emph{value}}) three-phase vector groups: the value can be one of \IndexKey{delta}, \IndexKey{wye}, \IndexKey{eyw}\footnote{The \IndexKey{eyw} symbol was suggested by \href{https://github.com/circuitikz/circuitikz/pull/742}{Jakob Leide on GitHub}} and \IndexKey{zig}.
3041
3042 \begin{ctikzExample}
3043 \begin{circuitikz}
3044 \draw (0,0) to[oosourcetrans, prim=zig, sec=delta, o-] ++(2,0)
3045 to[oosourcetrans, prim=delta, sec=wye,-o] ++(0,-2)
3046 to[ooosource, prim=eyw, sec=zig, tert=delta] (0,0)
3047 to[oosourceatrans, prim=wye, -*] ++(0,-2);
3048 \end{circuitikz}
3049 \end{ctikzExample}
3050
3051 These two ``sources'' have additional anchors that reach the center of the symbol;\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/725}{user @lapreindl on GitHub}.} they are used sometimes to add a (symbolic) connection there, like for example a ground connection.
3052
3053 \begin{ctikzExample}
3054 \begin{tikzpicture}[european, scale=2, transform shape,
3055 smalldot/.style={draw, circle,red, inner sep=0.2pt}]
3056 \draw (0,0) to[oosourcetrans, name=A,
3057 prim=delta, sec=wye] ++(1,0)
3058 to[ooosource, name=B, prim=eyw, sec=zig,
3059 tert=delta] ++(1,0)
3060 (A.symbolsec) -- ++(-45:0.5) node[ground]{};
3061 \node [smalldot] at (A.symbolprim) {};
3062 \node [smalldot] at (A.symbolsec) {};
3063 \node [smalldot] at (B.symbolprim) {};
3064 \node [smalldot] at (B.symbolsec) {};
3065 \node [smalldot] at (B.symboltert) {};
3066 \end{tikzpicture}
3067 \end{ctikzExample}
3068
3069 \subsubsection{Nullator and norator}
3070 \label{sec:nullator-and-norator}
3071
3072 These are special elements used in some approaches to model ideal amplifiers\footnote{See \href{https://en.m.wikipedia.org/wiki/Nullor}{the Wikipedia article}; suggested by \href{https://github.com/circuitikz/circuitikz/issues/615}{user atticus-sullivan on GitHub}.}.
3073
3074 \begin{groupdesc}
3075 \circuitdescbip*{nullator}{Nullator element (virtual short circuit; forces V and I to zero)}{}
3076 \circuitdescbip*{norator}{Norator element (admits any combination of V and I)}{}
3077 \end{groupdesc}
3078
3079 They are in the \texttt{sources} class, but they are not treated like sources in the labeling sense (they have both \texttt{bipoles/is voltage=false} and \texttt{bipoles/is current=false}, see~\ref{sec:source-vif}).
3080
3081 \begin{ctikzExample}
3082 \begin{circuitikz}[american]
3083 \draw (0,0) node[ground](GND){}
3084 to [I,l=$i_s$,invert]
3085 ++(0,2.5) -- ++(1.5,0) coordinate(up)
3086 to[nullator, v=0, i=0, name=A]
3087 (up|-GND) node[ground]{};
3088 \draw (up) to[R, *-*] ++(2,0) coordinate(out)
3089 to[norator, v^=$v_o$]
3090 (out|-GND) node[ground]{};
3091 \end{circuitikz}
3092 \end{ctikzExample}
3093
3094 The symbol shapes used here seems to be the most common in publications; if you prefer the shapes from the Wikipedia article, you can use the following definitions:
3095
3096 \begin{ctikzExample}
3097 \tikzset{noratorW/.style={voosource,
3098 bipoles/oosource/width=0.6,
3099 bipoles/oosource/height=0.3},
3100 nullatorW/.style={esource, sources/scale=0.5}}
3101 \begin{tikzpicture}
3102 \draw (0,0) to[nullatorW] ++(2,0) to[noratorW] ++(0, -2);
3103 \end{tikzpicture}
3104 \end{ctikzExample}
3105
3106 \subsubsection{DC sources}\label{sec:dc-sources}
3107 \begin{groupdesc}
3108 \circuitdescbip*{dcvsource}{DC voltage source}{}
3109 \circuitdescbip*{dcisource}{DC current source}{}
3110 \end{groupdesc}
3111
3112 The size of the broken part of the DC current source is configurable by changing the value of \IndexKey{bipoles/dcisource/angle} (default \texttt{80}); values must be between 0 (no circle at all, probably not useful) and 90 (full circle, again not useful).
3113 \begin{ctikzExample}
3114 \begin{circuitikz}
3115 \draw (0,0) to[dcvsource] ++(2,0)
3116 to [dcisource, fill=yellow] ++(2,0) ;
3117 \ctikzset{bipoles/dcisource/angle=45}
3118 \draw (0,-2) to[dcvsource] ++(2,0)
3119 to [dcisource, fill=yellow] ++(2,0) ;
3120 \end{circuitikz}
3121 \end{ctikzExample}
3122
3123 \subsubsection{Sources customizations}\label{sec:tweak-sources}
3124
3125 \paragraph{Size.}
3126 \label{par:source-size}
3127 You can change the scale of the batteries by setting the key \IndexKey{batteries/scale}, for the controlled (dependent) sources with \IndexKey{csources/scale}, and for all the other independent sources and generators with \IndexKey{sources/scale}, to something different from the default \texttt{1.0}.
3128
3129 Notice that the size of the double-circle sources (and of the triple-circle one) are tuned so that the full source occupy more or less the same horizontal space than one of the single-circle one; as a consequence, the circles are much smaller. If you want to have the same circle radius, you have to scale (locally!) those sources by one factor that is \texttt{1.5384} ($1/0.65$) for \texttt{oosource}, \texttt{1.6667} ($1/0.6$) for \texttt{oosourcetrans}, and \texttt{1.8182} ($1/0.55$) for \texttt{ooosource}.
3130
3131 \begin{ctikzExample}
3132 \begin{circuitikz}
3133 \draw[color=red] (0,0) to[esource] ++(3,0);
3134 \draw (0,0) to[oosourcetrans, prim=delta, sec=wye,
3135 sources/scale=1.667] ++(3,0);
3136 \end{circuitikz}
3137 \end{ctikzExample}
3138
3139 Alternatively, you can use the key \IndexKey{ootrans size} (which has possible values \texttt{small} and \texttt{large}, default \texttt{small}) to change the sizes of \texttt{oosourcetrans}, \texttt{oosourceatrans}, and \texttt{ooosource} so that they match the size of a normal source.
3140
3141 \begin{ctikzExample}
3142 \begin{circuitikz}
3143 \draw[color=red] (0,2) to[esource] ++(2,0);
3144 \draw (0,2) to[oosourcetrans] ++(2,0)
3145 to [oosourceatrans] ++(2,0)
3146 to [ooosource] ++(2,0);
3147 \ctikzset{ootrans size=large}
3148 \draw[color=red] (0,0) to[esource] ++(2,0);
3149 \draw (0,0) to[oosourcetrans] ++(2,0)
3150 to [oosourceatrans] ++(2,0)
3151 to [ooosource] ++(2,0);
3152 \end{circuitikz}
3153 \end{ctikzExample}
3154
3155 \paragraph{Waveform symbols.}
3156 \label{par:waveform-symbols}
3157 Internal symbols of sinusoidal, triangular and square sources are drawn with the same line thickness as the component by default. You can modify this by setting the key \IndexKey{sources/symbol/thickness} for independent sources and the corresponding \texttt{csource/...} for dependent ones. The value used here is relative to the component (i.e. the circle) value.
3158
3159 Normally the symbol is oriented in the same direction as the line, and rotate rigidly with the component; you can change this orientation using the key \IndexKey{sources/symbol/rotate} or \texttt{csource/...}. The default value is \texttt{90} which correspond to the ``line'' direction (remember, path components are defined as horizontal ones).
3160 If instead of an angle value you use \texttt{auto}, the symbol will be rotated so that the waveform is always vertical, similar to what happens in instruments:
3161
3162 \begin{ctikzExample}
3163 \begin{circuitikz}
3164 \draw (0,1) to[sqV] ++(3,0)
3165 to[sqV] ++(1,-1)
3166 to[sqV] ++(0,-3);
3167 \ctikzset{sources/symbol/rotate=auto}
3168 \ctikzset{sources/symbol/rotate=auto, sources/symbol/thickness=3}
3169 \draw[color=red] (0,0) to[sqV] ++(3,0)
3170 to[sqV] ++(0,-3)
3171 to[sqV] (0,0);
3172 \end{circuitikz}
3173 \end{ctikzExample}
3174
3175
3176 \paragraph{Polarity symbols.}
3177 \label{par:polarity-symbols}
3178 The symbols drawn into the \texttt{american voltage source}\footnote{Since version \texttt{1.1.0}, thanks to the suggestions and discussion
3179 \href{https://tex.stackexchange.com/questions/538723/circuitikz-what-should-i-do-to-put-the-and-on-the-appropriate-places-like-t}{in this TeX.SX question}.} can be changed by using the \verb|\ctikzset| keys \IndexKey{bipoles/vsourceam/inner plus} and \IndexKey[bipoles/vsourcesam/inner minus]{.../inner minus} (by default they are \verb|$+$| and \verb|$\vphantom{+}-$| respectively, in the current font), and move them nearer of farther away by twiddling \IndexKey{bipoles/vsourceam/margin} (default \texttt{0.7}, less means nearer). The reason of the \verb|\vphantom| can be found in section~\ref{sec:american-voltage-custom}.
3180
3181 You can do the same with the \texttt{american controlled voltage sources}, substituting \texttt{cvsourceam} to \texttt{vsourceam} (notice the initial ``\texttt{c}'').
3182
3183 \begin{ctikzExample}
3184 \begin{circuitikz}[american]
3185 \ctikzset{bipoles/vsourceam/inner plus={\tiny $+$}}
3186 \ctikzset{bipoles/vsourceam/inner minus={\tiny $-$}}
3187 \draw (0,0) to[V, l_=$V$] ++(0,3)
3188 to[R=\SI{5}{\ohm}] ++(3,0)
3189 to[V, invert,
3190 bipoles/vsourceam/inner plus={\color{red}\tiny $\oplus$},
3191 bipoles/vsourceam/inner minus={\color{blue}\tiny $\ominus$},
3192 bipoles/vsourceam/margin=0.5]
3193 ++(0,-3) to[short, -*] (0,0) node[ground]{};
3194 \end{circuitikz}
3195 \end{ctikzExample}
3196
3197 \paragraph{Orientation of the polarity symbols.}
3198 \label{par:orientation-of-the}
3199
3200 When rotating the sources, they usually move rigidly. This results in the fact that American voltage sources look nice when vertical but could be better in other directions. Since \texttt{v1.6.7}\footnote{Thanks to the suggestions and discussion
3201 \href{https://github.com/circuitikz/circuitikz/issues/773}{by user @jotagah on GitHub}.}, you can choose several rotation modes for those symbols (independent and dependent sources).
3202
3203 You can obtain several different rotations or rotation modes by changing the value of the key \IndexKey{sources/symbol/sign rotation} (with \verb!\ctikzset!). The value \texttt{default} (also the default value!) uses the legacy, ``rigid'' position.
3204
3205 If you provide a number, the symbols are rotated by that value (\texttt{0} means that the minus sign is aligned with the wire, \texttt{90} is very similar to \texttt{default}\footnote{Not exactly equal; the position of the symbols could be slightly different depending on the font.}).
3206 If you use \texttt{straight}, the symbols are rotated to be always horizontal. With \texttt{auto}, the symbols are drawn in the same way as \texttt{0} for inclination less the \SI{45}{\degree}, and as \texttt{90} otherwise.The following drawing shows the results for several different parameter values.
3207
3208 \begin{ctikzExample}[varwidth=true, pos=t]
3209 \begin{tikzpicture}[american, scale=0.6, transform shape]
3210 %\ctikzset{sources/symbol/sign rotation=default}
3211 \foreach \a in {0,30,...,359} \draw (0,0) -- ++(\a:1) to[V] ++(\a:2);
3212 \ctikzset{sources/symbol/sign rotation=0}
3213 \foreach \a in {0,30,...,359} \draw[color=red] (6,0) -- ++(\a:1) to[V] ++(\a:2);
3214 \ctikzset{sources/symbol/sign rotation=auto}
3215 \foreach \a in {0,30,...,359} \draw[color=blue] (12,0) -- ++(\a:1) to[V] ++(\a:2);
3216 \ctikzset{sources/symbol/sign rotation=straight}
3217 \foreach \a in {0,30,...,359} \draw (18,0) -- ++(\a:1) to[V] ++(\a:2);
3218 \end{tikzpicture}
3219 \end{ctikzExample}
3220
3221
3222
3223 \paragraph{Three-phase symbols.}
3224 \label{par:three-phase-symbols}
3225 The three-phase symbols \texttt{delta}, \texttt{wye}, \texttt{eyw}, and \texttt{zig} follows the line thickness exactly as
3226 the waveform ones (see above). Additionally, you can scale them up and down by changing the value of the keys
3227 \IndexKey{sources/symbol/delta scale}, \IndexKey[sources/symbol/wye scale]{.../wye scale}, \IndexKey[sources/symbol/eyw scale]{.../eyw scale}, and \IndexKey[sources/symbol/zig scale]{.../zig scale} (default \texttt{1}).
3228
3229 \begin{ctikzExample}
3230 \begin{circuitikz}[scale=1.8, transform shape]
3231 \tikzset{myoosource/.style={ooosource,
3232 prim=wye, sec=delta, tert=zig,
3233 }}
3234 \draw (0,2) to[myoosource] ++(2,0);
3235 \ctikzset{%
3236 sources/symbol/thickness=0.5,
3237 sources/symbol/delta scale=1.2,
3238 sources/symbol/wye scale=1.4,
3239 sources/symbol/zig scale=1.3,
3240 }
3241 \draw (0,0) to[myoosource] ++(2,0);
3242 \end{circuitikz}
3243 \end{ctikzExample}
3244
3245 \paragraph{Rotating the three-phase symbols.}
3246 \label{par:rotating-the-three}
3247 You have several keys to rotate, locally or globally, the three-phase symbols\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/886}{Jakob Leide}}.
3248 The symbols can be rotated (with effect on every symbol of that type) with the key \IndexKey{sources/symbol/delta rot} and similar ones for \texttt{eyw}, \texttt{wye} and \texttt{zig}.
3249 Additionally, you can rotate the symbol on a specific winding by usin the key \IndexKey{sources/symbol/prim rot} and similar ones for \texttt{sec}, \texttt{tert} and \texttt{upper}.
3250
3251 \begin{ctikzExample}
3252 \begin{circuitikz}[scale=1.5, transform shape]
3253 \draw (0,0) to[oosourcetrans, prim=delta, sec=delta,
3254 sources/symbol/sec rot=180] ++(2,0);
3255 \draw (0,-1) to[ooosource, prim=eyw, sec=delta,
3256 tert=delta, sources/symbol/delta rot=180] ++(2,0);
3257 \end{circuitikz}
3258 \end{ctikzExample}
3259
3260 \subsubsection{Source borders}
3261 \label{sec:source-borders}
3262
3263 Unfortunately, the border of the sources is only easily accessed if some anchor is provided.
3264 The border anchors of the shapes are not tight on them (see section~\ref{sec:bipoles-border-anchors}), which is not easily changeable, given that the algorithm that positions the labels depends on it.
3265
3266 On the other hand, \TikZ{} powerful \href{https://tikz.dev/tikz-coordinates\#sec-13.5.3}{partway coordinate calculation} (around section 13.5.3 of the manual) makes it possible to easily identify points on a circle if the center and one point of the circle are known, as you can see in the following example.
3267
3268 \begin{ctikzExample}
3269 \begin{tikzpicture}[]
3270 \path (0,0) to[oosourcetrans, name=T, ]++(2,0);
3271 % Use partway modifiers to reach a point on the left circle
3272 \draw ($(T.centerprim)!1!45:(T.left)$) -- ++(-135:0.2)
3273 -- ++(0,-1) node[ground]{};
3274 \begin{scope}[font=\tiny\ttfamily, pin distance=2mm, inner sep=0pt]
3275 \foreach \a in {-90,-45,...,90}
3276 \node [circ, scale=0.5, pin=\a:\a, color=red] at
3277 ($(T.centersec)!1!\a:(T.right)$){};
3278 \end{scope}
3279 \end{tikzpicture}
3280 \end{ctikzExample}
3281
3282 A similar approach can be used for dependent sources. Just remember that the anchors move (rotate) together with the component.
3283
3284 \begin{ctikzExample}
3285 \begin{tikzpicture}[american]
3286 \draw (0,0) to [cvsource, name=S] ++(0,2);
3287 \node [circ,red] at ($(S.e)!0.3333!(S.n)$) {};
3288 \node [circ,blue] at ($(S.e)!0.6666!(S.n)$) {};
3289 \end{tikzpicture}
3290 \end{ctikzExample}
3291
3292 \paragraph{Additional winding.}
3293 \label{par:additional-winding}
3294 The \texttt{oosourcetrans} and \texttt{oosourceatrans} components admit an additional winding, called \emph{upper} winding\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/886}{Jakob Leide}}.
3295 It can be added by specifying the key \IndexKey{oo upper winding}; you can pass an additional parameter specifying the size (relative to the symbol circle size) of the added circle. The default is \texttt{0.7}, but even the default can be changed by setting the key \IndexKey{bipoles/oosourcetrans/upper circle size default}. The height of the additional winding can be tweaked with the key \IndexKey{bipoles/oosourcetrans/upper circle offset} (default \texttt{\ctikzvalof{bipoles/oosourcetrans/upper circle offset}}, which tries to mimic the shape of \texttt{ooosource}).
3296
3297 \begin{ctikzExample}
3298 \begin{circuitikz}[scale=1.5, transform shape]
3299 \draw (0,0) to[oosourcetrans, prim=delta, o-o, name=a,
3300 sources/symbol/delta rot=180,
3301 oo upper winding, upper=delta, sec=wye,
3302 ] ++(2,0);
3303 \draw (a.centerprim) -- ++(210:0.4) node[ground]{};
3304 \draw (a.uppertop) -- ++(90:0.1) node[vcc]{};
3305 \draw [red] (a.symbolupper) to[short,-o] ++(45:0.5);
3306 \draw (0,-1) to[oosourcetrans, oo upper winding=1
3307 ] ++(2,0);
3308 \end{circuitikz}
3309 \end{ctikzExample}
3310
3311 \paragraph{Additional winding anchors.}
3312 \label{par:additional-winding-anchors}
3313 When using the upper winding, you have several additional anchors available.
3314
3315 \begin{ctikzExample}
3316 \begin{circuitikz}[scale=1.5, transform shape,
3317 smallsquare/.style={red, draw, inner sep=1pt}]
3318 \draw (0,0) to[oosourcetrans, oo upper winding=0.85,
3319 name=a, fill=cyan!30,upper=wye,
3320 sources/symbol/upper rot=-90] ++(2,0);
3321 \foreach\anc/\ang in {centerupper/-45, uppertop/90,
3322 topright/30, topleft/150, symbolupper/210}
3323 \draw[red] (a.\anc) node[smallsquare]{} -- ++(\ang:0.5)
3324 ++(\ang:0.1) node[font=\tiny\ttfamily,]{\anc};
3325 \end{circuitikz}
3326 \end{ctikzExample}
3327
3328 \begin{ctikzExample}
3329 \begin{circuitikz}[scale=1.5, transform shape,
3330 smallsquare/.style={red, draw, inner sep=1pt}]
3331 \draw (0,0) to[oosourceatrans, oo upper winding=0.75,
3332 name=a, fill=cyan!30,prim=delta,upper=delta,
3333 sources/symbol/upper rot=180] ++(2,0);
3334 \foreach\anc/\ang in {centerupper/-45, uppertop/90,
3335 topright/30, topleft/150, symbolupper/210}
3336 \draw[red] (a.\anc) node[smallsquare]{} -- ++(\ang:0.5)
3337 ++(\ang:0.1) node[font=\tiny\ttfamily,]{\anc};
3338 \end{circuitikz}
3339 \end{ctikzExample}
3340
3341 \subsection{Instruments}
3342 \label{sec:instruments}
3343 \subsubsection{Basic round instruments}
3344 \label{sec:basic-round-instruments}
3345
3346 \begin{groupdesc}
3347 \circuitdescbip*{rmeter}{Round meter (use \texttt{t=...} for the symbol)}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
3348 \circuitdescbip*{rmeterwa}{Round meter with arrow (use \texttt{t=...} for the symbol)}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
3349 \circuitdescbip*{ammeter}{Legacy ammeter}{}
3350 \circuitdescbip*{voltmeter}{Legacy voltmeter}{}
3351 \circuitdescbip*{ohmmeter}{Legacy ohmmeter}{}
3352 \end{groupdesc}
3353
3354 You can define styles if you want to use the new shapes for round instrument similarly to the legacy ones:%
3355 \footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/787}{user mxxmxn on GitHub}.}
3356
3357 \begin{ctikzExample}
3358 \tikzset{vmeter/.style={rmeterwa, t=V}}
3359 \tikzset{ameter/.style={rmeterwa, t=A}}
3360 \tikzset{ometer/.style={rmeterwa, t=$\Omega$}}
3361
3362 \begin{tikzpicture}
3363 % Old meter style
3364 \draw (0,2) to[voltmeter] ++(2,0)
3365 to[ammeter] ++(2,0)
3366 to[ohmmeter] ++(2,0);
3367 % New meter style
3368 \draw (0,0) to[vmeter] ++(2,0)
3369 to[ameter] ++(2,0)
3370 to[ometer] ++(2,0);
3371 \end{tikzpicture}
3372 \end{ctikzExample}
3373
3374 \subsubsection{Square instruments}
3375 \label{sec:square-instruments}
3376
3377 Sometimes it is better to use a shape for instruments which is very different from the round symbols used for sources.
3378
3379 \begin{groupdesc}
3380 \circuitdescbip*{smeter}{Square meter (use \texttt{t=...} for the symbol)}{}(left/135/0.2, right/45/0.2, center/-90/0.3, in 1/-135/.5, in 2/-45/.5)
3381 \circuitdescbip*{qiprobe}{QUCS-style current probe}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
3382 \circuitdescbip*{qvprobe}{QUCS-style voltage probe}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
3383 \circuitdescbip*{qpprobe}{QUCS-style power probe}{}(left/135/0.2, right/45/0.2, center/-90/0.3, v+/-135/.5, v-/-45/.5)
3384 \end{groupdesc}
3385
3386 \subsubsection{Oscilloscopes and current probes}
3387 \label{sec:oscilloscopes-and-current}
3388
3389 \begin{groupdesc}
3390 \circuitdescbip*[oscope]{oscope}{Oscilloscope\footnotemark}{}(left/135/0.2, right/45/0.2,
3391 in 1/-135/0.4, in 2/-45/0.4)
3392 \footnotetext{Suggested by \texttt{@nobrl} on GitHub}
3393 \circuitdescbip{iloop}{Current loop (symbolic)}{}(left/135/0.2, right/45/0.2, center/-90/0.3, i/30/0.4)
3394 \circuitdescbip{iloop2}{Current loop (real)}{}(left/135/0.2, right/-45/0.2, center/-90/0.3, i+/135/0.4, i-/45/0.4)
3395 \circuitdescbip{currtap}{Current tap (probe)\footnotemark}{}(tap/-90/0.2)
3396 \footnotetext{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/807}{user EEpchi on GitHub}.}
3397 \end{groupdesc}
3398
3399 \subsubsection{Instruments customizations}\label{sec:tweak-instruments}
3400
3401 You can change the scale of all the instruments (including the current loops) by setting the key \IndexKey{instruments/scale} to something different from the default \texttt{1.0}.
3402
3403 \paragraph{Current probes.}
3404 \label{par:current-probes}
3405 You can change the inner dot in several way, by changing the following keys under the \verb!\ctikzset! key \IndexKey{bipoles/currtap}:
3406 \begin{center}
3407 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{0.7\linewidth}}
3408 \toprule
3409 parameter & default & description \\
3410 \midrule
3411 thickness & default & Set the thickness of the line (\texttt{default}: do not change the class thickness) \\
3412 color & default & stroke color: \texttt{default} is the same as the component \\
3413 dash & default & dash pattern: none means solid line, default means keep the global pattern\footnotemark \\
3414 fill & default & fill the inner dot; \texttt{default} means use the wire color, \texttt{none} do not fill, other keys must be a valid color \\
3415 dot size& 0.5 & relative size of the inner dot \\
3416 \bottomrule
3417 \end{tabular}
3418 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
3419 \end{center}
3420
3421 \begin{ctikzExample}
3422 \begin{circuitikz}
3423 \draw (0,2) to[currtap, bipoles/currtap/fill=none, *-]
3424 ++(2,0) to[currtap, bipoles/currtap/.cd,
3425 fill=yellow, color=red, thickness=3,
3426 dash={{1.14pt}{2pt}}] ++(2,0);
3427 \draw (0,0) to[currtap=I, *-, name=ct] ++(2,0)
3428 to[currtap, -*, name=ct2,
3429 bipoles/currtap/dot size=0.3] ++(2,0);
3430 \draw (ct.tap) -- ++(0,-1) (ct2.tap) -- ++(0,-1);
3431 \end{circuitikz}
3432 \end{ctikzExample}
3433
3434 \paragraph{Square instruments index position.} You can change the index position of square
3435 \label{par:square-instruments-index}
3436 instruments with the key \IndexKey{bipoles/smeter/index position} (for \texttt{smeter}) or
3437 \IndexKey{bipoles/qmeter/index position} (for \texttt{qiprobe}, \texttt{qvprobe} and \texttt{qpprobe}).
3438 Use a value between \texttt{0} and \texttt{100} (the default is \texttt{80}).
3439
3440 \begin{ctikzExample}
3441 \begin{circuitikz}
3442 % Default
3443 \foreach [count=\i] \inst in
3444 {smeter, qiprobe, qvprobe, qpprobe} {
3445 \draw ({1.5*\i},1.4) to[\inst]
3446 ({1.5*(\i+1)},1.4);
3447 }
3448 % New indexes
3449 \ctikzset{bipoles/smeter/index position=50}
3450 \ctikzset{bipoles/qmeter/index position=25}
3451 \foreach [count=\i] \inst in
3452 {smeter, qiprobe, qvprobe, qpprobe} {
3453 \draw ({1.5*\i},0) to[\inst]
3454 ({1.5*(\i+1)},0);
3455 }
3456 \end{circuitikz}
3457 \end{ctikzExample}
3458
3459 \paragraph{Oscilloscope waveform.} You can change the waveform shown in the oscilloscope ``screen''\footnote{Suggested by \href{https://tex.stackexchange.com/q/595062/38080}{Mario Tafur on TeX.SX}}. To change it, you just set the key \IndexKey{bipoles/oscope/waveform} to one of the available shape. You have available the shapes in the following list (the default is \texttt{ramps}):
3460 \label{par:oscilloscope-waveform}
3461
3462 \begin{ctikzExample}[pos=t]
3463 \begin{circuitikz}
3464 \foreach [count=\i] \wvf in {ramps, sin, square, triangle, lissajous, zero, none} {
3465 \ctikzset{bipoles/oscope/waveform=\wvf}
3466 \draw ({2*\i},1.4) node[oscopeshape](O){}
3467 ({2*\i},0.65) node[anchor=base]{\texttt{\wvf}};
3468 }
3469 \ctikzset{bipoles/oscope/width=1.0}
3470 \foreach [count=\i] \wvf in {ramps, sin, square, triangle, lissajous, zero, none} {
3471 \ctikzset{bipoles/oscope/waveform=\wvf}
3472 \draw ({2*\i},0) node[oscopeshape]{};
3473 }
3474 \end{circuitikz}
3475 \end{ctikzExample}
3476
3477 If you want more or different shapes, you can define your owns, but you have to use low-level \texttt{pgf} commands (see part IX, \href{https://tikz.dev/base}{``The Basic Layer''}, in the PGF/\TikZ{} manual). The code is executed into a \verb|\pgfscope| \dots \verb|\endpgfscope| environment, and it must use the path built with a \verb|\pgfusepath|. The coordinates have been scaled so that the external box of the scope is a rectangle between \texttt{(-1cm, -1cm)} and \texttt{(1cm, 1cm)}; the oscilloscope grid is fixed and painted between \texttt{(-0.75cm, -0.5cm)} and \texttt{(0,75cm, 0.5cm)}. If you stretch the scope with the \texttt{\dots width} or \texttt{\dots height} keys, the drawing will be stretched too.
3478
3479 \begin{ctikzExample}
3480 \ctikzset{%
3481 bipoles/oscope/waveform/mywave/.code={%
3482 \pgfsetcolor{red}
3483 \pgfpathmoveto{\pgfpoint{-.75cm}{-.5cm}}
3484 \pgfpathlineto{\pgfpoint{.75cm}{.5cm}}
3485 \pgfusepath{draw}
3486 \pgfsetcolor{green}
3487 \pgfpathmoveto{\pgfpoint{-.75cm}{.5cm}}
3488 \pgfpathlineto{\pgfpoint{.75cm}{-.5cm}}
3489 \pgfusepath{draw}
3490 }}
3491 \begin{circuitikz}
3492 \ctikzset{bipoles/oscope/waveform=mywave}
3493 \draw (0,0) node[oscopeshape]{};
3494 \end{circuitikz}
3495 \end{ctikzExample}
3496
3497
3498
3499 \subsubsection{Rotation-invariant elements}
3500 \label{sec:rotation-invariant-elements}
3501
3502 The \texttt{oscope} element will not rotate the ``graph'' shown with the component:
3503
3504 \begin{ctikzExample}
3505 \begin{circuitikz}
3506 \foreach \a in {0,45,...,350} {
3507 \draw (0,0) to[oscope] (\a:3);
3508 }
3509 \end{circuitikz}
3510 \end{ctikzExample}
3511
3512 The \texttt{rmeter}, \texttt{rmaterwa}, and \texttt{smeter} have the same behavior.
3513
3514 However, if you prefer that the \texttt{oscope}, \texttt{rmeter}, \texttt{smeter} and \texttt{rmeterwa} instruments rotate the text or the diagram,
3515 you can use the key or style \IndexKey{rotated instruments} (the default style is \IndexKey{straight instruments}).
3516
3517 \begin{ctikzExample}
3518 \begin{circuitikz}[scale=0.8, transform shape]
3519 \ctikzset{rotated instruments} % new default
3520 \draw (0,0) to[oscope] ++(0:3);
3521 \draw (0,0) to[oscope] ++(60:3);
3522 \draw (0,0) to[rmeter, t=A] ++(120:3);
3523 % local override
3524 \draw (0,0) to[rmeterwa, t=A, straight instruments] ++(180:3);
3525 \ctikzset{straight instruments} % back to default
3526 \draw (0,0) to[rmeterwa, t=A] ++(240:3);
3527 % local override
3528 \draw (0,0) to[smeter, t=A, rotated instruments] ++(300:3);
3529 \end{circuitikz}
3530 \end{ctikzExample}
3531
3532
3533
3534 \subsubsection{Instruments as node elements}
3535 \label{sec:instruments-as-node}
3536
3537 The node-style usage of the \texttt{oscope} is also interesting, using the additional \texttt{in 1} and \texttt{in 2} anchors; notice that in this case you can use the text content of the node to put labels above it.
3538 Moreover, you can change the size of the oscilloscope by changing \IndexKey{bipoles/oscope/width} and \IndexKey{bipoles/oscope/height} keys (which both default to 0.6).
3539
3540 \begin{ctikzExample}
3541 \begin{circuitikz}
3542 \draw (0,1)
3543 to[oscope=$C_1$, fill=green!20!gray, name=O1] ++(2,0);
3544 \path (O1.right)
3545 node[ground, scale=0.5, below right=4pt]{};
3546 \ctikzset{bipoles/oscope/width=1.0}
3547 \draw (1,-1)
3548 node[oscopeshape, fill=yellow!20!orange](O2){$C_2$};
3549 \draw (O2.in 2) to[short, *-] ++(0,-0.5) node[ground]{};
3550 \draw (O2.in 1) to[short, *-] ++(0,-0.5)
3551 -- ++(-1,0) node[currarrow, xscale=-1]{};
3552 \end{circuitikz}
3553 \end{ctikzExample}
3554
3555 \subsubsection{Measuring voltage and currents, multiple ways}
3556 \label{sec:measuring-voltage-and}
3557
3558 This is the classical (legacy) option, with the \texttt{voltmeter} and \texttt{ammeter}. The problem is that elements are intrinsically horizontal, so they look funny if put in vertically.
3559
3560 \begin{ctikzExample}
3561 \begin{circuitikz}
3562 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3563 to [ammeter] ++(0,-2) node[ground]{};
3564 \draw (1,0) to[voltmeter] ++(0,-2)
3565 node[ground]{};
3566 \end{circuitikz}
3567 \end{ctikzExample}
3568
3569 So the solution is often changing the structure to keep the meters in horizontal position.
3570
3571 \begin{ctikzExample}
3572 \begin{circuitikz}
3573 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3574 to [ammeter] ++(2,0) --
3575 ++(0,-1) node[ground]{};
3576 \draw (1,0) -- (1,1) to[voltmeter]
3577 ++(2,0) node[ground]{};
3578 \end{circuitikz}
3579 \end{ctikzExample}
3580
3581 Since version 0.9.0 you have more options for the measuring instruments. You can use the generic \texttt{rmeterwa} (round meter with arrow), to which you can specify the internal symbol with the option \texttt{t=...} (and is fillable).
3582
3583 \begin{ctikzExample}
3584 \begin{circuitikz}[american]
3585 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3586 to [rmeterwa, t=A, i=$i$] ++(0,-2) node[ground]{};
3587 \draw (1,0) to[rmeterwa, t=V, v=$v$] ++(0,-2)
3588 node[ground]{};
3589 \end{circuitikz}
3590 \end{ctikzExample}
3591
3592 This kind of component will keep the symbol horizontal, whatever the orientation:
3593
3594 \begin{ctikzExample}
3595 \begin{circuitikz}[american]
3596 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3597 to [rmeterwa, t=A, i=$i$] ++(2,0) --
3598 ++(0,-1) node[ground]{};
3599 \draw (1,0) -- (1,1) to[rmeterwa, t=V, v^=$v$]
3600 ++(2,0) node[ground]{};
3601 \end{circuitikz}
3602 \end{ctikzExample}
3603
3604 The plain \texttt{rmeter} is the same, without the measuring arrow:
3605
3606 \begin{ctikzExample}
3607 \begin{circuitikz}[american]
3608 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3609 to [rmeter, t=A, i=$i$] ++(0,-2) node[ground]{};
3610 \draw (1,0) to[rmeter, t=V, v=$v$] ++(0,-2)
3611 node[ground]{};
3612 \end{circuitikz}
3613 \end{ctikzExample}
3614
3615 If you prefer it, you have the option to use square meters, in order to have more visual difference from generators:
3616
3617 \begin{ctikzExample}
3618 \begin{circuitikz}[american]
3619 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3620 to [smeter, t=A, i=$i$] ++(0,-2) node[ground]{};
3621 \draw (1,0) to[smeter, t=V, v=$v$] ++(0,-2)
3622 node[ground]{};
3623 \end{circuitikz}
3624 \end{ctikzExample}
3625
3626 Another possibility is to use QUCS\footnote{QUCS is an open source circuit simulator: \url{http://qucs.sourceforge.net/}}-style probes, which have the nice property of explicitly showing the type of connection (in series or parallel) of the meter:
3627
3628 \begin{ctikzExample}
3629 \begin{circuitikz}[american]
3630 \draw (0,0) -- ++(1,0) to[R] ++(2,0)
3631 to [qiprobe, l=$i$] ++(0,-2) node[ground]{};
3632 \draw (1,0) to[qvprobe, l=$v$] ++(0,-2)
3633 node[ground]{};
3634 \end{circuitikz}
3635 \end{ctikzExample}
3636
3637 If you want to explicitly show a power measurement, you can use the power probe \texttt{qpprobe} and using the additional anchors \texttt{v+} and \texttt{v-} :
3638
3639 \begin{ctikzExample}
3640 \begin{circuitikz}[american]
3641 \draw (0,0) to[short,-*] ++(1,0) coordinate(b)
3642 to[R] ++(2,0) to [qpprobe, l=$i$, a=$v$, name=P]
3643 ++(0,-2.5) node[ground](GND){};
3644 \draw (P.v-) -| ++(-0.5,-1) coordinate(a)
3645 to [short, -*] (a-|GND);
3646 \draw (P.v+) -| (b);
3647 \end{circuitikz}
3648 \end{ctikzExample}
3649
3650 The final possibility is to use oscilloscopes. For example:
3651
3652 \begin{ctikzExample}
3653 \begin{circuitikz}[american]
3654 \draw (0,0) -- ++(1,0) to[R] ++(3,0)
3655 to [iloop, mirror, name=I] ++(0,-2)
3656 node[ground] (GND){};
3657 \draw (1,0) to[oscope, v=$v$] ++(0,-2)
3658 node[ground]{};
3659 \draw (I.i) -- ++(-0.5,0) node[oscopeshape, anchor=right, name=O]{};
3660 \draw (O.south) -- (O.south |- GND) node[ground]{};
3661 \end{circuitikz}
3662 \end{ctikzExample}
3663
3664 Or, if you want a more physical structure for the measurement setup:
3665
3666 \begin{ctikzExample}[varwidth=true, pos=b]
3667 \begin{circuitikz}[american]
3668 \draw (0,0) -- ++(1,0) to[R] ++(3,0) to [iloop2, name=I] ++(0,-2)
3669 node[ground] (GND){};
3670 \ctikzset{bipoles/oscope/width=1.6}\ctikzset{bipoles/oscope/height=1.2}
3671 \node [oscopeshape, fill=green!10](O) at (6,2){};
3672 \node [bnc, xscale=-1, anchor=zero](bnc1) at (O.in 1){};
3673 \node [bnc, , anchor=zero, rotate=-90](bnc2) at (O.in 2){};
3674 \draw [-latexslim] (bnc1.hot) -| (1,0);
3675 \draw (bnc2.hot) |- (I.i+);
3676 \draw (I.i-) node[ground, scale=0.5]{};
3677 \end{circuitikz}
3678 \end{ctikzExample}
3679
3680
3681 \subsection{Mechanical Analogy}
3682 \label{sec:mechanical-analogy}
3683 \begin{groupdesc}
3684 \circuitdescbip*{damper}{Mechanical Damping}{}
3685 \circuitdescbip*{inerter}{Mechanical Inerter}{}
3686 \circuitdescbip{spring}{Mechanical Stiffness}{}
3687 \circuitdescbip*{viscoe}{Mechanical viscoelastic element\footnotemark}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
3688 \footnotetext{Suggested by @Alex in \url{https://tex.stackexchange.com/q/484268/38080}}
3689 \circuitdescbip*{mass}{Mechanical Mass}{}
3690 \end{groupdesc}
3691
3692 \subsubsection{Mechanical elements customizations}\label{sec:tweak-mechanicals}
3693
3694 You can change the scale of all the mechanical elements by setting the key \IndexKey{mechanicals/scale} to something different from the default \texttt{1.0}.
3695
3696 \subsection{Miscellaneous bipoles and symbols}
3697 \label{sec:miscellaneous-bipoles-and}
3698
3699 Here you'll find components that do not fit well in any category, or span several ones.
3700
3701 \subsubsection{Miscellaneous bipoles}
3702 \label{sec:miscellaneous-bipoles}
3703
3704 Here you'll find bipoles that are not easily grouped in the categories above.
3705
3706 \begin{groupdesc}
3707 \circuitdescbip{thermocouple}{Thermocouple}{}
3708 \circuitdescbip*{fuse}{Fuse}{}
3709 \circuitdescbip*{afuse}{Asymmetric fuse}{asymmetric fuse}
3710 \circuitdescbip{wfuse}{``wiggly'' fuse}{wiggly fuse}()[left/110/0.2, right/70/0.2]
3711 \circuitdescbip*{relais}{Relais\footnotemark}{}
3712 \footnotetext{Contributed by \href{https://github.com/circuitikz/circuitikz/pull/795}{Jakob Leide}}
3713 \circuitdescbip{squid}{Squid}{}
3714 \circuitdescbip{barrier}{Barrier}{}
3715 \circuitdescbip{openbarrier}{Open barrier}{}
3716 \end{groupdesc}
3717
3718 You can tune how big the gap in the \texttt{openbarrier} is by setting \IndexKey{bipole/openbarrier/gap} (default value \texttt{1} meaning full width).
3719 The default width \IndexKey{bipole/openbarrier/width} is \texttt{0.21}, while \IndexKey{bipole/barrier/width} is \texttt{0}.
3720 These settings ensure minimal width without drawing any wire when the components' node shapes are used.
3721
3722 \begin{groupdesc}
3723 \circuitdescbip*{european gas filled surge arrester}{European gas filled surge arrester}{}
3724 \circuitdescbip*{american gas filled surge arrester}{American gas filled surge arrester}{}
3725 \end{groupdesc}
3726
3727 \begin{framed}
3728 If (default behaviour) \IndexKey{europeangfsurgearrester} option is active (or the style \IndexKey{european gas filled surge arrester} is used), the shorthands \texttt{gas filled surge arrester} and \texttt{gf surge arrester} are equivalent to the european version of the component.
3729
3730 If otherwise \IndexKey{americangfsurgearrester} option is active (or the style \IndexKey{american gas filled surge arrester} is used), the shorthands the shorthands \texttt{gas filled surge arrester} and \texttt{gf surge arrester} are equivalent to the american version of the component.
3731 \end{framed}
3732
3733 \begin{groupdesc}
3734 \circuitdescbip*{lamp}{Lamp}{}
3735 \circuitdescbip*{bulb}{Bulb}{}
3736 \circuitdescbip*{wbulb}{Wiggly bulb shape\footnotemark}{}
3737 \footnotetext{This lamp is drawn in the style of the textbook Physics for Scientists and Engineers: A Strategic Approach by Randall D. Knight, suggested by \href{https://tex.stackexchange.com/questions/735367/special-bulbs-in-circuitikz-from-randall-textbook}{Sebastiano on TeX.SX}}
3738 \circuitdescbip*{neonlampcc}{Neon lamp\footnotemark\ (double cathode style)}{}
3739 \footnotetext{The neon lamps have been added in \texttt{v1.6.9} thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/793}{user bogger33 on GitHub}.}
3740 \circuitdescbip*{neonlampac}{Neon lamp (anode and cathode style)}{}
3741 \circuitdescbip*{sparkgap}{Spark gap\footnotemark (unenclosed)}{}
3742 \footnotetext{The spark gap has been added in \texttt{v1.6.9} thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/800}{user bogger33 on GitHub}.}
3743 \circuitdescbip*[sparkgap]{sparkgap, sparkgap/circle}{Spark gap}{}
3744 \circuitdescbip*[sparkgap]{sparkgap, sparkgap/dot, sparkgap/circle}{Spark gap (gas filled)}{}
3745 \circuitdescbip*{loudspeaker}{loudspeaker}{}( north/90/0.4, ne/45/0.4, east/0/0.4, se/-45/0.4, south/-90/0.4, sw/-135/0.4, west/180/0.4, nw/135/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
3746 \circuitdescbip*{mic}{mic}{}( north/90/0.4, east/0/0.4, south/-90/0.4, west/180/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
3747 \circuitdescbip*{tlmic}{tail-less mic\footnotemark}{}( north/90/0.4, east/0/0.4, south/-90/0.4, west/180/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
3748 \footnotetext{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/689}{Dr. Matthias Jung}.}
3749 \circuitdescbip*{buzzer}{Buzzer\footnotemark}{}(left/135/0.6, right/45/0.6)
3750 \circuitdescbip*{rbuzzer}{Reversed buzzer}{}(left/135/0.6, right/45/0.6)
3751 \footnotetext{Buzzers were suggested by \href{https://tex.stackexchange.com/questions/640501/buzzer-symbol-in-circuitikz}{user Michael.H on TeX.SX}}
3752 \end{groupdesc}
3753
3754 You can use microphones and loudspeakers with \texttt{waves} (see section~\ref{sec:RF}) too:
3755
3756 \begin{ctikzExample}
3757 \begin{circuitikz}
3758 \draw (0,0) to[mic, name=M] ++(0,2)
3759 to[amp, t=$A$] ++(2,0)
3760 to[loudspeaker, name=L] ++(0,-2)
3761 to[short, -*] (0,0) node[ground]{};
3762 \node [waves, scale=0.7, left=5pt]
3763 at(M.north) {};
3764 \node [waves, scale=0.7, right]
3765 at(L.north) {};
3766 \end{circuitikz}
3767 \end{ctikzExample}
3768
3769
3770 You have two types of microphones; \texttt{mic} has protruding connection and \texttt{tlmic} (for tail-less microphone) is inline. This last one is handy for use as a separate shape (which is named \texttt{tlmicshape}). You can change the (relative) thickness of the straight bar using the key \IndexKey{bipoles/mic/bar thickness} (default \texttt{1}).
3771
3772 \begin{ctikzExample}
3773 \begin{circuitikz}[]
3774 \draw (0,2) to[mic, name=M] ++(2,0) to[tlmic] ++(2,0);
3775 \node [color=red, tlmicshape](T) at (M.center) {};
3776 \ctikzset{bipoles/mic/bar thickness=3}
3777 \draw (0,0) to[mic] ++(2,0) to[tlmic] ++(2,0);
3778 \end{circuitikz}
3779 \end{ctikzExample}
3780
3781 \subsubsection{Miscellaneous element customization}\label{sec:tweak-misc}
3782
3783 You can change the scale of all the miscellaneous elements by setting the key \IndexKey{misc/scale} to something different from the default \texttt{1.0}; relative thickness can be controlled with \IndexKey{misc/thickness}.
3784
3785 \paragraph{Wiggly fuses.} Wiggly fuses can have (or not have) poles; you can switch between the two forms by setting to \texttt{true} or \texttt{false} (default \texttt{true}) the key \IndexKey{bipoles/wfuse/dots}; if they have poles, you can choose any of the pole shapes with the key \IndexKey{bipoles/wfuse/shape}.
3786 \label{par:wiggly-fuses}
3787 The pole nodes are named \texttt{-left} and \texttt{-right} so that you can access their borders.
3788
3789 \begin{ctikzExample}
3790 \begin{circuitikz}
3791 \draw (0,3) to[wfuse, bipoles/wfuse/dots=false] ++(2,0);
3792 \draw (0,2) to[wfuse, name=A] ++(2,0);
3793 \ctikzset{bipoles/wfuse/shape=osquarepole}
3794 \draw (0,1) to[wfuse, name=B] ++(2,0);
3795 \draw [red, densely dashed]
3796 (A-left.-135) to[bend right] (B-left.135);
3797 \ctikzset{bipoles/wfuse/shape=circ}
3798 \draw (0,0) to[wfuse, name=B] ++(2,0);
3799 \end{circuitikz}
3800 \end{ctikzExample}
3801
3802 \paragraph{Neon lamps.} Neon lamp ``dot'' size is the same as the size of poles (\texttt{circ} and \texttt{ocirc}), and they can be changed locally:
3803 \label{par:neon-lamps}
3804 \begin{ctikzExample}
3805 \begin{tikzpicture}
3806 \draw (0,0) to[neonlampcc, nodes width=0.03] ++(2,0)
3807 to[neonlampac, misc/thickness=3] ++(2,0);
3808 \end{tikzpicture}
3809 \end{ctikzExample}
3810
3811 \paragraph{Spark gap.} The \texttt{sparkgap} component is similar to the (American) surge arrester, but it's more configurable; it will render bare (unenclosed) by default, but you can add a (fillable) enclosure with the key \IndexKey{sparkgap/circle} and a dot with \IndexKey{sparkgap/dot} (they are boolean keys, false by default).
3812 \label{par:spark-gap}
3813 Moreover, the arrows are configurable like other arrows in the package (see~\ref{sec:tunablearrows}) using the \IndexKey{sparkgap end arrow} key (default \texttt{Triangle[scale=2]}). The gap is tunable with \IndexKey{sparkgap/gap} (default \texttt{0.05}).
3814 \begin{ctikzExample}
3815 \begin{tikzpicture}
3816 \draw (0,2) to[sparkgap, l=gap\textsubscript{1}] ++(2,0)
3817 to[sparkgap, sparkgap/circle,
3818 sparkgap/dot, l=S2] ++(2,0);
3819 \ctikzset{sparkgap end arrow={Kite[scale=1.5]}}
3820 \draw (0,0) to[sparkgap, l=S3] ++(2,0)
3821 to[sparkgap, l=S4, sparkgap/circle,
3822 sparkgap/gap=0.15] ++(2,0);
3823 \end{tikzpicture}
3824 \end{ctikzExample}
3825 As in neon lamps, the dot (if activated by the key \texttt{sparkgap/dot}) follows the size of poles and can be changed locally.
3826
3827 \subsubsection{Miscellaneous symbols}
3828 \label{sec:miscellaneous-symbols}
3829
3830 \begin{groupdesc}
3831 \circuitdesc{dc symbol}{dc symbol}{text}(left/135/0.2, right/45/0.2, center/-45/0.2)
3832 \circuitdesc{ac symbol}{ac symbol}{text}(left/135/0.2, right/45/0.2, center/-45/0.2)
3833 \end{groupdesc}
3834
3835 The symbols for dc or ac voltages or currents can be useful to specify the waveforms in parts of the circuit, or to add to existing symbols.
3836
3837 \begin{ctikzExample}
3838 \begin{circuitikz}[european]
3839 \draw (0,1.5) to[generic, name=a] ++(2,0);
3840 \node [ac symbol] at (a.center) {};
3841 \draw (0,0) node[dc symbol]{\qty{4}{V}};
3842 \draw (1,0) node[dc symbol, dc symbol segments=1]{\qty{1}{\uA}};
3843 \draw (2,0) node[dc symbol, dc symbol segments=4]{$V_p$};
3844 \end{circuitikz}
3845 \end{ctikzExample}
3846
3847 \subsubsection{Customization of ac/dc symbols.}
3848 \label{sec:customization-of-ac}
3849
3850 You can change the width and height of the symbols with \IndexKey{dc symbol/width}, \IndexKey{dc symbol/height}, \IndexKey{ac symbol/width}, \IndexKey{ac symbol/height} (at the \texttt{circuitikz} level, the default is \texttt{0.3} for the widths and \texttt{0.15} for both symbols).
3851 The node text is positioned above the symbol, at a distance controlled by the keys \IndexKey{dc symbol/text offset} (and the similar \texttt{ac\dots}; default \texttt{6pt}).
3852
3853 As shown in the example above, the \texttt{dc symbols} has an additional options. By default the lower line of the symbol has two segments, but you can change this with the \texttt{circuitikz} key \IndexKey{dc symbol/segments} (with also the direct key, at \TikZ{} level, \IndexKey{dc symbol segments} (default \texttt{2})) with any value greater than 0.
3854
3855 Additionally, you can change the relative thickness of the bottom line with the key \texttt{dc symbols/relative thickness} (default \texttt{1}).
3856
3857 \begin{ctikzExample}
3858 \begin{tikzpicture}[scale=2, transform shape]
3859 \tikzset{my dc symbol/.style={
3860 dc symbol,
3861 circuitikz/misc/thickness=4,
3862 circuitikz/dc symbol/height=0.1,
3863 circuitikz/dc symbol/width=0.2,
3864 circuitikz/dc symbol/relative thickness=.5,
3865 circuitikz/dc symbol/segments=3
3866 }}
3867 \node (A) at (0,0) {A}; \node (V) at (1,0) {V};
3868 % standard and customized
3869 \node [dc symbol, above,
3870 circuitikz/misc/thickness=4] at (A.north) {};
3871 \node [my dc symbol, above] at (V.north) {};
3872 \end{tikzpicture}
3873 \end{ctikzExample}
3874
3875 \subsection{Multiple wires (buses)}
3876 \label{sec:multiple-wires-buses}
3877
3878 These are simple drawings to indicate multiple wires.
3879 \begin{groupdesc}
3880 \circuitdescbip{multiwire}{Single line multiple wires}{multiwire}
3881 \circuitdescbip{bmultiwire}{Double line multiple wires}{bmultiwire}
3882 \circuitdescbip{tmultiwire}{Triple line multiple wires\footnotemark}{tmultiwire}
3883 \footnotetext{added by \texttt{olfline}}
3884 \end{groupdesc}
3885
3886 \begin{ctikzExample}
3887 \begin{circuitikz}
3888 \draw (0,0) to[multiwire=4] ++(1,0);
3889 \draw (0,-2) to[bmultiwire=6] ++(1,0);
3890 \draw (0,-4) to[tmultiwire=3] ++(1,0);
3891 \end{circuitikz}
3892 \end{ctikzExample}
3893
3894
3895
3896
3897 \subsection{Crossings}
3898 \label{sec:crossings}
3899
3900 Path style:
3901 \begin{groupdesc}
3902 \circuitdescbip{crossing}{Jumper style non-contact crossing}{xing}
3903 \end{groupdesc}
3904
3905 Node style:
3906 \begin{groupdesc}
3907 \circuitdesc{jump crossing}{Jumper-style crossing node}{}
3908 \circuitdesc{plain crossing}{Plain style crossing node}{}
3909 \end{groupdesc}
3910
3911 All circuit-drawing standards agree that to show a crossing without electric contact, a simple crossing of the wires suffices; the electrical contact must be explicitly marked with a filled dot.
3912
3913 \begin{ctikzExample}
3914 \begin{circuitikz}[]
3915 \draw(1,-1) to[short] (1,1)
3916 (0,0) to[short] (2,0);
3917 \draw(4,-1) to[short] (4,1)
3918 (3,0) to[short] (5,0)
3919 (4,0) node[circ]{};
3920 \end{circuitikz}
3921 \end{ctikzExample}
3922
3923 However, sometimes it is advisable to mark the non-contact situation more explicitly. To this end, you can use a path-style component called \texttt{crossing}:
3924
3925 \begin{ctikzExample}
3926 \begin{circuitikz}[]
3927 \draw(1,-1) to[short] (1,1) (0,0) to[crossing] (2,0);
3928 \draw(4,-1) to[short] (4,1) (3,0) to[short] (5,0)
3929 (4,0) node[circ]{};
3930 \end{circuitikz}
3931 \end{ctikzExample}
3932
3933 That should suffice most of the time; the only problem is that the crossing jumper will be put in the center of the subpath where the \texttt{to[crossing]} is issued, so sometimes a bit of trial and error is needed to position it.
3934
3935 For a more powerful (and elegant) way you can use the crossing nodes:
3936
3937 \begin{ctikzExample}
3938 \begin{circuitikz}[]
3939 \node at (1,1)[jump crossing](X){};
3940 \draw (X.west) -- ++(-1,0);
3941 \draw (X.east) to[R] ++(2,0);
3942 \draw (X.north) node[vcc]{};
3943 \draw (X.south) to[C] ++(0,-1.5);
3944 \end{circuitikz}
3945 \end{ctikzExample}
3946
3947 Notice that the \texttt{plain crossing} and the \texttt{jump crossing} have a small gap in the straight wire, to enhance the effect of crossing (as a kind of shadow).
3948
3949 \subsubsection{Crossing customization}
3950 \label{sec:crossing-customization}
3951
3952 The size of the crossing elements can be changed with the key \IndexKey{bipoles/crossing/size} (default 0.2).
3953
3954 While the horizontal line will be drawn with the current path values, you can change the style of the vertical line\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/704}{user lkjell on GitHub}, implemented in \texttt{v1.6.2}.} in a similar way to the one used for transistor's bodydiodes, by setting keys with the \verb!\ctikzset! command under the \IndexKey{crossing vertical} hierarchy. The available keys are:
3955
3956 \begin{center}
3957 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{0.5\linewidth}}
3958 \toprule
3959 parameter & default & description \\
3960 \midrule
3961 relative thickness & 1.0 & multiply the default thickness (which is the same of the \texttt{choke} component).\\
3962 color & default & stroke color: \texttt{default} is the same as the component. \\
3963 dash & default & dash pattern: \texttt{default} means not to change the setting for the component; \texttt{none} means unbroken line; every other input is a dash pattern.\footnotemark \\
3964 \bottomrule
3965 \end{tabular}
3966 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
3967 \end{center}
3968
3969 \begin{ctikzExample}
3970 \begin{circuitikz}[every node/.append style={scale=2}]
3971 \draw (0,2) node[jump crossing](A){};
3972 \begin{scope}
3973 \ctikzset{crossing vertical/.cd, color=red, dash={{2pt}{1pt}}}
3974 \draw (0,1) node[jump crossing](B){};
3975 \end{scope}
3976 \ctikzset{crossing vertical/dash=none}
3977 \draw[densely dotted, blue] (0,0) node[plain crossing](B){};
3978 \end{circuitikz}
3979 \end{ctikzExample}
3980
3981 \subsection{Arrows (fake and real)}\label{sec:arrows}
3982
3983 The main arrow shapes in \Circuitikz{} are really shapes, used as pseudo-arrows in lot of places in the packages (for transistors, flows, currents, and so on). The first three arrows are magnified by a factor~3 in the boxes below; for the \texttt{trarrow}, the anchor \texttt{tip} is exactly on the tip and \texttt{btip} is slightly receded.
3984
3985 \begin{groupdesc}
3986 \circuitdesc[3]{currarrow}{Arrow for current and voltage}{}(center/45/0.2,tip/-45/0.2)
3987 \circuitdesc[3]{inputarrow}{Arrow that is anchored at its tip, useful for block diagrams.}{}(center/0/0.2)
3988 \circuitdesc[3]{trarrow}{Arrow the same size of \texttt{currarrow} but only filled.}{}(center/90/0.2, tip/0/0.2, btip/-90/0.2)
3989 \circuitdesc{flowarrow}{Arrow used for the flows}{$I_p$}(south/-90/0.2, east/0/0.2, west/180/0.2, center/45/0.2)
3990 \end{groupdesc}
3991
3992 \subsubsection{Arrows size}\label{sec:currarrow-size}
3993
3994 You can use the parameter \IndexKey{current arrow scale} to change the size of the arrows in various components and indicators; the normal value is 16, higher numbers give smaller arrows and so on. You need to use \texttt{circuitikz/current arrow scale} if you use it into a node.
3995
3996 \begin{ctikzExample}
3997 \begin{circuitikz}
3998 \draw (0,0) to[R, i=f] ++(2,0) node[npn, anchor=B]{};
3999 \draw (0,-2) to[R, f=f, current arrow scale=8] ++(2,0)
4000 node[pnp, anchor=B, circuitikz/current arrow scale=8]{};
4001 \draw (0,-4) to[R, f=f, current arrow scale=24] ++(2,0)
4002 node[nigbt, anchor=B]{};
4003 \end{circuitikz}
4004 \end{ctikzExample}
4005
4006 Moreover, you have the arrow tip \IndexKey{latexslim} which is an arrow similar to the old (in deprecated \texttt{arrows} library) \texttt{latex'} element:
4007
4008 \begin{ctikzExample}
4009 \begin{circuitikz}[american,]
4010 \draw [latexslim-latexslim] (0,0) -- (1,0);
4011 \end{circuitikz}
4012 \end{ctikzExample}
4013
4014 \subsubsection{Generic Tunable Arrows}
4015 \label{sec:generic-tunable-arrows}
4016
4017 The basic passive components (resistors, capacitors and inductors) come with a ``tunable version'' (see for example~\ref{sec:tunablearrows}) that conveys the information that their value is adjustable. For generic components you can obtain a similar effect with the extra macro \verb|\ctikztunablearrow|, introduced in version \texttt{1.4.1}. The macro should be called as:
4018 \begin{quote}
4019 \ttfamily
4020 \textbackslash ctikztunablearrow[\emph{extra options}]\{\emph{thickness}\}\{\emph{length}\}\{\emph{angle}\}\{\emph{name}\}
4021 \end{quote}
4022 where \emph{extra options} is an optional argument with generic \TikZ{} keys, \emph{thickness} is the relative thickness (referred to the current line width when the macro is invoked), \emph{length} is the length of the arrow with respect to the diagonal size of the component, \emph{angle} is the inclination with respect to the normal direction of the component\footnote{which is the left-to-right direction of the component when shown in the component box in this manual.}, and finally \emph{name} is the reference name of the bipole or node.
4023
4024 The arrows are the ones set with the keys \IndexKey{tunable start arrow} and \IndexKey{tunable end arrow} (to maintain coherency across the circuit), but you can override them in the \emph{extra options} argument as shown in the following example.
4025
4026 \begin{ctikzExample}
4027 \begin{circuitikz}
4028 \draw (0,0) node[tlground]{} to[sV, name=A] ++(0,3)
4029 node[op amp, anchor=+](B){};
4030 \ctikztunablearrow{1}{1.2}{30}{A}
4031 \ctikzset{tunable start arrow={Bar},
4032 tunable end arrow={Stealth}}
4033 \ctikztunablearrow[color=green,
4034 {Latex[reversed]}-Circle]{1}{1.2}{90}{A}
4035 \ctikztunablearrow[color=blue, densely dashed]{1}{1.2}{-30}{A}
4036 \begin{scope}[transparency group, opacity=0.5]
4037 \ctikztunablearrow[red, shorten <=3mm]{6}{0.8}{110}{B}
4038 \end{scope}
4039 \end{circuitikz}
4040 \end{ctikzExample}
4041
4042 Notice also the need to force a transparency group if you want a semitransparent arrow.
4043
4044 \subsubsection{Arrow tips}\label{sec:arrow-tips}
4045
4046 In addition to the pseudo-arrows, \Circuitikz{} also adds a couple of ``real'' arrow tips.
4047 The package automatically loads the \texttt{arrows.meta} \TikZ{} library but \emph{not} the deprecated \texttt{arrows} library; in the first versions of the package it used quite a lot the \texttt{latex'} tip, which is not available anymore. To maintain the backward compatibility, the `latexslim` tip has been added, and used by default in several components. This is an old-style arrow tip, with no customization possible.
4048
4049 The other tip is \IndexKey{Jack Tap}\footnote{Added after a suggestion from \href{https://github.com/circuitikz/circuitikz/issues/806}{Anisio Rogerio Braga} on GitHub}, which is mainly used to build jack connectors (see section~\ref{sec:jacks}). This is a new-style arrow tip, and accepts the parameter \texttt{length} (default \texttt{0.3 cm}), \texttt{width} (default \texttt{0.15 cm}), and the boolean \texttt{swap}.
4050
4051
4052 \begin{ctikzExample}
4053 \begin{circuitikz}
4054 \draw (0,.25) (0,0) edge[-latexslim] ++(1,0)
4055 ++(0, -0.5) edge[-{Jack Tap[swap]}] ++(1,0)
4056 ++(0, -0.5) edge[-Jack Tap] ++(1,0)
4057 ++(0, -0.5) edge[-{Jack Tap[fill=cyan]}] ++(1,0)
4058 ++(0, -0.5) edge[-{Jack Tap[width=.3cm,fill]}]++(1,0)
4059 ++(0, -0.5) edge[-{Jack Tap[width=.3cm,line join=round,
4060 line cap=round]}, thick] ++(1,0)
4061 ++(0, -0.5) edge[^-^f] ++(1,0)
4062 ++(0, -0.5) edge[vf-v] ++(1,0);
4063 \end{circuitikz}
4064 \end{ctikzExample}
4065 You can also have a filled version, by adding the key \texttt{fill} (without arguments\footnote{This usage of the \texttt{fill} key in arrow tips will be added to \TikZ{} in version \texttt{3.1.11}, see \href{https://github.com/pgf-tikz/pgf/pull/1352}{this PR by Henri Menke}; \Circuitikz{} will add it to older versions.}) or \texttt{fill=color} if you want a color different from the stroke ones, and they accept the \texttt{line join} and \texttt{line cap} as most of the standard \TikZ{} arrows.
4066 As you can see, the normal and swapped \texttt{Jack Tap} tips have the shorthands \texttt{v} and \verb|^| (and \texttt{vf} and \verb|^f| for their filled counterparts). Notice that the tips are automatically reversed when they are at the \emph{start} of the path.
4067
4068 \subsection{Terminal shapes}\label{sec:terminals}
4069
4070 These are the so-called ``bipole nodes'' shapes, or poles (see section~\ref{sec:bipole-nodes}). These nodes are always filled; the ``open'' versions (starting with an \texttt{o}) are by default filled with the color specified by the key \IndexKey{open nodes fill} (by default \texttt{white}), but you can override locally it with the \texttt{fill} parameter.
4071
4072 \begin{groupdesc}
4073 \circuitdesc{circ}{Connected terminal}{}
4074 \circuitdesc{ocirc}{Unconnected terminal}{}
4075 \circuitdesc{diamondpole}{Diamond-square terminal}{}
4076 \circuitdesc{odiamondpole}{Open diamond-square terminal}{}
4077 \circuitdesc{squarepole}{Square-shape terminal}{}
4078 \circuitdesc{osquarepole}{Open square-shape terminal}{}
4079 \end{groupdesc}
4080
4081 This is not a pole, but it's used to "fill" nasty corners (look closer, and see ~\ref{sec:line-joins}).
4082
4083 \begin{groupdesc}
4084 \circuitdesc{rectjoinfill}{Filling square with line width size}{}
4085 \end{groupdesc}
4086
4087 Since version 0.9.0, ``bipole nodes'' shapes have all the standard geographical anchors, so you can do things like these:
4088
4089 \begin{ctikzExample}
4090 \begin{circuitikz}[american,]
4091 \draw (0,-1) node[draw](R){R};
4092 \draw (R.east) node[ocirc, right]{};
4093 \end{circuitikz}
4094 \end{ctikzExample}
4095
4096 The size of the poles is controlled by the key \IndexKey{nodes width} (default \texttt{0.04}, relative to the basic length).
4097 Be sure to see section~\ref{sec:bipole-nodes} for more usage and configurability.
4098
4099 \subsection{Connectors}\label{sec:connectors}
4100
4101 Connectors have a class by themselves (\IndexKey[connectors/scale]{connectors}), so you can use the \texttt{scale}, \texttt{fill} and \texttt{thickness} properties as usual.
4102
4103 \subsubsection{BNC connector/terminal}
4104 \label{sec:bnc-connector-terminal}
4105
4106 \begin{groupdesc}
4107 \circuitdesc*{bnc}{BNC connector}{}(left/135/0.6, right/45/0.6, center/-45/0.6, hot/0/0.6, zero/-135/0.6, shield/-90/0.4)
4108 \end{groupdesc}
4109 The BNC connector is defined so that you can easily connect it as input or output (but remember that you need to flip the text if you flip the component):
4110
4111 \begin{ctikzExample}
4112 \begin{circuitikz}
4113 \draw (0,0)
4114 node[bnc](B1){$v_i$} to[R=\SI{50}{\ohm}] ++(3,0)
4115 % you can also use \ctikzflipx{$v_o$} in LaTeX
4116 node[bnc, xscale=-1](B2){\scalebox{-1}[1]{$v_o$}};
4117 \node [ground] at (B1.shield) {};
4118 \node [eground] at (B2.shield){};
4119 \end{circuitikz}
4120 \end{ctikzExample}
4121
4122 It also has a \texttt{zero} anchor if you need to rotate it about its real center.
4123
4124 \begin{ctikzExample}
4125 \begin{circuitikz}
4126 \draw[thin, red] (0,0) -- ++(1,0) (0,-1) -- ++(1,0);
4127 \path (0,0) node[bnc]{} ++(1,0) node[bnc, rotate=-90]{};
4128 \path (0,-1) node[bnc, anchor=zero]{} ++(1,0) node[bnc, anchor=zero, rotate=-90]{};
4129 \end{circuitikz}
4130 \end{ctikzExample}
4131
4132 \subsubsection{IEC 60617 socket-plug connectors}
4133 \label{sec:iec-60617-socket}
4134
4135 Plug and socket connectors (modeled on the IEC60617 standard) are available\footnote{Since \texttt{v1.5.0}; thanks to Alexander Sauter for suggesting them and \href{https://github.com/circuitikz/circuitikz/issues/611}{helping in the design}.} both in path-style form and, with separated but matching shapes for plug and socket, in node-style. There are two differently oriented shapes for each type to ease the construction of ``split'' connections (see the examples below). \textbf{Notice} that the elements in the following table are scaled by a factor of 1.5, to better show the position of the anchors.
4136
4137 \begin{groupdesc}
4138 \ctikzset{connectors/scale=1.5}
4139 \circuitdescbip[iecconn]{iec connector}{IEC 60617 connector}{iecconn}(left/145/0.3, right/45/0.3, center/-90/0.4, plug center/90/0.4, socket center/-135/0.3)
4140 \circuitdesc{iecconnshape}{IEC 60617 connector}{\tiny text}(left/145/0.3, right/45/0.3, center/-90/0.2)
4141 \circuitdesc{iecsocketL}{IEC 60617 female socket, left side}{\tiny text}(left/145/0.3, right/45/0.3, center/-90/0.2, socket center/0/0.2)
4142 \circuitdesc{iecplugR}{IEC 60617 male plug, right side}{\tiny text}(left/145/0.3, right/45/0.3, center/-90/0.2, plug center/90/0.4)
4143 \circuitdesc{iecplugL}{IEC 60617 male plug, left side}{\tiny text}(left/145/0.3, right/45/0.3, center/-90/0.2, plug center/90/0.4)
4144 \circuitdesc{iecsocketR}{IEC 60617 female socket, right side}{\tiny text}(left/145/0.3, right/45/0.3, center/-90/0.4, socket center/-135/0.3)
4145 \end{groupdesc}
4146
4147 The \texttt{center} anchors (as well as the text position) of the split elements of the connectors are on the side of the component (similar to what happens with grounds and supply voltage arrows) to ease the most common use.
4148
4149 Also, the text for the plug nodes is raised to the same level of the text in the sockets, and it will ignore descendants, so that the two text lines up when the two components are put side by side.
4150
4151 The \texttt{plug center} anchor always point to the center of the rectangular plug shape, and the \texttt{socket center} to the center of the semicircle in the sockets.
4152
4153 \begin{ctikzExample}
4154 \begin{circuitikz}
4155 \draw (0,1) node[bnc]{} to[R] ++(2,0)
4156 to[iec connector] ++(1,0);
4157 \draw (0,0) node[bnc]{} to[R] ++(2,0)
4158 to[iec connector, invert] ++(1,0);
4159 \end{circuitikz}
4160 \end{ctikzExample}
4161
4162 Aligning ``disconnected'' plugs and sockets is reasonably easy:
4163
4164 \begin{ctikzExample}
4165 \begin{circuitikz}
4166 \draw (0,2) to[iec connector, name=C1] ++(2,0) coordinate(stop)
4167 (C1.nw) node[above left, inner xsep=0pt]{s1}
4168 (C1.ne) node[above right, inner xsep=0pt]{p1};
4169 \draw (0,1) coordinate(tmp) -- (tmp-|C1.left)
4170 node[iecsocketL](S2){s2};
4171 \draw (0,0) coordinate(tmp) (tmp-|C1.socket center)
4172 node[iecplugR](P3){p3} (P3.right) -- (tmp-|stop);
4173 \draw[red, dashed] ([yshift=1cm]C1.socket center) -- ++(0,-4);
4174 \end{circuitikz}
4175 \end{ctikzExample}
4176
4177 You can choose the best shape when rotating them, to simplify the positioning (shape rotates around the \texttt{center} anchor).
4178
4179 \begin{ctikzExample}
4180 \begin{circuitikz}
4181 \draw (0,0) -| ++(1,-1) node[iecsocketL, rotate=-90]{}
4182 (2,-1) -| ++(1,1) node[iecplugR, rotate=90]{};
4183 \end{circuitikz}
4184 \end{ctikzExample}
4185
4186 Choosing the proper left/right shape results in easily build ``mixed'' connectors; you can use the node text position properties to have lined-up labels, but remember that the text is outside the bounding box:
4187
4188 \begin{ctikzExample}
4189 \begin{circuitikz}[]
4190 \path (0,2); % for the bounding box, text is not accounted for
4191 \draw (0,1)--++(1,0) node[iecsocketL](s1){S1};
4192 \draw [color=red](s1.e) node[iecplugR](p1){P1} (p1.e)--++(1,0);
4193 \draw (0,0) -- ++(1,0) node[iecplugL](p2){P2};
4194 \draw [color=blue](p2.e) node[iecsocketR](s2){S2} (s2.e)--++(1,0);
4195 \end{circuitikz}
4196 \end{ctikzExample}
4197
4198 You can use the \texttt{plug center} anchor to add the IEC ``multiplier'':
4199
4200 \begin{ctikzExample}
4201 \begin{circuitikz}[]
4202 \draw (0,0) to[iec connector, connectors/scale=2, name=A,
4203 a={\small\ttfamily output bus}] ++(3,0);
4204 \draw (A.plug center) ++(-.2,-.4) -- ++(.4,.8) node[above]{8};
4205 \end{circuitikz}
4206 \end{ctikzExample}
4207
4208 \subsubsection{Jack connectors}\label{sec:jacks}
4209
4210 There are \emph{lots} of different jack connectors symbols --- see the \href{https://github.com/circuitikz/circuitikz/issues/806}{discussion here} for examples. So instead of creating a monster component, it has been decided to add elements to simplify the drawing of such connectors. The first (and for now only) such element is the \texttt{Jack Tap} arrow tip (see section~\ref{sec:arrow-tips}) with its shorthands \texttt{v} and \verb|^|.
4211
4212 For example, and audio jack can be drawn like this:
4213
4214 \begin{ctikzExample}[pos=t, varwidth=true]
4215 % drawing based on one by Anisio Rogerio Braga
4216 % https://github.com/circuitikz/circuitikz/issues/806
4217 \newcommand\dx{1.5}\newcommand\dy{1}
4218 \begin{circuitikz}
4219 \draw[-v] (0,\dy/3*4) to[short, o-] ++(\dx,0);
4220 \draw[-Triangle] (0,\dy) node[ocirc]{} -| ++(\dx/3,\dy/3);
4221 \draw[-Triangle] (0,\dy/3*2) node[ocirc]{} -| ++(\dx/3,-\dy/3);
4222 \draw[-^] (0,\dy/3) to[short, o-] ++(2*\dx/3,0);
4223 \draw (0,0.0) to[short, o-] ++(1.75*\dx,0) rectangle ++(0.2,4*\dy/3);
4224 \end{circuitikz}\qquad\qquad
4225 %---% audio jack with an inserted plug
4226 \begin{circuitikz}
4227 \draw[-v] (0,\dy/3*4) to[short, o-] ++(\dx,0.2);
4228 \draw[-Triangle] (0,\dy) node[ocirc]{} -| ++(\dx/3,\dy/3);
4229 \draw[-Triangle] (0,\dy/3*2) node[ocirc]{} -| ++(\dx/3,-\dy/3);
4230 \draw[-^] (0,\dy/3) to[short, o-] ++(2*\dx/3,-0.2);
4231 \draw (0,0.0) to[short, o-] ++(1.75*\dx,0) rectangle ++(0.2,4*\dy/3);
4232 \end{circuitikz}
4233 \end{ctikzExample}
4234
4235 \subsection{Block diagram components}
4236 \label{sec:block-diagram-components}
4237 \noindent Contributed by Stefan Erhardt.
4238
4239 \begin{groupdesc}
4240 \circuitdesc*{mixer}{mixer}{}( w/180/0.1,s/-90/0.1,e/0/0.1,n/90/0.1, center/-120/0.3, geocenter/-60/.3 )
4241 \circuitdesc*{mixer, boxed}{mixer, boxed}{}(right up/30/0.1, right down/-30/0.1, left up/150/0.1, left down/-150/0.1)
4242 \circuitdesc*{adder}{adder}{}( west/180/0.1,south/-90/0.1,east/0/0.1,north/90/0.1 )
4243 \circuitdesc*{oscillator}{oscillator}{}( w/180/0.1,s/-90/0.1,e/0/0.1,n/90/0.1, center/45/0.2, geocenter/-45/.3 )
4244 \circuitdesc*{circulator}{circulator}{}( left/180/0.1,down/-90/0.1,right/0/0.1, up/90/0.1 )
4245 \circuitdesc*{wilkinson}{wilkinson divider}{}( in/180/0.1, out2/45/0.1, out1/-45/0.1 )
4246 \circuitdesc*{splitter}{resistive splitter\footnotemark}{}( in/180/0.1, out2/45/0.1, out1/-45/0.1 )
4247 \footnotetext{added by \texttt{matthuszagh}}
4248 \circuitdesc*{genericsplitter}{generic splitter\footnotemark}{$\SI{-3}{\deci\bel}$}( in/180/0.1, out2/45/0.1, out1/-45/0.1 )
4249 \footnotetext{added by \texttt{frankplow}}
4250 \circuitdesc*{mzm}{Mach Zehnder Modulator\footnotemark}{}( in/180/0.1, mod/90/0.1, out/0/0.1)
4251 \footnotetext{added by \texttt{dl1chb}}
4252 \end{groupdesc}
4253
4254 \begin{groupdesc}
4255 \circuitdescbip*{twoport}{generic two port (use \texttt{t=\dots} to specify text)}{}(w/180/0.1,s/-90/0.1,e/0/0.1,n/90/0.1, center/-120/0.3)
4256 \circuitdescbip*{twoportsplit}{generic two port split (use \texttt{t1=\dots} and \texttt{t2=\dots} to specify text)}{}(right up/30/0.1, right down/-30/0.1, left up/150/0.1, left down/-150/0.1)
4257 \circuitdescbip*{vco}{vco}{}
4258 \circuitdescbip*{vco,box}{vco,box}{}(right up/30/0.1, right down/-30/0.1, left up/150/0.1, left down/-150/0.1)
4259 \circuitdescbip*{bandpass}{bandpass}{}
4260 \circuitdescbip*{bandstop}{bandstop}{}
4261 \circuitdescbip*{highpass}{highpass}{}
4262 \circuitdescbip*{lowpass}{lowpass}{}
4263 \circuitdescbip*{highpass2}{simplified highpass (with only 2 waves)}{}
4264 \circuitdescbip*{lowpass2}{simplified lowpass (with only 2 waves)}{}
4265 \circuitdescbip*{allpass}{allpass}{}
4266 \circuitdescbip*{vallpass}{variable allpass\footnotemark}{}
4267 \footnotetext{This block, as well as \texttt{bgenerator}, \texttt{cgenerator}, \texttt{qgenerator}, \texttt{ngenerator},
4268 \texttt{biast}, \texttt{sinetable}, \texttt{register}, \texttt{harmonics}, and the TV/Radio system blocks have been
4269 contributed by \href{https://github.com/circuitikz/circuitikz/pull/693}{Dr. Matthias Jung}.}
4270 \circuitdescbip*{bgenerator}{Block generator (use \texttt{t=\dots} to specify text)}{}
4271 \circuitdescbip*{qgenerator}{Crystal generator (use \texttt{t=\dots} to specify text)}{}
4272 \circuitdescbip*{cgenerator}{Clock generator}{}
4273 \circuitdescbip*{ngenerator}{Generic generator (use \texttt{t=\dots} to specify text)}{}
4274 \circuitdescbip*{adc}{A/D converter}{}
4275 \circuitdescbip*{dac}{D/A converter}{}
4276 \circuitdescbip*{dsp}{DSP}{}
4277 \circuitdescbip*{fft}{FFT}{}
4278 \circuitdescbip*{amp}{amplifier; use \texttt{t=\dots} to add a text}{}(up/90/0.2, down/-90/0.2)
4279 \circuitdescbip*{amp, boxed}{amplifier, boxed; use \texttt{t=\dots} to add a text}{}(up/90/0.2, down/-90/0.2)
4280 \circuitdescbip*{iamp}{instrumentation amplifier; use \texttt{t=\dots} to add a text}{}(up/90/0.2, down/-90/0.2)
4281 \circuitdescbip*{iamp, boxed}{instrumentation amplifier, boxed; use \texttt{t=\dots} to add a text}{}(up/90/0.2, down/-90/0.2)
4282 \circuitdescbip*{vamp}{VGA (variable gain amplifier)}{}
4283 \circuitdescbip*{vamp, boxed}{VGA, boxed}{}
4284 \circuitdescbip*{piattenuator}{$\pi$ attenuator}{}
4285 \circuitdescbip*{vpiattenuator}{var. $\pi$ attenuator}{}
4286 \circuitdescbip*{tattenuator}{T attenuator}{}
4287 \circuitdescbip*{vtattenuator}{var.\ T attenuator}{}
4288 \circuitdescbip*{phaseshifter}{phase shifter}{}
4289 \circuitdescbip*{vphaseshifter}{var.\ phase shifter}{}
4290 \circuitdescbip*{biast}{BIAS-T circuit as block}{}
4291 \circuitdescbip*{sinetable}{Sine lookup table}{}
4292 \circuitdescbip*{register}{Register (use \texttt{t=\dots} to specify text)}{}(clk/180/0.2)
4293 \circuitdescbip*{detector}{detector}{}
4294 \circuitdescbip*{saturation}{Saturation\footnotemark}{}
4295 \footnotetext{Contributed by \href{https://github.com/circuitikz/circuitikz/issues/758}{P. Sacco \texttt{<[email protected]>}}}
4296 \circuitdescbip*{sigmoid}{Sigmoid}{}
4297 \circuitdescbip*{allornothing}{Comparison, all-or-nothing}{}
4298 \circuitdescbip*{fiber}{Optical Fiber}{}
4299 \circuitdescbip*{sdcdc}{single wire DC/DC converter\footnotemark}{}(dc up in/135/.3, dc down in/185/.3, dc up out/45/.3, dc down out/-35/.3)
4300 \footnotetext{the converter blocks added by \texttt{olfline}}
4301 \circuitdescbip*{sacdc}{single phase AC/DC converter}{}(ac up in/135/.3, ac down in/185/.3, dc up out/45/.3, dc down out/-35/.3)
4302 \circuitdescbip*{sdcac}{single phase DC/AC converter}{}(dc up in/135/.3, dc down in/185/.3, ac up out/45/.3, ac down out/-35/.3)
4303 \circuitdescbip*{sacac}{single phase AC/AC converter}{}(ac up in/135/.3, ac down in/185/.3, ac up out/45/.3, ac down out/-35/.3)
4304 \circuitdescbip*{tacdc}{three phases AC/DC converter}{}(ac up in/135/.3, ac mid in/185/.3, ac down in/-135/.3, dc up out/45/.3, dc down out/-35/.3)
4305 \circuitdescbip*{tdcac}{three phases AC/DC converter}{}(ac up out/45/0.1, ac mid out/-5/.3, ac down out/-45/.1, dc up in/135/.3, dc down in/185/.3)
4306 \circuitdescbip*{tacac}{three phases AC/DC converter}{}(ac up in/135/.3, ac mid in/185/.3, ac down in/-135/.3, ac up out/45/.3, ac mid out/-5/.3, ac down out/-45/.3)
4307 \circuitdesc*{gridnode}{gridnode\footnotemark}{}(left/135/0.2, right/45/0.2, center/-100/0.4, up/90/0.2, down/-45/.2)
4308 \footnotetext{added by \texttt{olfline}}
4309 \end{groupdesc}
4310
4311 Filters blocks have an alternative, Bode-diagram-like appearance.
4312 Their names end in \texttt{p}, as a mnemonic for ``plot''.
4313 By default, they have a ``fake'' semi-logarithmic grid to convey the hint that the diagram is a frequency response one, to separate them from similar drawings as, for example, saturation.
4314 The grid can be removed or customized, see section~\ref{sec:block-filter-grid-cust}.
4315
4316 \begin{groupdesc}
4317 \circuitdescbip*{lowpassp}{lowpass, plot style}{}
4318 \circuitdescbip*{highpassp}{highpass, plot style}{}
4319 \circuitdescbip*{bandpassp}{bandpass, plot style}{}
4320 \circuitdescbip*{bandstopp}{bandstop, plot style}{}
4321 \circuitdescbip*{resonantp}{resonant, plot style}{}
4322 \circuitdescbip*{notchp}{notch, plot style}{}
4323 \end{groupdesc}
4324
4325 If you add the \IndexKey{ideal filter} option, the filters are changed like this:
4326
4327 \begin{groupdesc}
4328 \circuitdescbip*{lowpassp, ideal filter}{lowpass, plot style, ideal filter}{}
4329 \circuitdescbip*{highpassp, ideal filter}{highpass, plot style, ideal filter}{}
4330 \circuitdescbip*{bandpassp, ideal filter}{bandpass, plot style, ideal filter}{}
4331 \circuitdescbip*{bandstopp, ideal filter}{bandstop, plot style, ideal filter}{}
4332 \circuitdescbip*{resonantp, ideal filter}{resonant, plot style, ideal filter}{}
4333 \circuitdescbip*{notchp, ideal filter}{notch, plot style, ideal filter}{}
4334 \end{groupdesc}
4335
4336 Another difference when using \texttt{ideal filter} is that now the grid is linear, and the angles are always sharp.
4337
4338 Blocks to draw TV/radio system schematics, contributed by \href{https://github.com/circuitikz/circuitikz/pull/693}{Dr. Matthias Jung}.
4339 \begin{groupdesc}
4340 % radio/tv block sets
4341 \circuitdescbip*{camera}{Videocamera}{}
4342 \circuitdescbip*{tvset}{Television (TV)}{}
4343 \circuitdescbip*{trx}{Radio tranceiver (HAM-Radio)}{}(plus/160/0.2, minus/200/0.2)
4344 \circuitdescbip*{swr}{Standing Wave Ratio (SWR) meter}{}
4345 \circuitdescbip*{power}{Power Supply}{}(u1/160/0.2, u2/200/0.2, plus/45/0.2, minus/-45/0.2)
4346 \end{groupdesc}
4347
4348 \begin{groupdesc}
4349 \circuitdesc*{fourport}{Generic fourport}{}(port1/180/0.1, port2/0/0.1, port3/0/0.2, port4/180/0.1)
4350 \circuitdesc*{coupler}{Coupler\footnotemark}{}(left down/180/0.1, right down/0/0.1, right up/0/0.2, left up/180/0.1)
4351 \footnotetext{Notice that the \texttt{left/right up/down} anchors coincide with \texttt{port1\dots 4} only for the default values of \texttt{block [left/right] anchors pos}.}
4352 \circuitdesc*{coupler2}{Coupler with rounded arrows}{}
4353 \end{groupdesc}
4354
4355 \subsubsection{Blocks anchors}
4356 \label{sec:blocks-anchors}
4357
4358 The ports of the \texttt{mixer}, \texttt{adder}, \texttt{oscillator} and \texttt{circulator} can be addressed with \texttt{west}, \texttt{south}, \texttt{east}, \texttt{north}; the equivalent \texttt{left}, \texttt{down}, \texttt{right}, \texttt{up}; or the shorter \texttt{w, s, e, n} ones:
4359
4360 \begin{ctikzExample}
4361 \begin{circuitikz} \draw
4362 (0,0) node[mixer] (mix) {}
4363 (mix.w) node[left] {w}
4364 (mix.s) node[below] {s}
4365 (mix.e) node[right] {e}
4366 (mix.n) node[above] {n}
4367 ;\end{circuitikz}
4368 \end{ctikzExample}
4369
4370 In addition, since \texttt{v1.6.0}, most blocks also have the \texttt{left up}, \texttt{left down}, \texttt{right up} and \texttt{right down} anchors:
4371 \begin{ctikzExample}
4372 \begin{circuitikz} \draw
4373 (0,0) to[bandpass, name=bp] ++(2,0)
4374 (bp.left up) node[circ, red]{}
4375 (bp.left down) node[circ, blue]{}
4376 (bp.right up) node[circ, green]{}
4377 (bp.right down) node[circ, orange]{}
4378 ;\end{circuitikz}
4379 \end{ctikzExample}
4380
4381 Since \texttt{1.6.7} you can change the relative position of the lateral generic anchors\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/769}{user @sputeanus} on GitHub} using the keys \IndexKey{block left anchors pos} and \IndexKey{block right anchor pos} (default \texttt{0.5}, as in previous releases) which set the position as a fraction of the top to center segment.
4382 Since \texttt{1.8.4} the effect of this keys is also extended to node-type blocks, which is especially useful for the ``boxed'' versions; you can also use the inner styling here.
4383
4384 \begin{ctikzExample}
4385 \begin{circuitikz}
4386 \ctikzset{block left anchors pos=0.8, block right anchors pos=0.2}
4387 \ctikzset{blocks/inner thickness=3, blocks/inner color=orange}
4388 \draw (0,3) to[bandpass, name=bp] ++(2,0)
4389 (1,1.5) node[gridnode](g){} (1,0) node[mixer, boxed](bm){};
4390 \foreach \n in {bp, bm, g} {\path
4391 (\n.left up) node[circ, red]{}
4392 (\n.left down) node[circ, blue]{}
4393 (\n.right up) node[circ, green]{}
4394 (\n.right down) node[circ, orange]{};}
4395 \end{circuitikz}
4396 \end{ctikzExample}
4397
4398 To set both left and right at the same value, you can use the key \IndexKey{block lateral anchors pos}, which set both to the same number.
4399 You can use those anchors to build ``mixed-type'' circuits, using the node-shapes (the following drawing is a bit silly, but shows that the anchor position can be changed locally):
4400 \begin{ctikzExample}[pos=t, varwidth=true]
4401 \begin{tikzpicture}[
4402 big/.style={circuitikz/blocks/scale=1.5},
4403 long/.style={circuitikz/bipoles/twoportsplit/width=1.5}]
4404 \ctikzset{block lateral anchors pos=0.8}
4405 \path (0,0) node[sacdcshape, big, circuitikz/block right anchors pos=0.2](A){}
4406 (5,0) node[twoportsplitshape, big, long, t1=LNA, t2=Digital](B){};
4407 \draw (A.right up) -- (B.left up) (A.right down) to[cute choke] (B.left down);
4408 \end{tikzpicture}
4409 \end{ctikzExample}
4410
4411 Notice also from the previous example that the generic blocks (\IndexKey[twoport/width]{twoport} and \IndexKey[twoportsplit/width]{twoportsplit}) can be made ``longer'' by setting different \texttt{width} and \texttt{height} (the other blocks are square, and just use the \texttt{width} key for both dimensions).
4412
4413 Also, for \texttt{amp} and \texttt{vamp}, the \texttt{up} and \texttt{down} anchors follow the shape when they are not boxed.
4414 \begin{ctikzExample}
4415 \begin{tikzpicture}
4416 \draw (0,0) to[vamp, name=a] ++(1.5,0)
4417 to [vamp, boxed, name=ab] ++(1.5,0);
4418 \path (a.up) node[circ, blue]{} (ab.up) node[circ, blue]{};
4419 \path (a.down) node[circ, red]{} (ab.down) node[circ, red]{};
4420 \end{tikzpicture}
4421 \end{ctikzExample}
4422
4423 The \texttt{oscillator} has a displaced \texttt{center} anchor, to simplify the task of putting it at the left side of a circuit; it also as a special position for the node text. The four round elements (mixer, circulator, adder, and the oscillator) have a \texttt{geocenter} anchor which always corresponds to the center of the circle.
4424 \begin{ctikzExample}
4425 \begin{tikzpicture}[>=Stealth]
4426 \draw (0,0)node[oscillator](O){$f_0$} -- ++(1,0);
4427 \draw[blue, ->] (1,1) -- (O.center);
4428 \draw[red, ->] (1,1) -- (O.geocenter);
4429 \end{tikzpicture}
4430 \end{ctikzExample}
4431
4432 Moreover, the have proper border anchors since version \texttt{1.2.3} (and fixed for boxed elements in \texttt{1.5.0}), so you can do things like this:
4433
4434 \begin{ctikzExample}
4435 \begin{circuitikz}
4436 \draw (0,0) node[adder] (mix) {}
4437 (-1,1) -- ++(0.5,0) -- (mix)
4438 (-1,-1) -- ++(0.5,0) -- (mix) -- ++(1,0);
4439 \draw [red, <-] (mix.45) -- ++(1,1);
4440 \end{circuitikz}
4441 \end{ctikzExample}
4442
4443 Those components have also \textbf{deprecated} anchors named \texttt{1, 2, 3, 4}; they are better not used because they can conflict with the border anchor. They still work for backward compatibility, but could be removed in a future release.
4444
4445 \begin{ctikzExample}
4446 \begin{circuitikz} \draw
4447 (0,0) node[mixer] (mix) {}
4448 (mix.1) node[left] {1} (mix.2) node[below] {2}
4449 (mix.3) node[right] {3} (mix.4) node[above] {4};
4450 \draw [ultra thick, red, opacity=0.5]
4451 (-1,-1)--(1,1)(-1,1)--(1,-1);
4452 \node [red, below] at (0,-1) {DON'T USE};
4453 \end{circuitikz}
4454 \end{ctikzExample}
4455
4456 The Wilkinson divider has (notice that the node text is outside the bounding box, similarly to what happens for transistors!):
4457
4458 \begin{ctikzExample}
4459 \begin{circuitikz} \draw
4460 (0,0) node[wilkinson] (w) {\SI{3}{dB}}
4461 (w.in) to[short,-o] ++(-0.5,0)
4462 (w.out1) to[short,-o] ++(0.5,0)
4463 (w.out2) to[short,-o] ++(0.5,0)
4464 (w.in) node[below left] {\texttt{in}}
4465 (w.out1) node[below right] {\texttt{out1}}
4466 (w.out2) node[above right] {\texttt{out2}}
4467 ;
4468 \end{circuitikz}
4469 \end{ctikzExample}
4470
4471 The couplers have:
4472
4473 \begin{ctikzExample}
4474 \begin{circuitikz} \draw (0,1.5) %bounding box
4475 (0,0) node[coupler] (c) {\SI{10}{dB}}
4476 (c.left down) to[short,-o] ++(-0.5,0)
4477 (c.right down) to[short,-o] ++(0.5,0)
4478 (c.right up) to[short,-o] ++(0.5,0)
4479 (c.left up) to[short,-o] ++(-0.5,0)
4480 (c.left down) node[below left] {\texttt{left down}}
4481 (c.right down) node[below right] {\texttt{right down}}
4482 (c.right up) node[above right] {\texttt{right up}}
4483 (c.left up) node[above left] {\texttt{left up}}
4484 ;
4485 \end{circuitikz}
4486 \end{ctikzExample}
4487
4488 Or you can also use \texttt{port1} to \texttt{port4} if you prefer:
4489
4490 \begin{ctikzExample}
4491 \begin{circuitikz} \draw (0,1.5) %bounding box
4492 (0,0) node[coupler2] (c) {\SI{3}{dB}}
4493 (c.port1) to[short,-o] ++(-0.5,0)
4494 (c.port2) to[short,-o] ++(0.5,0)
4495 (c.port3) to[short,-o] ++(0.5,0)
4496 (c.port4) to[short,-o] ++(-0.5,0)
4497 (c.port1) node[below left] {\texttt{port1}}
4498 (c.port2) node[below right] {\texttt{port2}}
4499 (c.port3) node[above right] {\texttt{port3}}
4500 (c.port4) node[above left] {\texttt{port4}}
4501 ;
4502 \end{circuitikz}
4503 \end{ctikzExample}
4504
4505 Also they have the simpler \texttt{1, 2, 3, 4} anchors, and although they have no border anchors (for now), it is better not to use them.
4506
4507 \begin{ctikzExample}
4508 \begin{circuitikz} \draw(0,1.5) %bounding box
4509 (0,0) node[coupler] (c) {\SI{10}{dB}}
4510 (c.1) to[short,-o] ++(-0.5,0)
4511 (c.2) to[short,-o] ++(0.5,0)
4512 (c.3) to[short,-o] ++(0.5,0)
4513 (c.4) to[short,-o] ++(-0.5,0)
4514 (c.1) node[below left] {\texttt{1}}
4515 (c.2) node[below right] {\texttt{2}}
4516 (c.3) node[above right] {\texttt{3}}
4517 (c.4) node[above left] {\texttt{4}}
4518 ;
4519 \end{circuitikz}
4520 \end{ctikzExample}
4521
4522 \subsubsection{Blocks customization}
4523 \label{sec:blocks-customization}
4524
4525 You can change the scale of all the block elements by setting the key \texttt{blocks/scale} to something different from the default \texttt{1.0}.
4526
4527 With the option \texttt{>} you can draw an arrow to the input of the block diagram symbols.
4528 \begin{ctikzExample}
4529 \begin{circuitikz} \draw
4530 (0,0) to[short,o-] ++(0.3,0)
4531 to[lowpass,>] ++(2,0)
4532 to[adc,>] ++(2,0)
4533 to[short,-o] ++(0.3,0);
4534 \end{circuitikz}
4535 \end{ctikzExample}
4536
4537
4538 You can also change the width for the generic block:
4539
4540 \begin{ctikzExample}[pos=t, varwidth=t]
4541 \begin{circuitikz}[european]
4542 \draw (0,0) to[amp, >, t=$K_{\mathrm{p}}$] ++(2,0)
4543 to[saturation, >, name=sat] ++(2,0) -- ++(0.5,0)
4544 to[twoport, t=$\displaystyle\frac{\tau s +1}{\tau s}$, >,
4545 bipoles/twoport/width=1.5] ++(3,0);
4546 \node[above] at (sat.ne) {$+I_{\mathrm{max}}$};
4547 \node[below] at (sat.sw) {$-I_{\mathrm{max}}$};
4548 \end{circuitikz}
4549 \end{ctikzExample}
4550
4551 \paragraph{Multi ports}
4552 \label{par:multi-ports}
4553 Since inputs and outputs can vary, input arrows can be placed as nodes. Note that you have to rotate the arrow on your own:
4554
4555 \begin{ctikzExample}
4556 \begin{circuitikz} \draw
4557 (0,0) node[mixer] (m) {}
4558 (m.w) to[short,-o] ++(-1,0)
4559 (m.s) to[short,-o] ++(0,-1)
4560 (m.e) to[short,-o] ++(1,0)
4561 (m.w) node[inputarrow] {}
4562 (m.s) node[inputarrow,rotate=90] {};
4563 \end{circuitikz}
4564 \end{ctikzExample}
4565
4566 You can use additional anchors to mix different kinds of elements.
4567
4568 \begin{ctikzExample}[varwidth=true, pos=t]
4569 % Author: Prof. Dr. Matthias Jung Year: 2023
4570 \begin{tikzpicture}
4571 %\useasboundingbox (-3.75,-1.0) rectangle (10.5,3);
4572 \node[draw, powershape] at (0,0) (supply) {};
4573 \draw(supply.south) node[anchor=north]{\qty{13,8}{V}};
4574 \node[draw, trxshape] at (5,0) (trx) {};
4575 \draw(trx.east) -- ++(1,0) node[swrshape, anchor=west](swr){};
4576 \draw(swr.east) -- ++(1,0) node[antenna]{};
4577 \draw(trx.south) node[ground]{};
4578 \draw[red](supply.plus) to [fuse, color=red] ++(2.5,0)
4579 to [short, i={I}, color=red] (trx.plus);
4580 \draw(trx.minus) to [short, i={}] (supply.minus);
4581 \draw(supply.u1) to [short, -o] ++(-1,0) coordinate(c1);
4582 \draw(supply.u2) to [short, -o] ++(-1,0) coordinate(c2);
4583 \draw(c1) to [open, l_={$\sim\qty{230}{\volt}$}] (c2);
4584 \end{tikzpicture}
4585 \end{ctikzExample}
4586
4587 \paragraph{Labels and custom two-port boxes}
4588 \label{par:labels-and-custom}
4589
4590 You can use the keys \texttt{t}, \texttt{t1}, \texttt{t2} (shorthands for \texttt{text}, \texttt{text in}, \texttt{text out}) to fill the generic blocks:
4591 \begin{ctikzExample}
4592 \begin{circuitikz} \draw
4593 (0,0) to[short,o-] ++(0.3,0)
4594 to[allpass,>] ++(2,0)
4595 to[twoport,>,t={B}] ++(2,0)
4596 to[twoportsplit,t1={\tiny in},
4597 t2={\tiny\color{red}out}] ++(0,-2.5);
4598 \end{circuitikz}
4599 \end{ctikzExample}
4600
4601 Some two-ports have the option to place a normal label (\texttt{l=}) and a inner label (\texttt{t=}).
4602 \begin{ctikzExample}
4603 \begin{circuitikz}
4604 \ctikzset{bipoles/amp/width=0.9}
4605 \draw (0,0) to[amp,t=LNA,l_=$F{=}0.9\,$dB,o-o] ++(3,0);
4606 \end{circuitikz}
4607 \end{ctikzExample}
4608
4609 Each block determines where the text is added:
4610 \begin{ctikzExample}
4611 \begin{circuitikz} \draw
4612 (0,0) to[qgenerator, t=G,*-] ++(2,0)
4613 to[vallpass,>] ++(2,0)
4614 to[ngenerator, t=FM,>] ++(2,0)
4615 to[short,-o] ++(0.3,0);
4616 \end{circuitikz}
4617 \end{ctikzExample}
4618
4619 For the \IndexKey{twoportsplit} block, you can change how the text is positioned using the key (shared with amplifiers and logic ports, so better use it locally) \IndexKey{component text} (default value \texttt{center}), which gives the standard positioning (text centered in each one of the triangles in which the block is divided).
4620 If you set it to the value \texttt{border}, the text will be positioned at the corner (upper left or bottom right, depending on orientation) with a distance set by \IndexKey{border text distance} (default \texttt{\ctikzvalof{border text distance}}).
4621 This option makes it easy to define additional blocks, like these \href{https://github.com/circuitikz/circuitikz/issues/925}{suggested by Matthias Jung}:
4622
4623 \begin{ctikzExample}[only code, exec outside]
4624 % define a macro to draw a "safe" four-dot symbol
4625 % basic LaTeX pictures are usable inside TikZ nodes,
4626 % no nesting problems.
4627 \newcommand{\fourdots}{%
4628 \begingroup
4629 \setlength{\unitlength}{0.8mm}%
4630 \begin{picture}(4,4)(-2,-2)
4631 \put(-2,0){\line(1,0){4}}
4632 \put(0,-2){\line(0,1){4}}
4633 \multiput(-1,1)(2,0){2}{\circle*{1}}
4634 \multiput(-1,-1)(2,0){2}{\circle*{1}}
4635 \end{picture}%
4636 \endgroup
4637 }
4638 % define the new blocks
4639 \tikzset{%
4640 tinysplits/.style 2 args={twoportsplit,
4641 component text=border, border text distance=3pt,
4642 t1={\tiny\ttfamily #1}, t2={\tiny\ttfamily #2}},
4643 source coder/.style={tinysplits={0101}{01}},
4644 channel coder/.style={tinysplits={01}{01+01}},
4645 mapper/.style={tinysplits={01}{\fourdots}},
4646 }
4647 \end{ctikzExample}
4648
4649 \begin{ctikzExample}
4650 \begin{circuitikz}
4651 \draw (0,0)
4652 to[source coder, >] ++(2.5,0)
4653 to[channel coder, >] ++(0,2.5)
4654 to[mapper, >] ++(-2.5,0)
4655 to[source coder,>] ++(0,-2.5)
4656 ;
4657 \end{circuitikz}
4658 \end{ctikzExample}
4659
4660
4661
4662 \paragraph{Box option}
4663 \label{par:box-option}
4664 Several devices have the possibility to add a box around them with the \IndexKey{box} or \IndexKey{boxed} option. The inner symbol scales down to fit inside the box. For the ``circled'' devices (mixer, adder, oscillator and circulator) the inner circle is normally drawn, unless you use the \IndexKey{box only} or \IndexKey{boxed only} option.\footnote{Since 1.5.0, suggested by \href{https://github.com/circuitikz/circuitikz/issues/621}{GitHub user myzinsky}}
4665 \begin{ctikzExample}
4666 \begin{circuitikz} \draw
4667 (0,0) node[mixer, box only, anchor=east](m){}
4668 to[amp, boxed, >, -o] ++(2.5,0)
4669 (m.west) node[inputarrow]{} to[short,-o] ++(-0.8,0)
4670 (m.south) node[inputarrow,rotate=90]{} --
4671 ++(0,-0.7) node[oscillator, box, anchor=north]{};
4672 \end{circuitikz}
4673 \end{ctikzExample}
4674
4675
4676 \paragraph{Dash optional parts}
4677 \label{par:dash-optional-parts}
4678 To show that a device is optional, you can dash it. The inner symbol will be kept with solid lines, unless you set the key \IndexKey{inner blocks dashed} to true.
4679 Moreover, the key \IndexKey{dashed blocks pattern} (default \verb|{{1mm}{1mm}}|), be careful with the number of braces!.
4680 \begin{ctikzExample}
4681 \begin{circuitikz}
4682 \draw (0,1.5) to[amp,l=\SI{10}{dB}] ++(2.5,0);
4683 \draw[dashed] (2.5,1.5) to[lowpass,l=opt.] ++(2.5,0);
4684 % or just the block
4685 \draw (0,0) to[amp,l=\SI{10}{dB}] ++(2.5,0)
4686 to[lowpass,l=opt., dashed] ++(2.5,0);
4687 % or everything
4688 \ctikzset{inner blocks dashed,
4689 dashed blocks pattern={{1.5pt}{1pt}},
4690 }
4691 \draw (0,-1.5) to[amp,l=\SI{10}{dB}] ++(2.5,0)
4692 to[lowpass,l=opt., dashed] ++(2.5,0);
4693 \end{circuitikz}
4694 \end{ctikzExample}
4695
4696 \paragraph{Dashing the DC symbol in blocks.}
4697 \label{par:dashing-the-dc}
4698 The symbol for the DC side can be different across countries,\footnote{Head-up from \href{https://github.com/circuitikz/circuitikz/issues/680}{user \texttt{@dbstf} on GitHub}} with different kind of dashing on the bottom line.
4699 Moreover, sometimes the dashing is used to convey different meanings (like rectified sinusoidal or stabilized DC).
4700 You can change the general style for the DC symbol using the key \IndexKey{blocks dc segments}; using~\texttt{1} (default) will use a continuous line; using \texttt{2} you will have the international-styled symbol, and with~\texttt{3} the English one (you can use higher numbers; the only restriction is that it must be strictly greater than \texttt{0}). You can also change the input and output part separately with the keys \IndexKey{blocks dc in segments} and \IndexKey{blocks dc out segments} (see the following example). The \texttt{inner blocks dashed} can have strange interaction with these ones.
4701
4702
4703 \begin{ctikzExample}[basicstyle=\footnotesize\ttfamily]
4704 \begin{tikzpicture}[scale=0.8]
4705 \ctikzset{blocks dc segments=3}
4706 \draw (0,2) to[sacdc] ++(2,0) to[sdcdc]
4707 ++(2,0) to[sdcac] ++(2,0);
4708 \ctikzset{blocks dc segments=1}
4709 \draw[dashed] (0,0) to[sacdc, blocks dc out segments=2]
4710 ++(2,0) to[sdcdc, blocks dc in segments=2,
4711 inner blocks dashed,
4712 dashed blocks pattern={{0.4pt}{0.4pt}}]
4713 ++(2,0) to[sdcac] ++(2,0);
4714 \end{tikzpicture}
4715 \end{ctikzExample}
4716
4717
4718 \paragraph{Blocks inner drawing.}
4719 \label{par:blocks-inner-drawing}
4720 Almost all of the inner block drawing style can be customized, without affecting the external box, with the keys \IndexKey{blocks/inner color} (default \texttt{default}, which means ``don't change color'') and \IndexKey{blocks/inner thickness} (default \texttt{1}; this is relative to the class-specified thickness).
4721
4722 \begin{ctikzExample}
4723 \begin{circuitikz} \draw
4724 (0,0) to[short,o-] ++(0.3,0)
4725 to[lowpass,>, blocks/inner color=red ] ++(2,0)
4726 to[lowpassp,>, blocks/inner thickness=4,
4727 blocks/filter grid/thickness=0.25] ++(2,0)
4728 to[short,-o] ++(0.3,0);
4729 \end{circuitikz}
4730 \end{ctikzExample}
4731
4732 The key \IndexKey{blocks/gridnode/gridlines} controls the number of lines in the \texttt{gridnode} block, defined as parallel lines in one diagonal. This can be customised using the key, which accepts any positive integer (default is \texttt{7}).\footnote{Contributed by \href{https://github.com/circuitikz/circuitikz/pull/906}{Jakob Leide on GitHub}}
4733
4734 \begin{ctikzExample}
4735 \begin{circuitikz}
4736 \node[gridnode] at (0,0) {};
4737 \node[gridnode,gridlines=3] at (2,0) {};
4738 \ctikzset{blocks/gridnode/gridlines=10}
4739 \node[gridnode] at (4,0) {};
4740 \end{circuitikz}
4741 \end{ctikzExample}
4742
4743 \paragraph{Plot-type filter blocks customization.}\label{sec:block-filter-grid-cust}
4744 In the ``plot''-type filter blocks, you can change the appearance of the grid using the following parameters (with \verb!\ctikzset!, under the family \IndexKey{blocks/filter grid/})
4745
4746 \begin{center}
4747 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{8cm}}
4748 \toprule
4749 parameter & default & description \\
4750 \midrule
4751 thickness & 0.5 & line thickness, this is relative to the \texttt{inner thickness} setting for the block \\
4752 color & default & stroke color: \texttt{default} is the same as the component color (\texttt{inner color} if it's set) \\
4753 dash & \{\{0.04cm\}\{0.04cm\}\} & dash pattern: none means solid line, default means keep the global pattern\footnotemark \\
4754 opacity & 0.3 & stroke opacity for the grid. Using \texttt{0} will suppress the drawing of the grid completely. \\
4755 \bottomrule
4756 \end{tabular}
4757 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples. Notice that the dimensions are not exactly \unit{cm}: the length are scaled so that \qty{1}{cm} is really the block width.}
4758 \end{center}
4759
4760 Additionally, the \IndexKey{blocks/filter plot/relative thickness} (default \ctikzvalof{blocks/filter plot/relative thickness}) will change the relative thickness (with respect to the class thickness, or \texttt{inner thickness} if set) of the ``frequency response'' sketch line.
4761
4762 Finally, the plots are by default rounded\footnote{This, and the hint for the new filter shapes, were suggested by \href{https://chat.stackexchange.com/transcript/message/68537036\#68537036}{@cis on the TeX-SX chat}. Ideal filters ignore the roundness parameter.}, but you can choose to have them with sharp edges setting the key \IndexKey{blocks/filter plot/rounding} to \texttt{0} (the default value is \texttt{0.15}).
4763
4764 Setting the key \IndexKey{ideal filter numbers} a small \texttt{0} and \texttt{1} are added at the left side of the grid. The two numbers can be customized using the keys \IndexKey{ideal filter number low} and \IndexKey{ideal filter number low} (by default set to \texttt{0} and \texttt{1} respectively), but notice that there is very little space there.
4765
4766 \begin{ctikzExample}
4767 \begin{circuitikz}
4768 \draw (0,0) to[lowpassp=\qty{1}{\kHz},
4769 blocks/filter grid/color=red,
4770 blocks/filter grid/dash=none,
4771 blocks/filter grid/thickness=1] ++(2,0)
4772 to[notchp=\qty{50}{\hertz},
4773 blocks/filter grid/opacity=0,
4774 blocks/filter plot/relative thickness=1,
4775 blocks/filter plot/rounding=0] ++(2,0);
4776 \draw (0,-2) to[lowpassp, ideal filter] ++(2,0)
4777 to[bandpassp, ideal filter,
4778 ideal filter numbers] ++(2,0);
4779 \ctikzset{ideal filter numbers, % set as default
4780 ideal filter number high=A}
4781 \draw (0,-4) to[lowpassp, ideal filter] ++(2,0)
4782 to[bandpassp, ideal filter] ++(2,0);
4783 \end{circuitikz}
4784 \end{ctikzExample}
4785
4786 \subsection{Transistors}
4787 \label{sec:transistors}
4788
4789 \subsubsection{Standard bipolar transistors}
4790 \label{sec:standard-bipolar-transistors}
4791
4792 \begin{groupdesc}
4793 \circuitdesc{npn}{npn}{Q}( B/180/0.2,C/0/0.2,E/0/0.2 )
4794 \circuitdesc{pnp}{pnp}{}
4795 \circuitdesc{npn, schottky base}{schottky npn}{}
4796 \circuitdesc{pnp, schottky base}{schottky pnp}{}
4797 \circuitdesc{npn, bodydiode}{npn}{}(body C in/60/0.2, body E in/-60/0.2,body C out/0/0.3, body E out/-0/0.3)
4798 \circuitdesc{npn,photo}{photo npn}{}(nobase/0/0.4)
4799 \circuitdesc{pnp,photo}{photo pnp}{}(arrows/180/0.1)
4800 \circuitdesc{nigbt}{nigbt}{Q}
4801 \circuitdesc{pigbt}{pigbt}{}(centergap/0/0.5)
4802 \circuitdesc{Lnigbt}{Lnigbt}{Q}
4803 \circuitdesc{Lpigbt}{Lpigbt}{}
4804 \circuitdesc{Lpigbt, bodydiode}{Lpigbt}{Q}(body C in/-60/0.2, body E in/60/0.2,body C out/0/0.3, body E out/-0/0.3)
4805 \end{groupdesc}
4806
4807 \subsubsection{Multi-terminal bipolar transistors}
4808 \label{sec:multi-terminal-bipolar}
4809
4810 In addition to the standard BJTs transistors, since version~\texttt{0.9.6} the \texttt{bjtnpn} and \texttt{bjtpnp} are also available; these are devices where you can have more collectors and emitters (on the other hand, they have no \texttt{photo} nor \texttt{bodydiode} options --- they are silently ignored).
4811
4812 Basically they are the same as the normal \texttt{npn} and \texttt{pnp}, and they (by default) have similar sizes; the options \texttt{collectors} and \texttt{emitters} will change the number of the relative terminals. The base terminal is connected midway from the collector and the emitter, \emph{not} on the center of the base; a \texttt{cbase} anchor is available if you prefer to use it. The label of the component (the text) is set on the right side, vertically centered around the base terminal. They will accept the \texttt{schottky base} key.
4813
4814 \begin{groupdesc}
4815 \circuitdesc{bjtnpn, collectors=1, emitters=2}{bjt npn}{Q}(B/180/0.2, C/45/0.2, E/-45/0.2, C1/0/0.4, E1/0/0.4, E2/0/0.4, nobase/135/0.4, cbase/-135/0.4, center/0/0.6)
4816 \circuitdesc{bjtpnp, collectors=3, emitters=2}{bjt pnp}{Q}(B/180/0.2, C/-45/0.2, E/45/0.2, C1/0/0.4, C2/0/0.4, C3/0/0.4, E1/0/0.4, E2/0/0.4, nobase/135/0.4, cbase/-135/0.4)
4817 \end{groupdesc}
4818
4819 \subsubsection{Field-effect transistors}
4820 \label{sec:field-effect-transistors}
4821
4822 \begin{groupdesc}
4823 \circuitdesc{nmos}{nmos}{Q}( G/180/0.2,D/0/0.2,S/0/0.2 )
4824 \circuitdesc{pmos}{pmos}{}(centergap/0/0.5)
4825 \circuitdesc{nmosd}{nmos depletion}{Q}( G/180/0.2,D/0/0.2,S/0/0.2 )
4826 \circuitdesc{pmosd}{pmos depletion}{}
4827 \circuitdesc{hemt}{hemt}{}
4828 \circuitdesc{hemt, nobase}{hemt without base terminal}{Q}( G/180/0.2,D/0/0.2,S/0/0.2, nogate/-120/0.2)
4829 \circuitdesc{GaN hemt}{Gallium Nitride hemt (a ``styled'' \texttt{hemt}, see~\ref{sec:hemt})}{Q}( G/180/0.2,D/0/0.2,S/0/0.2, nogate/-120/0.2)
4830 \end{groupdesc}
4831
4832 \textsc{nfet}s and \textsc{pfet}s have been incorporated based on code provided by Clemens Helfmeier and Theodor Borsche. Use the package options \IndexKey{fetsolderdot}/\IndexKey{nofetsolderdot} to enable/disable solderdot at some fet-transistors. Additionally, the solderdot option can be enabled/disabled for single transistors with the option \texttt{solderdot} and \texttt{nosolderdot}, respectively (You can adjust the size of the solder dot, see section~\ref{sec:solderdot-scale}).
4833
4834 \begin{groupdesc}
4835 \circuitdesc{nfet}{nfet}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4836 \circuitdesc{nfetd}{nfet depletion}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4837 \circuitdesc{nigfete}{nigfete}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4838 \circuitdesc{nigfete,solderdot}{nigfete}{}(centergap/0/0.5)
4839 \circuitdesc{nigfetebulk}{nigfetebulk}{}
4840 \circuitdesc{nigfetd}{nigfetd}{}(centergap/0/0.5)
4841 \circuitdesc{pfet}{pfet}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4842 \circuitdesc{pfetd}{pfet depletion}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4843 \circuitdesc{pigfete}{pigfete}{}(centergap/0/0.5, G/180/0.1, D/0/0.1, S/0/0.1)
4844 \circuitdesc{pigfetebulk}{pigfetebulk}{}
4845 \circuitdesc{pigfetd}{pigfetd}{}
4846 \end{groupdesc}
4847
4848 Since version \texttt{1.6.0}, you can add the \IndexKey{doublegate} option to the \texttt{*igfet*} family of devices to have a double gate MOS --- the additional gate is called \texttt{G2} or \texttt{gate2} (the plain \texttt{G} is where it will be without the \texttt{doublegate} option).
4849
4850 \begin{groupdesc}
4851 \circuitdesc{nigfete, doublegate}{nigfete, doublegate}{Q}(G/180/0.1, G2/180/0.1, D/0/0.1, S/0/0.1)
4852 \circuitdesc{nigfete,solderdot, doublegate}{nigfete, doublegate}{}(G1/180/0.1, centergap/0/0.5, G2/180/0.1)
4853 \circuitdesc{nigfetebulk, doublegate}{nigfetebulk, doublegate}{}(G/180/0.1, G2/180/0.1)
4854 \circuitdesc{nigfetd, doublegate}{nigfetd, doublegate}{}(G1/180/0.1, centergap/0/0.5, G2/180/0.1)
4855 \circuitdesc{pigfete, doublegate}{pigfete, doublegate}{}(G/180/0.1, centergap/0/0.5, G2/180/0.1, D/0/0.1, S/0/0.1)
4856 \circuitdesc{pigfetebulk, doublegate}{pigfetebulk, doublegate}{}(G/180/0.1, G2/180/0.1)
4857 \circuitdesc{pigfetd, doublegate}{pigfetd, doublegate}{}(G1/180/0.1, G2/180/0.1)
4858 \end{groupdesc}
4859
4860 You can use the double-gated transistor for example like this:%
4861 \footnote{Found at \href{https://www.electronics-notes.com/articles/electronic_components/fet-field-effect-transistor/dual-gate-mosfet.php}{this page on electronics notes}.}
4862
4863 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily]
4864 \begin{circuitikz}[european, scale=0.7, transform shape,
4865 circuitikz/resistors/scale=0.7]
4866 \draw (0,0) to[C, o-*] ++(1,0) coordinate(in)
4867 to[R, -*] ++(0,-3) coordinate(GND)
4868 ++(1,0) to[C, *-] ++(0,4) -- ++(1,0) coordinate(div)
4869 to[R, *-*] ++(0,2) coordinate(vdd)
4870 (div) to[R, -*] (div|-GND)
4871 (in) -- ++(2.5,0) node[nigfetd, doublegate, anchor=G1](Q){Q}
4872 (Q.G2) to[short, -*] (Q.G2-|div)
4873 (Q.D) to[R, -*] (Q.D|-vdd)
4874 (Q.D) to[C, *-o] ++(2,0) coordinate(out)
4875 (Q.S) to[R, *-*] (Q.S|-GND) (Q.S) -- ++(1,0) coordinate(Sd)
4876 (Sd) to[C, -*] (Sd |- GND);
4877 \draw (0,0|-GND) -- (out|-GND) (0,0|-vdd) -- (out|-vdd);
4878 \end{circuitikz}
4879 \end{ctikzExample}
4880
4881 Since version \texttt{v1.8.1} the \texttt{fdsoi} flag has been added to draw back gates for \href{https://anysilicon.com/fdsoi/}{FDSOI} types transistors.\footnote{Suggested via email by Raphael Nägele <[email protected]>; see also \href{https://github.com/circuitikz/circuitikz/issues/871}{this issue on GitHub}.}
4882 The flag acts on all the FET transistors.
4883
4884 \begin{groupdesc}
4885 \circuitdesc{nigfetebulk, fdsoi}{FDSOI-type nigfetebulk}{}(G/180/0.1, D/0/0.1, S/0/0.1, bulk/0/0.1)
4886 \circuitdesc{nfet, fdsoi}{FDSOI-type nfet}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4887 \circuitdesc{pigfetebulk, fdsoi}{FDSOI-type pigfetebulk}{}(G/180/0.1, D/0/0.1, S/0/0.1, bulk/0/0.1)
4888 \circuitdesc{pfet, fdsoi}{FDSOI-type pfet}{Q}(G/180/0.1, D/0/0.1, S/0/0.1)
4889 \end{groupdesc}
4890 and also with other FET-based shapes with bulk connection:
4891 \begin{groupdesc}
4892 \circuitdesc{nigfete, fdsoi} {FDSOI-type nigfete with bulk connected to spurce}{}(G/180/0.1, D/0/0.1, S/0/0.1, bulk/0/0.1)
4893 \circuitdesc{pigfete, fdsoi, doublegate, solderdot}{FDSOI-type pigfete with double gate and solderdot}{}(G/180/0.1, D/0/0.1, S/0/0.1, bulk/0/0.1)
4894 \end{groupdesc}
4895
4896 \textsc{JFET} are also available\footnote{based on code provided by Danilo Piazzalunga}, both n-type and p-type.
4897
4898 \begin{groupdesc}
4899 \circuitdesc{njfet}{n-type JFET}{Q}(G/-135/0.2,D/0/0.2,S/0/0.2)
4900 \circuitdesc{pjfet}{p-type JFET}{}(G/-135/0.2,D/0/0.2,S/0/0.2)
4901 \end{groupdesc}
4902
4903 \textsc{UJT} transistors\footnote{sugged by \href{https://github.com/circuitikz/circuitikz/issues/522}{user JetherReis on GitHub}.} have a different anchor names although \textbf{most} of the others, like \texttt{D} and \texttt{G}, also work (the exception is \texttt{E} and \texttt{emitter}!). Notice that if used with \IndexKey{nobase}, the anchor \texttt{E} follows the wire, while \texttt{G} is fixed (as is \texttt{kink}).
4904
4905 \begin{groupdesc}
4906 \circuitdesc{nujt}{n-type UJT}{Q}(G/-135/0.2,B1/0/0.2,B2/0/0.2 , kink/90/0.4, E/135/0.2)
4907 \circuitdesc{pujt}{p-type UJT}{Q}(G/-135/0.2,B1/0/0.2,B2/0/0.2 , kink/90/0.4, E/135/0.2)
4908 \circuitdesc{nujt, nobase}{n-type UJT with nobase option}{Q}(G/-135/0.2,B1/0/0.2,B2/0/0.2 , kink/90/0.4, E/135/0.2)
4909 \end{groupdesc}
4910
4911 \textsc{isfet}:
4912
4913 \begin{groupdesc}
4914 \circuitdesc{isfet}{isfet}{Q}
4915 \end{groupdesc}
4916
4917 \textsc{Graphene fet} have been added in version \texttt{1.3.2}\footnote{added by Romano Giannetti after a suggestion by Cees Keyer.}. They look better if you set \texttt{transistors/arrow pos=end} and \texttt{transistor/thickness=3} or higher for them, so they are plotted with this option here.
4918 \begin{groupdesc}
4919 \ctikzset{transistors/thickness=3, transistors/arrow pos=end}
4920 \circuitdesc*{ngfet}{N-type graphene FET}{Q}(outer hex up/45/0.3, outer hex down/-45/0.3, right/0/0.4)
4921 \circuitdesc*{pgfet}{pgfet}{Q}(inner hex up/135/0.3, inner hex down/-135/0.3)
4922 \end{groupdesc}
4923
4924 \subsubsection{Transistor texts (labels)}\label{sec:transistors-labels}
4925
4926 In versions before \texttt{0.9.7}, transistors text (the node text) was positioned near the collector terminal; since version \texttt{0.9.7} the default has been changed to a more natural position near the center of the device, similar to the multi-terminal transistors. You can revert to the old behavior locally with the key \IndexKey{legacy transistors text}, or globally by setting the package option \IndexKey{legacytransistorstext}.
4927
4928 Notice the use of the utility functions \verb|\ctikzflip{|\texttt{\textsl{x,y,xy}}\verb|}| as explained in section~\ref{sec:mirroring-and-flipping}.
4929
4930 \begin{ctikzExample}
4931 \begin{circuitikz}[scale=0.8, transform shape]
4932 \draw (0,0) node [npn]{T1}
4933 ++(1.2,0) node [npn, xscale=-1]{\ctikzflipx{T1}}
4934 ++(2,0) node [npn, yscale=-1]{\ctikzflipy{T1}}
4935 ++(1.2,0) node [npn, scale=-1]{\ctikzflipxy{T1}};
4936 \ctikzset{legacy transistors text}
4937 \draw (0,-2) node [npn]{T1}
4938 ++(1.2,0) node [npn, xscale=-1]{\ctikzflipx{T1}}
4939 ++(2,0) node [npn, yscale=-1]{\ctikzflipy{T1}}
4940 ++(1.2,0) node [npn, scale=-1]{\ctikzflipxy{T1}};
4941 \end{circuitikz}
4942 \end{ctikzExample}
4943
4944 There is a situation where using the legacy position makes sense: if you have a transistor with a bulk pin, and you need to connect that pin to something outside the component:
4945
4946 \begin{ctikzExample}
4947 \begin{circuitikz}[scale=0.8, transform shape]
4948 \draw (0,0) node [nigfetebulk](T1){T1} (T1.S) node[ground]{}
4949 (T1.bulk) -- ++(0.5, 0) node[vee]{};
4950 \draw (2,0) node [nigfetebulk, legacy transistors text](T2){T2}
4951 (T2.S) node[ground]{}
4952 (T2.bulk) -- ++(0.5, 0) node[vee]{};
4953 \end{circuitikz}
4954 \end{ctikzExample}
4955
4956 You can use the \texttt{legacy transistors text} to position the label ``up'', near the drain (or source, whichever is up) of the transistor --- but then we have a problem, if you use, for example, a transistor circle (it works by chance with the standard sizes, but if you change the size of the circle, you'll have problems:)
4957
4958 \begin{ctikzExample}
4959 \begin{circuitikz}[scale=0.8, transform shape]
4960 \ctikzset{legacy transistors text, tr circle}
4961 \draw (0,0) node [nigfetebulk](T1){T1} (T1.S) node[ground]{}
4962 (T1.bulk) -- ++(0.5, 0) node[vee]{}
4963 (0,-3) node [pigfetebulk](P1){P1} (P1.D) node[ground]{};
4964 \ctikzset{transistor circle/scale circle radius=1.3}
4965 \draw (2,0) node [nigfetebulk](T2){T2}
4966 (2,-3) node [pigfetebulk](P2){P2} (P2.D) node[ground]{}
4967 (T2.S) node[ground]{}
4968 (T2.bulk) -- ++(0.8, 0) node[vee]{};
4969 \end{circuitikz}
4970 \end{ctikzExample}
4971
4972 Since version \texttt{1.8.2} you can solve this with \IndexKey[component text: up/down]{component text=up} (or \texttt{down}, default \texttt{center}).
4973 This flag will move the text label of the transistors near the upper (or lower, respectively) terminal, a bit offset to the right.
4974 The value of this flag is taken into account only for transistors (at least, for now).
4975
4976 \begin{ctikzExample}
4977 \begin{circuitikz}
4978 \ctikzset{component text=up, tr circle}
4979 \draw (0,0) node [nigfetebulk](T1){T1}
4980 (T1.S) node[ground]{}
4981 (T1.bulk) -- ++(0.5, 0) node[vee]{}
4982 (0,-3) node [pigfetebulk, component text=down](P1){P1}
4983 (P1.D) node[ground]{};
4984 \ctikzset{transistor circle/scale circle radius=1.6}
4985 \draw (2,0) node [nigfetebulk](T2){T2}
4986 (2,-3) node [pigfetebulk, component text=down](P2){P2}
4987 (P2.D) node[ground]{}
4988 (T2.S) node[ground]{}
4989 (T2.bulk) -- ++(1.2, 0) node[vee]{};
4990 \end{circuitikz}
4991 \end{ctikzExample}
4992
4993 \begin{ctikzExample}
4994 \begin{circuitikz}
4995 \draw (0,0) node[bjtnpn, emitters=2,
4996 component text=up](B){pB} ++(2,0)
4997 node[bjtnpn](C){pC} (B.nobase) -- (C.base)
4998 ++(2,1); %adjust bounding box
4999 \end{circuitikz}
5000 \end{ctikzExample}
5001
5002 \subsubsection{Transistors customization}\label{sec:styling-transistors}
5003
5004 \paragraph{Size.} You can change the scale of all the transistors by setting the key \IndexKey{transistors/scale} (default \texttt{1.0}).
5005 \label{par:size}
5006 The size of the arrows (if any) is controlled by the same parameters as \IndexKey{currarrow} (see section~\ref{sec:currarrow-size}) and the dots on P-type transistors (if any) are the same as the nodes/poles (see section~\ref{sec:bipole-nodes}).
5007
5008 \paragraph{Thickness.} You can change the thickness of the gate and base (channel) segments with the key \IndexKey{transistors/thickness}; additionally, since \texttt{v1.8.6}, you can use the key \IndexKey{transistors/gate thickness} which will be interpreted has the \emph{relative} thickness of the gate segment\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/934}{Michael Köfinger et al.}.}.
5009
5010 \begin{ctikzExample}
5011 \begin{tikzpicture}[]
5012 \ctikzset{tripoles/.cd, mos style=arrows,
5013 pmos style/nocircle}
5014 \ctikzset{transistors/.cd, thickness=4,
5015 arrow pos=end}
5016 \draw (0,0) node[nmos]{} ++(2,0) node[pmos]{} ++(2,0) node[npn]{};
5017 \ctikzset{transistors/gate thickness=2}
5018 \draw (0,-2) node[nmos]{} ++(2,0) node[pmos]{};
5019 \end{tikzpicture}
5020 \end{ctikzExample}
5021
5022 \paragraph{Rounded caps for gate and base.} You can notice that with very thick segments the drawing is quite harsh.
5023 If you prefer to use rounded caps for the lines, you can use the boolean key \IndexKey{transistors/rounded caps} (default \texttt{false}):
5024
5025 \begin{ctikzExample}
5026 \begin{tikzpicture}[]
5027 \ctikzset{transistors/.cd, thickness=6, rounded caps=true}
5028 \draw (0,-2) node[nmos](N){} ++(2,0) node[npn]{};
5029 \draw (N.C) -- ++(1,0);
5030 \end{tikzpicture}
5031 \end{ctikzExample}
5032
5033 \paragraph{Arrows.} The default position of the arrows in transistors is somewhat in the middle of the terminal; if you prefer you can move them to the end with the style key \IndexKey[transistor/arrow pos]{transistors/arrow pos=end} (the default value is \texttt{legacy}).
5034 \label{par:arrows}
5035
5036 \begin{ctikzExample}
5037 \begin{circuitikz}
5038 \ctikzset{tripoles/mos style=arrows}
5039 \ctikzset{transistors/arrow pos=end}
5040 \draw (0,0) node[npn, ](npn){};
5041 \draw (2,0) node[pnp, ](npn){};
5042 \draw (0,-2) node[nmos, ](npn){};
5043 \draw (2,-2) node[pmos, ](npn){};
5044 \end{circuitikz}
5045 \end{ctikzExample}
5046
5047 If the option \IndexKey{arrowmos} is used (or after the \IndexKey[tripoles/mos style/arrows]{}command \verb!\ctikzset{tripoles/mos style/arrows}! is given), this is the output:
5048 \begin{groupdesc}
5049 \ctikzset{tripoles/mos style/arrows}
5050 \circuitdesc{nmos}{nmos}{}
5051 \circuitdesc{pmos}{pmos}{}
5052 \circuitdesc{nmosd}{nmos depletion}{}
5053 \circuitdesc{pmosd}{pmos depletion}{}
5054 \end{groupdesc}
5055
5056 You can go back to the no-arrows mos with \IndexKey{noarrowmos} locally or with
5057 \texttt{\textbackslash ctikzset\{tripoles/mos style/no arrows\}}.
5058
5059 To draw the PMOS circle non-solid, use the option \IndexKey{emptycircle} or the command
5060 \\\verb!\ctikzset{tripoles/pmos style/emptycircle}!. To remove the dot completely (only useful if you have \texttt{arrowmos} enabled, otherwise there will be no difference between P-MOS and N-MOS), you can use the option \IndexKey{nocircle} or \verb|\ctikzset{tripoles/pmos style/nocircle}|.
5061
5062 \begin{groupdesc}
5063 \circuitdesc{pmos,emptycircle}{pmos}{}
5064 \circuitdesc{pmos,nocircle,arrowmos}{pmos}{}
5065 \end{groupdesc}
5066
5067 This example show the combined effects of the arrows and gate-circle options:
5068
5069 \begin{ctikzExample}
5070 \begin{circuitikz}[
5071 info/.style={left=1cm, blue, text width=5em, align=right},]
5072 \draw (0,1) node{pmos} (2,1) node{nmos};
5073 \draw (0,0) node[info]{default} node[pmos]{} (2,0) node[nmos]{};
5074 \ctikzset{tripoles/mos style/arrows}
5075 \draw (0,-2) node[info]{arrows} node[pmos]{} (2,-2) node[nmos]{};
5076 \ctikzset{tripoles/pmos style/emptycircle}
5077 \draw (0,-4) node[info]{emptycircle} node[pmos]{} (2,-4) node[nmos]{};
5078 \ctikzset{tripoles/pmos style/nocircle}
5079 \draw (0,-6) node[info]{nocircle} node[pmos]{} (2,-6) node[nmos]{};
5080 \ctikzset{tripoles/mos style/no arrows}
5081 \draw (0,-8) node[info, red]{no circle, no arrows, DON'T do it}
5082 node[pmos]{} (2,-8) node[nmos]{};
5083 \end{circuitikz}
5084 \end{ctikzExample}
5085
5086 You can also change\footnote{Thanks to the idea by \href{https://github.com/circuitikz/circuitikz/issues/655}{Dr. Matthias Jung on GitHub}.} the type of the arrow for the ``light rays'' of the phototransistors with the generic arrows options shown in~\ref{sec:tunablearrows}, using the name \texttt{opto}, like in the following (overdone) example. Also the \texttt{opto arrows} styling options (see section~\ref{sec:opto-arrows}).
5087
5088 \begin{ctikzExample}
5089 \begin{tikzpicture}
5090 \draw (0,2) node[npn, photo]{} ++(2,0) node[pnp, photo]{};
5091 \ctikzset{opto end arrow={Triangle[angle'=60]}}
5092 \ctikzset{opto arrows/.cd, color=red, dash={{1pt}{1pt}}}
5093 \draw (0,0) node[npn, photo]{} ++(2,0) node[pnp, photo]{};
5094 \end{tikzpicture}
5095 \end{ctikzExample}
5096
5097 \paragraph{Circles.} Since \texttt{1.2.6}, you can add a circle\footnote{Suggested by Dr. Matthias Jung \href{https://github.com/circuitikz/circuitikz/issues/442}{on GitHub}} to most of the transistor shapes --- with the exception of multi-terminal (\texttt{bjtnpn} and \texttt{bjtpnp}, where it would be awkward anyway) and graphene FETs. The circle is intended in some case as the component's housing, and used to distinguish discrete components from integrated ones.
5098 \label{par:circles}
5099
5100 To add the circle to a single transistor, you use the \IndexKey{tr circle} keys in the node; if you want all of your transistors with a circle, you can set the property \texttt{tr circle} with a \verb|\ctikzset| command (it will respect normal grouping, of course); in that case, you can use \texttt{tr circle=false} to locally disable them.
5101
5102 \begin{ctikzExample}
5103 \begin{circuitikz}[]
5104 \draw (0,2) node[npn]{} (2,2) node[npn, tr circle](Q){};
5105 % collector connected to housing
5106 \node [circ] at (Q.circle C){};
5107 \ctikzset{tr circle=true} % or \ctikzset{tr circle} alone
5108 \draw (0,0) node[nigfete]{}
5109 (2,0) node[nigfete, tr circle=false]{};
5110 \end{circuitikz}
5111 \end{ctikzExample}
5112
5113 You can tweak the appearance of transistor's circles and even draw it partially; see ~\ref{sec:trans-circle-custom} for details.
5114
5115 \paragraph{Body diodes and similar things.}\label{sec:bodydiodes-anchor} For all transistors (minus \texttt{bjtnpn} and \texttt{bjtpnp}) a body diode (or freewheeling or flyback diode) can automatically be drawn. Just use the global option \IndexKey{bodydiode}, or for single transistors, the \TikZ-option \texttt{bodydiode}.
5116 As you can see in the next example, the text for the diode is moved if a bodydiode is present (but beware, if you change a lot the relative dimension of components, it may become misplaced):
5117
5118 \begin{ctikzExample}
5119 \begin{circuitikz}
5120 \draw (0,0) node[npn,bodydiode](npn){1}
5121 ++(2,0)node[pnp,bodydiode](npn){};
5122 \draw (0,-2) node[nigbt,bodydiode](npn){2}
5123 ++(2,0)node[pigbt,bodydiode](npn){};
5124 \draw (0,-4) node[nfet,bodydiode](npn){3}
5125 ++(2,0)node[pfet,bodydiode](npn){};
5126 \end{circuitikz}
5127 \end{ctikzExample}
5128
5129 You can tweak the appearance of transistor's bodydiodes; see ~\ref{sec:trans-bodydiode-custom}.
5130
5131 For more complex snubs or protections, you can use the \IndexKey[bodydiode anchors]{body ...} anchors to add more or different things to the transistors in addition (or instead) of the flyback\IndexKey[flyback diode]{} diode.
5132
5133 \begin{ctikzExample}[dollar]
5134 \def\snubb#1#2{% add a snubber to a transistor
5135 \draw (#1.body C #2) to[short, *-, nodes width=0.02]
5136 ++(0.3,0) coordinate(tmp) to [R, resistors/scale=0.3]
5137 % 2/3 space for R, 1/3 for C
5138 ($(tmp)!0.66!(tmp|-#1.body E #2)$)
5139 to [C, capacitors/scale=0.3] (tmp|-#1.body E #2)
5140 to [short, -*, nodes width=0.02] (#1.body E #2);
5141 }
5142 \begin{circuitikz}
5143 \node[npn](Q1) at(0,0) {};
5144 \node[pnp](Q2) at(2,0) {};
5145 \node[pnp, bodydiode](Q3) at(0,-3) {};
5146 \node[npn, bodydiode](Q4) at(2,-3) {};
5147 \snubb{Q1}{in} \snubb{Q2}{in}
5148 \snubb{Q3}{out} \snubb{Q4}{out}
5149 \end{circuitikz}
5150 \end{ctikzExample}
5151
5152 \paragraph{HEMT customization.}\label{sec:hemt} Since \texttt{v1.6.1} the shape of the \texttt{hemt} transistor can be customized.\footnote{After a suggestion from \href{https://github.com/circuitikz/circuitikz/issues/691}{user \texttt{@epsilon-phi} on GitHub}.}
5153 \label{par:hemt-customization-sec}
5154 There are several keys under the hierarchy \IndexKey{tripoles/hemt} that can be use to change the appearance; some of them are common to other transistors and some are specific.
5155
5156 The main ones are \texttt{\dots/split gate} (boolean, default \texttt{false}) that will create a ``split'' gate, which sometimes is used to convey that the device is enhancement-type;
5157 \texttt{source arrow} (default \texttt{0}), to add an arrow on the source terminal (\texttt{1} for a right-facing one, \texttt{-1} the other way around; the arrow will obey \texttt{arrow pos=end} if issued, but otherwise the position is fixed);
5158 \texttt{gate asym} (default \texttt{0.0}) which displaces the gate asymmetrically. For example, the \texttt{GaN hemt} component is really a styled \texttt{hemt} (predefined), with the definition:
5159
5160 \begin{lstlisting}
5161 \tikzset{GaN hemt/.style={hemt,
5162 circuitikz/tripoles/hemt/base height=0.6,% length of the "base" vertical bar
5163 circuitikz/tripoles/hemt/gate height=0.5,% distance of the S/D terminals
5164 circuitikz/tripoles/hemt/bodydiode conn=0.85,% attachment point of body diode
5165 circuitikz/tripoles/hemt/gate asym=-0.1,% slightly down
5166 circuitikz/tripoles/hemt/split gate=true,% split gate
5167 circuitikz/tripoles/hemt/source arrow=1,% right-facing arrow
5168 },
5169 }
5170 \end{lstlisting}
5171
5172 \begin{ctikzExample}
5173 \begin{circuitikz}[]
5174 \path (-1,-1) rectangle (3,3);% bounding box
5175 \node [hemt] at (0,2) {A};
5176 \node [hemt,
5177 circuitikz/tripoles/hemt/split gate=true
5178 ] at (2,2) {B};
5179 \node [GaN hemt] at (0,0) {C};
5180 \node [GaN hemt,
5181 circuitikz/tripoles/hemt/split gate=false
5182 ] at (2,0) {D};
5183 \end{circuitikz}
5184 \end{ctikzExample}
5185
5186 \paragraph{Schottky transistors.}
5187 \label{par:schottky-transistors}
5188 The Schottky transistors are generated by adding the \IndexKey{schottky base} key (there is also a \IndexKey{no schottky base} key that can be used if you use the other one as a default).
5189 You can change the size of the Schottky ``hook'' changing the parameter \IndexKey{tripoles/schottky base size} with \verb|\ctikzset{}| (default \texttt{\ctikzvalof{tripoles/schottky base size}}; the unit is the standard resistor length, scaled if needed.)
5190
5191 \begin{ctikzExample}
5192 \begin{circuitikz}
5193 \draw (0,4) node[npn]{}
5194 ++(2,0) node[npn, schottky base]{};
5195 \draw (1,2) node[bjtnpn, collectors=2, emitters=3,
5196 schottky base, rotate=90]{};
5197 \tikzset{schottky base}
5198 \ctikzset{tripoles/schottky base size=0.1}
5199 \draw (0,0) node[pnp]{}
5200 ++(2,0) node[npn, no schottky base]{};
5201 \end{circuitikz}
5202 \end{ctikzExample}
5203
5204 \paragraph{Ferroelectric transistors} You can add the \IndexKey{ferroel} ferroelectric modifier\footnote{suggested by \href{https://github.com/circuitikz/circuitikz/issues/515}{Mayeul Cantan}} to the \texttt{*mos} and \texttt{*fet} transistor types. Similarly to the Schottky bipolar transistors, you activate it by adding the \IndexKey{ferroel gate} key (there is also a \IndexKey{no ferroel base} key that can be used if you use the other one as a default).
5205 \label{par:ferroelectric-transistors}
5206
5207 The mark will follow the \texttt{transistors} class thickness, but you can adjust it independently using the class parameter \IndexKey{modifier thickness} as in passive components --- this value is relative to the class' thickness.
5208
5209 \begin{ctikzExample}
5210 \begin{circuitikz}
5211 \draw (0,2) node[nmos]{}
5212 ++(2,0) node[nmos, ferroel gate]{};
5213 \ctikzset{ferroel gate} % by default from now on
5214 \ctikzset{transistors/.cd, % class properties
5215 thickness=1, modifier thickness=3}
5216 \draw (0,0) node[pfet]{}
5217 ++(2,0) node[pfet, no ferroel gate]{};
5218 \end{circuitikz}
5219 \end{ctikzExample}
5220
5221
5222 \paragraph{IGBT outer base.}
5223 \label{par:igbt-outer-base}
5224 Normally, in bipolar IGBTs the outer base is the same size (height) of the inner one, and of the same thickness (which will depend on the class thickness value). You can change this by setting (via \verb|\ctikzset|) the keys \IndexKey{tripoles/igbt/outer base height} (default \texttt{0.4}, the same as \texttt{base height}), and \IndexKey{tripoles/igbt/outer base thickness} (default \texttt{1.0}), which will be relative to the class thickness.
5225
5226 \begin{ctikzExample}[varwidth=true, pos=t]
5227 \begin{circuitikz}
5228 \draw (0,0)
5229 -- ++(1,0) node[nigbt, anchor=B](B){} (B.nobase)
5230 -- ++(1,0) node[pigbt, anchor=B](B){} (B.nobase)
5231 -- ++(1,0) node[Lnigbt, anchor=B](B){} (B.nobase)
5232 -- ++(1,0) node[Lpigbt, anchor=B](B){} (B.nobase)
5233 ;
5234 \ctikzset{tripoles/igbt/outer base height=0.3}
5235 \ctikzset{tripoles/igbt/outer base thickness=1.5}
5236 \draw (6,0)
5237 -- ++(1,0) node[nigbt, anchor=B](B){} (B.nobase)
5238 -- ++(1,0) node[pigbt, anchor=B](B){} (B.nobase)
5239 -- ++(1,0) node[Lnigbt, anchor=B](B){} (B.nobase)
5240 -- ++(1,0) node[Lpigbt, anchor=B](B){} (B.nobase)
5241 ;
5242 \end{circuitikz}
5243 \end{ctikzExample}
5244
5245 \paragraph{UJT transistors.}\label{sec:ujt} They look better if you use \texttt{transistors/arrow pos=end}, especially if you use them with \texttt{tr circle}. If you use the key \texttt{nobase} with UJTs, the horizontal part of the controlling terminal is not drawn; notice that this \emph{will} move the \texttt{E} or \texttt{emitter} anchor, but not the generic ones like \texttt{G}.
5246
5247 \begin{ctikzExample}[basicstyle=\footnotesize\ttfamily]
5248 \begin{circuitikz}[scale=0.8]
5249 \draw (0,5) node[nujt]{} ++(2,0) node[pujt]{}
5250 ++(2,0) node[nujt, tr circle]{} ++(2,0)
5251 node[pujt, tr circle]{};
5252 \ctikzset{transistors/arrow pos=end}
5253 \draw (0,2.5) node[nujt](A){} ++(2,0) node[pujt]{}
5254 ++(2,0) node[nujt, tr circle]{} ++(2,0)
5255 node[pujt, tr circle](C){};
5256 \draw (0,0) node[nujt, nobase](B){} ++(2,0)
5257 node[pujt, nobase]{} ++(2,0)
5258 node[nujt, tr circle, nobase]{} ++(2,0)
5259 node[pujt, tr circle, nobase](D){};
5260 % "E" anchor follows the nobase option:
5261 \draw[red] (A.E) |- (B.E) (C.E) |- (D.E);
5262 \end{circuitikz}
5263 \end{ctikzExample}
5264
5265 \paragraph{Base/Gate terminal.} The Base/Gate connection of all transistors can be disabled by the options \textit{nogate} or \textit{nobase}, respectively. The Base/Gate anchors are floating, but there is an additional anchor \IndexKey{nogate}/\IndexKey{nobase}, which can be used to point to the unconnected base:
5266 \label{par:base-gate-terminal}
5267 \begin{ctikzExample}
5268 \begin{circuitikz}
5269 \draw (2,0) node[npn,nobase](npn){};
5270 \draw (npn.E) node[below]{E};
5271 \draw (npn.C) node[above]{C};
5272 \draw (npn.B) node[circ]{} node[left]{B};
5273 \draw[dashed,red,-latex] (1,0.5)--(npn.nobase);
5274 \end{circuitikz}
5275 \end{ctikzExample}
5276
5277 \paragraph{Bulk terminals.} You can add a bulk terminal\footnote{Thanks to Burak Kelleci <[email protected]>.} to \texttt{nmos} and \texttt{pmos} using the key \IndexKey{bulk} in the node (and \IndexKey{nobulk} if you set the bulk terminal by default); additional anchors \texttt{bulk} and \texttt{nobulk} are added (in the next example, \texttt{tripoles/mos style/arrows} is enacted, too):
5278 \label{par:bulk-terminals}
5279
5280 \begin{groupdesc}
5281 \ctikzset{tripoles/mos style/arrows}
5282 \circuitdesc{nmos, bulk}{nmos}{}(bulk/45/0.3, nobulk/-30/.4)
5283 \circuitdesc{pmos, bulk}{pmos}{}
5284 \circuitdesc{nmosd, bulk}{nmos depletion}{}(bulk/45/0.3, nobulk/-30/.4)
5285 \circuitdesc{pmosd, bulk}{pmos depletion}{}
5286 \end{groupdesc}
5287
5288 When adding the bulk connection, since \texttt{v1.8.1}, you can also add FDSOI-type back gates.
5289 In this case, there are two possible shapes for the back gate, as seen in literature.
5290 One is the one seen for the full symbol above, and the other one is a dot, which is activated by the \IndexKey{fdsoidot} flag.
5291
5292 \begin{groupdesc}
5293 \ctikzset{tripoles/mos style/arrows}
5294 \circuitdesc{nmos, bulk, fdsoi}{nmos, FDSOI back gate}{}(bulk/45/0.3, nobulk/-30/.4)
5295 \circuitdesc{pmos, bulk, fdsoidot}{pmos, FDSOI back gate (dot-style)}{}
5296 \circuitdesc{nmosd, bulk, fdsoidot}{nmos depletion, FDSOI back gate (dot-style)}{}(bulk/45/0.3, nobulk/-30/.4)
5297 \circuitdesc{pmosd, bulk, fdsoi}{pmos depletion, FDSOI back gate}{}
5298 \end{groupdesc}
5299
5300 Also, IGBTs have anchors to access the ``bulk'' equivalent connections.
5301
5302 \begin{groupdesc}
5303 \circuitdesc{nigbt}{nigbt}{}(nobase/135/0.3, nobulk/-30/.4)
5304 \circuitdesc{pigbt, nobase}{pigbt with no base terminal\footnotemark}{}(nobase/135/0.3, nobulk/-30/.4)
5305 \footnotetext{Since \texttt{v1.4.4}, noticed by \href{https://tex.stackexchange.com/q/619334/38080}{user \texttt{hinata exc} on Stack Exchange}.}
5306 \end{groupdesc}
5307
5308
5309 \paragraph{Solder dots.}\label{sec:solderdot-scale}
5310 Solder dots are scaled-down\footnote{Since \texttt{v1.6.3}, suggested by \href{https://tex.stackexchange.com/q/687225/38080}{user Hartomes on TeX StackExchange}; previously, the default scale was \texttt{1.0}, which created a clash with body diodes.} version of the normal \texttt{circ} connection dot (\emph{pole}).
5311 This is to convey the information that the connection is \emph{internal} to the device, and not controllable from the outside. By default, they are scaled as the bodydiode connection dots (see section~\ref{sec:trans-bodydiode-custom}), but you can change them with the command\IndexKey[transistor solderdot scale]{} \texttt{\textbackslash ctikzset\{transistor solderdot scale=\emph{x}\}}, where $x$ is the scale with respect to the normal \texttt{circ} node (default: \texttt{0.7}).
5312
5313 \begin{ctikzExample}
5314 \begin{tikzpicture}[]
5315 \draw (0,0) to[short,*-] ++(.1,0)
5316 node[nigfete, solderdot, anchor=G]{};
5317 \ctikzset{transistor solderdot scale=1}
5318 \draw (2,0) to[short,*-] ++(.1,0)
5319 node[nigfete, solderdot, anchor=G]{};
5320 \end{tikzpicture}
5321 \end{ctikzExample}
5322
5323 \paragraph{Simplified symbols for depletion-mode MOSFETs}.
5324 \label{par:simplified-symbols-for}
5325 The \texttt{nmosd}, \texttt{pmosd} (symplified) symbols for depletion-mode MOSFET (introduced in \texttt{1.2.4}) behave exactly like the normal (without the final \texttt{d}) ones.
5326
5327 By default, the thick bar (indicating the pre-formed channel) is filled with the same color as the drawing:
5328 \begin{ctikzExample}
5329 \begin{circuitikz}[ ]
5330 \draw (0,2) to[R] ++(2,0) node[nmosd, anchor=G]{};
5331 \draw[color=red] (0,0) to[R] ++(2,0) node[pmosd, anchor=G]{};
5332 \end{circuitikz}
5333 \end{ctikzExample}
5334
5335 You can change this behavior by setting the key
5336 \IndexKey{tripoles/nmosd/depletion color} (default value \texttt{default}, which means ``use the draw color'') to the color you want; using \texttt{none} will lead to an unfilled channel (note that in this case the color does not change automatically with the path!):
5337 \begin{ctikzExample}
5338 \begin{circuitikz}[ ]
5339 \ctikzset{tripoles/nmosd/depletion color=gray}
5340 \draw (0,2) to[R] ++(2,0) node[nmosd, anchor=G]{};
5341 \ctikzset{tripoles/pmosd/depletion color=none}
5342 \draw[color=red] (0,0) to[R] ++(2,0)
5343 node[pmosd, anchor=G]{};
5344 \ctikzset{tripoles/pmosd/depletion color=
5345 {cyan!50!white}}
5346 \draw[color=blue] (0,-2) to[R] ++(2,0)
5347 node[pmosd, anchor=G, bulk]{};
5348 \end{circuitikz}
5349 \end{ctikzExample}
5350
5351
5352 Obviously you have the equivalent \IndexKey{tripoles/pmosd/depletion color} for type-P transistors.
5353
5354 They also have path-style syntax, as the other transistors.
5355
5356 \begin{ctikzExample}
5357 \begin{circuitikz}[ ]
5358 \draw (0,0) to[Tnmosd] ++(2,0)
5359 to[Tpmosd, invert] ++(0,-2)
5360 ;
5361 \end{circuitikz}
5362 \end{ctikzExample}
5363
5364 \paragraph{JFET gate position.} Since version \texttt{1.8.6}\footnote{the change was triggered by the question by user Vector on \href{https://tex.stackexchange.com/q/762783/38080}{TeX StackExchange}.}, you can change the vertical position of the gate terminal in the junction transistor \texttt{njfet} and \texttt{pjfet} using the key \IndexKey{transistors/jfet gate height} (default \texttt{1.0}, which means that the gate arrow is at the same height as the source terminal).
5365 In the following example you can see its use and effect (notice that when it is set to zero, there is complete symmetry between drain and source terminal; this is physically right for ideal/simplified devices, but not always for real ones).
5366
5367 \begin{ctikzExample}
5368 \begin{tikzpicture}
5369 \ctikzset{transistors/arrow pos=end}
5370 \tikzset{jfet pos/.style={
5371 circuitikz/transistors/jfet gate height=#1}}
5372 \draw (0,0) node[njfet]{}
5373 ++(2,0) node[njfet, jfet pos=0.5]{}
5374 ++(2,0) node[njfet, jfet pos=0]{};
5375 \end{tikzpicture}
5376 \end{ctikzExample}
5377
5378 \paragraph{Gate/Base gap coloring.} You can color the space representing the gate capacitor or the insulated base by using the key \IndexKey{tr gap fill} (default \texttt{none}, which means nothing is drawn there). This fill is done \emph{after} any circle fill but before any additional modifier (see the example below). You can use it locally or set it globally (normal scoping works, as ever).
5379 \label{par:gate-base-gap}
5380
5381 \begin{ctikzExample}
5382 \begin{tikzpicture}
5383 \node[nigfete, tr gap fill=green] at(0,0){};
5384 \node[nigfete, tr gap fill=red, tr circle,
5385 fill=cyan!30] at(1.5,0){};
5386 \node[nmos, tr gap fill=cyan, ferroel gate](A)
5387 at(3,0){};
5388 \end{tikzpicture}
5389 \end{ctikzExample}
5390
5391 \subsubsection{Multiple terminal transistors customization}
5392 \label{sec:multiple-terminal-transistors}
5393
5394 You can create completely ``bare'' transistors (without the connection leads to the \texttt{B}, \texttt{C} y \texttt{E} terminals), by changing the parameter \IndexKey{tripoles/bjt/pins width} (default \texttt{0.3}; it is expressed as a fraction of the basic (scaled) length) or using the style \IndexKey{bjt pins width}; and you can change the distance between multiple collectors/emitters setting with \verb|\ctikzset{}| the parameter \IndexKey{tripoles/bjt/multi height} (default \texttt{0.5}) or the style \IndexKey{bjt multi height}.
5395
5396 \begin{groupdesc}
5397 \circuitdesc{bjtnpn, collectors=2, emitters=2, bjt pins width=0, bjt multi height=0.8}{bjt npn with parameters}{Q}(B/180/0.2, C/45/0.2, E/-45/0.2, C1/0/0.4, C2/0/0.4, E1/0/0.4, E2/0/0.4, nobase/-135/0.4, cbase/135/0.4)
5398 \end{groupdesc}
5399
5400
5401 \subsubsection{Transistor circle customization}\label{sec:trans-circle-custom}
5402
5403 \paragraph{Position and size.} You can see in the following diagram where the circle is positioned --- when there is no bodydiode, it will pass through the anchors for the body diode and near the base connection. The dimension of the circle is bigger when the bodydiode is in, to encompass it.
5404 \label{par:position-and-size}
5405 The anchors are present even if there is no circle, so you can use them to draw different kinds of circles (say, encompassing two transistors) in a coherent way.
5406
5407 \circuitdesc{npn, tr circle}{npn with a circle}{}(circle base/90/0.5, circle C/30/0.2, circle E/-30/0.2, circle center/0/0.5)
5408 \circuitdesc{npn, tr circle, bodydiode}{npn with a circle}{}(circle base/90/0.6, circle C/30/0.2, circle E/-30/0.2, circle center/0/0.5 )
5409
5410 The position of the circle on collector and emitter by default is the one shown above; the position along the base can be adjusted in most transistors using the \verb|\ctikzset| parameter \IndexKey{transistor circle/default base in} (by default \texttt{\ctikzvalof{transistor circle/default base in}}); \texttt{njfet} and \texttt{pjfet} use \texttt{transistor circle/njfet base in} (default \texttt{\ctikzvalof{transistor circle/njfet base in}}; the same for \texttt{pjfet}) and, finally, \texttt{isfet} uses \texttt{transistor circle/isfet base in} (default \texttt{\ctikzvalof{transistor circle/isfet base in}}). You can change the resulting size of the circle by setting to something different to \texttt{1.0} the parameter \IndexKey{transistor circle/scale circle radius} --- that will move the anchors too; for example:
5411
5412 \begin{ctikzExample}
5413 \begin{circuitikz}[scale=1.5, transform shape]
5414 \draw (0,0) node[npn, tr circle](Q1){};
5415 \node [circ] at (Q1.circle C){};
5416 \ctikzset{transistor circle/scale circle radius=1.2}
5417 \draw[color=red] (0,0) node[npn, tr circle](Q2){};
5418 \node [circ, color=red] at (Q2.circle C){};
5419 \end{circuitikz}
5420 \end{ctikzExample}
5421
5422 \paragraph{Line and color.} Normally the circle follows the style of the component --- the line thickness is fixed by the class element \texttt{transistors/thickness} and the color is the same as the component color. You can change, if you need, all of these things using the parameters of the following table (the parameters are under the \verb|\ctikzset| category root \IndexKey{transistor circle/}.
5423 \label{par:line-and-color}
5424
5425 \begin{center}
5426 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{8cm}}
5427 \toprule
5428 parameter & default & description \\
5429 \midrule
5430 relative thickness & 1.0 & multiply the class thickness \\
5431 color & default & stroke color: \texttt{default} is the same as the component \\
5432 dash & default & dash pattern: none means solid line, default means keep the global pattern\footnotemark \\
5433 partial borders & none & draw only part of the circle border: none means draw all \\
5434 partial border dash & \{\{2pt\}\{2pt\}\} & dash pattern used in partial borders \\
5435 \bottomrule
5436 \end{tabular}
5437 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
5438 \end{center}
5439
5440 \begin{ctikzExample}
5441 \begin{circuitikz}[]
5442 \draw (0,2) node[npn, tr circle](Q1){};
5443 \ctikzset{transistor circle/relative thickness=2}
5444 \draw (2,2) node[npn, tr circle](Q1){};
5445 \ctikzset{transistor circle/color=red}
5446 \draw (0,0) node[npn, tr circle](Q1){};
5447 \ctikzset{transistor circle/color=default}
5448 \ctikzset{transistor circle/dash={{4pt}{4pt}{1pt}{4pt}}}
5449 \draw[color=blue] (2,0) node[npn, tr circle](Q1){};
5450 \end{circuitikz}
5451 \end{ctikzExample}
5452
5453 Finally, using the class style you can do quite interesting things.
5454
5455 \begin{ctikzExample}
5456 \begin{circuitikz}[]
5457 \ctikzset{transistors/thickness=4, transistors/fill=cyan!30,
5458 transistor circle/relative thickness=0.25,}
5459 \draw (0,0) node[npn, tr circle](Q1){};
5460 \ctikzset{transistor circle/dash={{2pt}{2pt}}}
5461 \draw (1.5,0) node[npn, tr circle, xscale=-1](Q2){};
5462 \end{circuitikz}
5463 \end{ctikzExample}
5464
5465 \paragraph{Partially drawn circle borders}
5466 \label{par:partially-drawn-circle}
5467
5468 In some circuits, transistors are drawn with partial or dashed border (to convey the meaning of several active components encased in the same physical package, or to signify thermal contact). To achieve this effect, you can use the \IndexKey{transistor circle/partial border}\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/602}{Jether Fernandes Reis} for tubes, implemented by Romano in \texttt{v1.5.2}.} key (default \texttt{none}). This key can be set to \texttt{none}, or must be a sequence of \textbf{exactly} 4 numbers, that can have value \texttt{0}, \texttt{1}, or \texttt{2}. Each number defines the style of a part of the border to be not drawn, solid or dashed respectively.
5469
5470 The part of the border are numbered from 1 to 4 as shown below:
5471 \begin{quote}
5472 \begin{circuitikz}[circuitikz/transistors/fill=cyan!20,
5473 circuitikz/transistor circle/partial borders=1212]
5474 \draw (0,0) node[npn, tr circle](T){};
5475 \draw[red, font=\ttfamily\small\bfseries]
5476 ([shift={(.3,-.2)}]T.north east) node{1}
5477 ([shift={(.3,.2)}]T.south east) node{2}
5478 ([shift={(.2,.2)}]T.south west) node{3}
5479 ([shift={(.2,-.2)}]T.north west) node{4}
5480 ;
5481 \end{circuitikz}
5482 \end{quote}
5483 The dashed line pattern can be changed by setting the key \IndexKey{transistor circle/partial border dash} (default \verb|{{2pt}{2pt}}|). Be careful with the extra set of braces here.
5484
5485 \begin{ctikzExample}
5486 \begin{circuitikz}[]
5487 \ctikzset{transistors/thickness=4, transistors/fill=cyan!30,
5488 transistor circle/relative thickness=0.25,
5489 transistor circle/partial borders=2211}
5490 \draw (0,0) node[npn, tr circle](Q1){};
5491 \ctikzset{transistor circle/dash={{2pt}{2pt}}}
5492 \draw (1.5,0) node[npn, tr circle, xscale=-1](Q2){};
5493 \end{circuitikz}
5494 \end{ctikzExample}
5495
5496 \begin{ctikzExample}
5497 \begin{circuitikz}[]
5498 \ctikzset{transistors/thickness=4, transistors/fill=cyan!30,
5499 transistor circle/relative thickness=0.25,
5500 transistor circle/partial borders=0011}
5501 \draw (0,0) node[npn, tr circle](Q1){};
5502 \ctikzset{transistor circle/dash={{2pt}{2pt}}}
5503 \draw (1.5,0) node[npn, tr circle, xscale=-1](Q2){};
5504 \draw[dashed] (Q1.circle top) -- (Q2.circle top);
5505 \draw[dashed] (Q1.circle bottom) -- (Q2.circle bottom);
5506 \end{circuitikz}
5507 \end{ctikzExample}
5508
5509 \subsubsection{Transistor bodydiode customization}\label{sec:trans-bodydiode-custom}
5510
5511 You can change the style of the bodydiode\footnote{Suggested by \href{https://tex.stackexchange.com/questions/653348/drawing-mosfet-bodydiode-dashed}{user Alex Ghilas on TeX.SX}, implemented in \texttt{v1.5.4}; \texttt{scale} suggested by \href{https://github.com/circuitikz/circuitikz/issues/703}{user \texttt{@sputeanus} on GitHub} and added in version \texttt{1.6.2}.} in a similar way to the one used for circles (albeit with less options), by setting keys with the \verb!\ctikzset! command (or, like in the following example, directly in the node instantiation) under the \IndexKey{transistor bodydiode/} hierarchy. The available keys are:
5512
5513 \begin{center}
5514 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{0.5\linewidth}}
5515 \toprule
5516 parameter & default & description \\
5517 \midrule
5518 relative thickness & 1.0 & multiply the class thickness \\
5519 color & default & stroke color: \texttt{default} is the same as the component \\
5520 dash & default & dash pattern: \texttt{default} means not to change the setting for the component; \texttt{none} means unbroken line; every other input is a dash pattern\footnotemark \\
5521 scale & 0.3 & scale of the diode, with respect to the basic (not scaled) diode dimension.\\
5522 dot scale & 0.7 & scale of bodydiode connections dots, with respect to the \texttt{circ} pole. Use zero to remove them (useful if you have circles around the transistor).\\
5523 \bottomrule
5524 \end{tabular}
5525 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
5526 \end{center}
5527
5528 The following is a quite extensive example. Obviously, a good strategy in this case is to define styles for the options, or, better, set the option in your style file or in the preamble (for coherency).
5529
5530 \begin{ctikzExample}[varwidth=true, pos=t]
5531 \begin{tikzpicture}[red solid thin bodydiode/.style={bodydiode,
5532 circuitikz/transistor bodydiode/dash=none,
5533 circuitikz/transistor bodydiode/color=red,
5534 circuitikz/transistor bodydiode/relative thickness=0.3}]
5535 \draw (0,0) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_1$};
5536 \draw[densely dashed] (3,0) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_2$};
5537 \draw (6,0) node (mosfet1) [nigfete,anchor=D,bodydiode, tr circle,
5538 circuitikz/transistor bodydiode/color=gray,
5539 circuitikz/transistor bodydiode/scale=0.2,
5540 circuitikz/transistor bodydiode/dot scale=0] {$Q_3$};
5541 \draw (0,-2) node (mosfet1) [nigfete,anchor=D,bodydiode,
5542 circuitikz/transistor bodydiode/dash={{2pt}{1pt}}] {$Q_4$};
5543 \draw[densely dashed] (3,-2) node (mosfet1) [nigfete,anchor=D,
5544 red solid thin bodydiode] {$Q_5$};
5545 \ctikzset{transistor bodydiode/relative thickness=.5,
5546 transistor bodydiode/scale=0.6}% from now on, in scope
5547 \draw[densely dotted] (6,-2) node (mosfet1) [nigfete,anchor=D,bodydiode,
5548 circuitikz/transistor bodydiode/dash=none,
5549 circuitikz/transistor bodydiode/dot scale=1] {$Q_6$};
5550 \path (7,0); %% adjust bounding box (node text is outside it!)
5551 \end{tikzpicture}
5552 \end{ctikzExample}
5553
5554 \subsubsection{Transistors anchors}
5555 \label{sec:transistors-anchors}
5556
5557 For \textsc{nmos}, \textsc{pmos}, \textsc{nfet}, \textsc{nigfete}, \textsc{nigfetd}, \textsc{pfet}, \textsc{pigfete}, and \textsc{pigfetd} transistors one has \texttt{base}, \texttt{gate}, \texttt{source} and \texttt{drain} anchors (which can be abbreviated with \texttt{B}, \texttt{G}, \texttt{S} and \texttt{D}):
5558
5559 \begin{ctikzExample}
5560 \begin{circuitikz} \draw
5561 (0,0) node[nmos] (mos) {}
5562 (mos.gate) node[anchor=east] {G}
5563 (mos.drain) node[anchor=south] {D}
5564 (mos.source) node[anchor=north] {S}
5565 ;\end{circuitikz}
5566 \end{ctikzExample}
5567
5568 \begin{ctikzExample}
5569 \begin{circuitikz} \draw
5570 (0,0) node[pigfete] (pigfete) {}
5571 (pigfete.G) node[anchor=east] {G}
5572 (pigfete.D) node[anchor=north] {D}
5573 (pigfete.S) node[anchor=south] {S}
5574 (pigfete.bulk) node[anchor=west] {Bulk}
5575 ;\end{circuitikz}
5576 \end{ctikzExample}
5577
5578 Similarly \textsc{njfet} and \textsc{pjfet} have \texttt{gate}, \texttt{source} and \texttt{drain} anchors (which can be abbreviated with \texttt{G}, \texttt{S} and \texttt{D}):
5579
5580 \begin{ctikzExample}
5581 \begin{circuitikz} \draw
5582 (0,0) node[pjfet] (pjfet) {}
5583 (pjfet.G) node[anchor=east] {G}
5584 (pjfet.D) node[anchor=north] {D}
5585 (pjfet.S) node[anchor=south] {S}
5586 ;\end{circuitikz}
5587 \end{ctikzExample}
5588
5589 For \textsc{npn}, \textsc{pnp}, \textsc{nigbt} and \textsc{pigbt} transistors, the anchors are \texttt{base}, \texttt{emitter} and \texttt{collector} anchors (which can be abbreviated with \texttt{B}, \texttt{E} and \texttt{C}):
5590
5591 \begin{ctikzExample}
5592 \begin{circuitikz} \draw
5593 (0,0) node[npn] (npn) {}
5594 (npn.base) node[anchor=east] {B}
5595 (npn.collector) node[anchor=south] {C}
5596 (npn.emitter) node[anchor=north] {E}
5597 ;\end{circuitikz}
5598 \end{ctikzExample}
5599
5600 \begin{ctikzExample}
5601 \begin{circuitikz} \draw
5602 (0,0) node[pigbt] (pigbt) {}
5603 (pigbt.B) node[anchor=east] {B}
5604 (pigbt.C) node[anchor=north] {C}
5605 (pigbt.E) node[anchor=south] {E}
5606 ;\end{circuitikz}
5607 \end{ctikzExample}
5608
5609
5610 Notice that the geographical anchors of transistors are \emph{not} affected by either the bodydiode and the circle options; the label text is also outside of them. This is to permit aligning the components independently from those features. On the other hand, this can sometimes create problems because that element is outside the bounding box automatically calculated by \TikZ{}.
5611
5612 The exception is the \texttt{right} anchor which, when a circle is present, indicates the edge of the circle itself (since \texttt{v1.3.2})
5613
5614 {\geolrcoord{npn} \geolrcoord{npn, bodydiode} \geolrcoord{npn, bodydiode, tr circle}}
5615
5616
5617 All transistors, except the multi-terminal \texttt{bjtnpn} and \texttt{bjtpnp}, (since \texttt{0.9.6}) have internal nodes on the terminal corners, called \texttt{inner up} and \texttt{inner down}; you do not normally need them, but they are here for special applications:
5618
5619 \begin{ctikzExample}
5620 \begin{circuitikz}
5621 \node [npn](A) at(0,2) {};
5622 \node [pmos](B) at(0,0) {};
5623 \foreach \e in {A, B}
5624 \foreach \a in {inner up, inner down} {
5625 \node[red, circle, inner sep=1pt, draw]
5626 at (\e.\a) {};
5627 \node [right, font=\tiny, blue]
5628 at (\e.\a) {\a};
5629 }
5630 \end{circuitikz}
5631 \end{ctikzExample}
5632
5633 Additionally, you can access the position for the flyback diodes and possibly \IndexKey[snubbers]{}snubbers as shown in~\ref{sec:bodydiodes-anchor}.
5634
5635 \begin{quote}
5636 \showanchors{npn}{}(body C in/45/0.4, body E in/-45/0.4, body C out/0/0.4, body E out/0/0.4)
5637 \showanchors{npn, bodydiode}{}(body C in/45/0.4, body E in/-45/0.4, body C out/0/0.4, body E out/0/0.4)
5638 \showanchors{pnp}{}(body C in/-45/0.4, body E in/45/0.4, body C out/0/0.4, body E out/0/0.4)
5639 \end{quote}
5640
5641 Transistor circles also have several anchors on them:
5642 \begin{quote}
5643 \showanchors{npn, tr circle}{}(circle center/-135/0.6, circle top/90/0.3, circle left/180/0.2, circle right/0/0.2, circle bottom/-90/0.3, circle C/45/0.2, circle E/-45/0.2)
5644 \showanchors{pigfete, bodydiode, tr circle}{}(circle center/-135/0.6, circle top/90/0.3, circle left/180/0.2, circle right/0/0.2, circle bottom/-90/0.3, circle C/-45/0.2, circle E/45/0.2)
5645 \end{quote}
5646
5647 The multi-terminal transistors have all the geographical anchors; note though that the \texttt{center} anchor is not the geometrical center of the component, but the logical one (at the same height as the base).
5648 The additional anchors \IndexKey{vcenter} (vertical geometric center of the collector--emitter zone) and \IndexKey{gcenter} (graphical center) are provided, as shown in the following picture. They have no bodydiode anchors nor \texttt{inner \emph{up/down}} ones.
5649
5650 \begin{quote}
5651 \geocoord{bjtnpn, collectors=1, emitters=2}
5652 \showanchors{bjtpnp, collectors=4, emitters=1, bjt pins width=0.6}{}(north/90/0.4, east/0/0.4, south/-90/0.4, west/180/0.4, center/120/0.3, vcenter/0/0.4, gcenter/-120/0.4, cbase/-60/0.6)
5653 \end{quote}
5654
5655 A complete example of multiple terminal transistor application is the following PNP double current mirror circuit.
5656
5657 \begin{ctikzExample}
5658 \begin{circuitikz}
5659 \ctikzset{transistors/arrow pos=end}
5660 \draw (0,0) node[bjtpnp, xscale=-1](Q1){%
5661 \scalebox{-1}[1]{Q1}};
5662 \draw (Q1.B) node[bjtpnp, anchor=B, collectors=2]
5663 (Q2){Q2} (Q1.B) node[circ]{};
5664 \draw (Q1.E) node[circ]{} node[vcc]{} (Q2.E)
5665 node[vcc]{} (Q1.E) -| (Q1.B);
5666 \draw (Q1.C) to[R, l_=$R_0$, f=$I_0$] ++(0,-3.5)
5667 node[ground](GND){};
5668 \draw (Q2.C) -- ++(0,-0.5) coordinate(a);
5669 \draw (Q2.C1) -- ++(1,0) coordinate(b) -- (b|-a);
5670 \draw (a) ++(0,-0.1) node[flowarrow, rotate=-90,
5671 anchor=west]{\rotatebox{90}{$I_0$}};
5672 \draw (b|-a) ++(0,-0.1) node[flowarrow, rotate=-90,
5673 anchor=west]{\rotatebox{90}{$I_0$}};
5674 \path (b) ++(0.5,0); % bounding box adjust
5675 \end{circuitikz}
5676 \end{ctikzExample}
5677
5678
5679 Here is one composite example (please notice that the \texttt{xscale=-1} style would also reflect the label of the transistors, so here a new node is added and its text is used, instead of that of \texttt{pnp1}):
5680
5681 \begin{ctikzExample}
5682 \begin{circuitikz} []\draw
5683 (0,0) node[pnp] (pnp2) {Q2}
5684 (pnp2.B) node[pnp, xscale=-1, anchor=B] (pnp1) {}
5685 (pnp1) node[left, inner sep=0pt] {Q1}
5686 (pnp1.C) node[npn, anchor=C] (npn1) {Q3}
5687 (pnp2.C) node[npn, xscale=-1, anchor=C] (npn2)
5688 {\scalebox{-1}[1]{Q4}}
5689 (pnp1.E) -- (pnp2.E) (npn1.E) -- (npn2.E)
5690 (pnp1.B) node[circ] {} |- (pnp2.C) node[circ] {}
5691 ;\end{circuitikz}
5692 \end{ctikzExample}
5693
5694 Notice that the text labels of transistors are outside the bounding box of the component (that is, the set of geographical anchors). If it is a problem, use a separate text node to set the transistor's label.
5695 Of course, transistors like other components can be reflected vertically:
5696
5697 \begin{ctikzExample}
5698 \begin{circuitikz} \draw
5699 (0,0) node[pigfete, yscale=-1] (pigfete) {}
5700 (pigfete.bulk) node[anchor=west] {Bulk}
5701 (pigfete.G) node[anchor=east] {G}
5702 (pigfete.D) node[anchor=south] {D}
5703 (pigfete.S) node[anchor=north] {S}
5704 ;\end{circuitikz}
5705 \end{ctikzExample}
5706
5707 Finally, double-gated components (MOSes, FETs, IGBTs) have an extra anchor \IndexKey{centergap} positioned in the middle of the ``gate capacitor'' or base.
5708 \begin{ctikzExample}
5709 \begin{circuitikz}
5710 \node [nmos](A) at (0,3) {};
5711 \node [nfet](B) at (0,1.5) {};
5712 \node [pigbt](C) at (0,0) {};
5713 \foreach \myn in {A, B, C}
5714 \draw[color=red] (\myn.centergap)
5715 node[ocirc]{} -- ++(1,0)
5716 node[right, font=\tiny]{centergap};
5717 \end{circuitikz}
5718 \end{ctikzExample}
5719
5720 For UJT transistors anchors, see section~\ref{sec:ujt}.
5721
5722
5723 \subsubsection{Transistor paths}\label{sec:transasbip}
5724
5725 For syntactical convenience standard transistors (not multi-terminal ones) can be placed using the normal path notation used for bipoles. The transistor type can be specified by simply adding a ``T'' (for transistor) in front of the node name of the transistor. It will be placed with the base/gate orthogonal to the direction of the path:
5726
5727 \begin{ctikzExample}
5728 \begin{circuitikz} \draw
5729 (0,0) node[njfet] {1}
5730 (-1,2) to[Tnjfet=2] (1,2)
5731 to[Tnjfet=3, mirror] (3,2)
5732 ;\end{circuitikz}
5733 \end{ctikzExample}
5734
5735 Access to the gate and/or base nodes can be gained by naming the transistors with the \texttt{n} or \IndexKey{name} path style:
5736 \begin{ctikzExample}
5737 \begin{circuitikz} \draw[yscale=1.1, xscale=.8]
5738 (2,4.5) -- (0,4.5) to[Tpmos=p1, n=p1] (0,3)
5739 to[Tnmos=n1, n=n1] (0,1.5)
5740 to[Tnmos=n2, n=n2] (0,0) node[ground] {}
5741 (2,4.5) to[Tpmos=p2,n=p2] (2,3) to[short, -*] (0,3)
5742 (p1.G) -- (n1.G) to[short, *-o] ($(n1.G)+(3,0)$)
5743 (n2.G) ++(2,0) node[circ] {} -| (p2.G)
5744 (n2.G) to[short, -o] ($(n2.G)+(3,0)$)
5745 (0,3) to[short, -o] (-1,3)
5746 ;\end{circuitikz}
5747 \end{ctikzExample}
5748
5749 Transistors used in path are fully path-style components, so to flip and rotate them you should use \texttt{mirror} and \texttt{invert} as shown in section~\ref{sec:mirror-flip-path}.
5750
5751 Transistor paths have the possibility to use the poles syntax (see section~\ref{sec:bipole-nodes}) but they have \textbf{no} voltage, current, flow, annotation options.
5752 Also, the positioning of the labels is very simple and is not foolproof for all rotations; if you need to control them more please name the node and position them by hand, or use the more natural node style for transistors.
5753
5754 The \IndexKey{name} property is available also for bipoles; this is useful mostly for triac, potentiometer and thyristor (see~\ref{sec:othertrip}).
5755
5756
5757
5758 \subsection{Electronic Tubes}
5759 \label{sec:electronic-tubes}
5760
5761 Electronic tubes, also known as vacuum tubes, control current flow between electrodes. They come in many different flavours.
5762 \small{Contributed by J. op den Brouw (\texttt{[email protected]}).}
5763
5764 \begin{groupdesc}
5765 \circuitdesc*{diodetube}{Tube Diode}{}(anode/90/0.2, cathode/-90/0.2 )
5766 \circuitdesc*{triode}{Triode}{}(anode/90/0.2, cathode/-90/0.2, control/180/0.2 )
5767 \circuitdesc*{tetrode}{Tetrode}{}(anode/90/0.2, cathode/-90/0.2, control/190/0.2,screen/170/0.2 )
5768 \circuitdesc*{pentode}{Pentode}{}(anode/90/0.2, cathode/-90/0.2, control/190/0.2,screen/180/0.2,suppressor/170/0.2 )
5769 \end{groupdesc}
5770
5771 Some pentodes have the suppressor grid internally connected to the control grid, which saves a pin on the tube's housing.
5772
5773 \begin{groupdesc}
5774 \circuitdesc*{pentode suppressor to cathode}{Pentode with suppressor grid connected to cathode}{}( anode/90/0.2, cathode/-90/0.2, control/190/0.2,screen/180/0.2 )
5775 \end{groupdesc}
5776
5777 Note that the \verb|diodetube| is used as component name to avoid clashes with the semiconductor diode.
5778 Normally, the filament is not drawn. If you want a filament, put the \verb|filament| option in the node description:
5779
5780 \begin{groupdesc}
5781 \circuitdesc*{diodetube,filament}{Tube Diode\footnotemark}{}(anode/90/0.2, filament 1/-90/0.4, filament 2/-45/0.2, filament center/0/0.5 )
5782 \footnotetext{The \texttt{filament center} anchor has been added in \texttt{v1.6.9} thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/792}{user bogger33 on GitHub}.}
5783 \end{groupdesc}
5784
5785 Sometimes, you don't want the cathode to be drawn (but you do want the filament). Use the \verb|nocathode| option in the node description:
5786
5787 \begin{groupdesc}
5788 \circuitdesc*{diodetube,filament,nocathode}{Tube Diode}{}(anode/90/0.2 )
5789 \end{groupdesc}
5790
5791 If you want a full cathode to be drawn, use the \verb|fullcathode| option in the node description. You can then use the anchors \verb|cathode 1| and \verb|cathode 2|.
5792
5793 \begin{groupdesc}
5794 \circuitdesc*{diodetube,fullcathode}{Tube Diode}{}(anode/90/0.2, cathode 1/-135/0.2, cathode 2/-45/0.2 )
5795 \end{groupdesc}
5796
5797 \subsubsection{Tubes customization}
5798 \label{sec:tubes-customization}
5799
5800 The tubes can be scaled using the key \IndexKey{tubes/scale}, default \texttt{1.0}. In addition, they are
5801 fully configurable, and the attributes are described below\IndexKey[tubes customization]{}:
5802
5803 \begin{tabular}{l | l | l}
5804
5805 Key & Default value & Description\\
5806 \hline
5807 \verb|tubes/scale| & \verb|1| & scale factor \\
5808 \verb|tubes/width| & \verb|1| & relative width \\
5809 \verb|tubes/height| & \verb|1.4| & relative height \\
5810 \verb|tubes/tube radius| & \verb|0.40| & radius of tube circle \\
5811 \verb|tubes/anode distance| & \verb|0.40| & distance from center \\
5812 \verb|tubes/anode width| & \verb|0.40| & width of an anode/plate \\
5813 \verb|tubes/grid protrusion| & \verb|0.25| & distance from center \\
5814 \verb|tubes/grid dashes| & \verb|5| & number of grid dashes \\
5815 \verb|tubes/grid separation| & \verb|0.2| & separation between grids \\
5816 \verb|tubes/grid shift| & \verb|0.0| & y shift of grids from center \\
5817 \verb|tubes/cathode distance| & \verb|0.40| & distance from grid \\
5818 \verb|tubes/cathode width| & \verb|0.40| & width of a cathode \\
5819 \verb|tubes/cathode corners| & \verb|0.06| & corners of the cathode wire \\
5820 \verb|tubes/cathode right extend| & \verb|0.075| & extension at the right side \\
5821 \verb|tubes/filament distance| & \verb|0.1| & distance from cathode \\
5822 \verb|tubes/filament angle| & \verb|15| & angle from the centerpoint \\
5823 \end{tabular}
5824
5825 Conventionally, the model of the tube is indicated at the \verb|east| anchor, and you can access filament anchors if you need them:
5826
5827
5828 \begin{ctikzExample}
5829 \ctikzset{tubes/width=1.4, tubes/height=1}
5830 \begin{circuitikz}
5831 \draw (0,2) node[triode, filament] (Tri) {};
5832 \draw (Tri.east) node[right] {12AX7};
5833 \ctikzset{tubes/filament angle=40,
5834 tubes/filament distance=0.2}
5835 \draw (0,0) node[triode, filament] (Pent) {};
5836 \draw (Pent.east) node[right] {BOH};
5837 \path (Tri.filament 1) node[red,ocirc]{};
5838 \path (Pent.filament 1) node[red,ocirc]{};
5839 \path (Tri.filament center) node[blue,ocirc]{};
5840 \draw (Pent.filament center) -- ++(0,-1) node[tlground]{};
5841 \end{circuitikz}
5842 \end{ctikzExample}
5843
5844
5845
5846 Example triode amplifier:
5847
5848 \begin{lstlisting}
5849 \begin{circuitikz}
5850 \draw (0,0) node (start) {}
5851 to[sV=$V_i$] ++(0,2+\ctikzvalof{tubes/height})
5852 to[C=$C_i$] ++(2,0) coordinate(Rg)
5853 to[R=$R_g$] (Rg |- start)
5854 (Rg) to[short,*-] ++(1,0)
5855 node[triode,anchor=control] (Tri) {} ++(2,0)
5856 (Tri.cathode) to[R=$R_c$,-*] (Tri.cathode |- start)
5857 (Tri.anode) to [R=$R_a$] ++(0,2)
5858 to [short] ++(3.5,0) node(Vatop) {}
5859 to [V<=$V_a$] (Vatop |- start)
5860 to [short] (start)
5861 (Tri.anode) ++(0,0.2) to[C=$C_o$,*-o] ++(2,0)
5862 (Tri.cathode) ++(0,-0.2) to[short,*-] ++(1.5,0) node(Cctop) {}
5863 to[C=$C_c$,-*] (start -| Cctop)
5864 ;
5865 \draw[red,thin,dashed] (Tri.north west) rectangle (Tri.south east);
5866 \draw (Tri.east) node[right] {12AX7};
5867 \end{circuitikz}
5868 \end{lstlisting}
5869
5870 \begin{circuitikz}[scale=0.7, transform shape]
5871 \draw (0,0) node (start) {}
5872 to[sV=$V_i$] ++(0,2+\ctikzvalof{tubes/height})
5873 to[C=$C_i$] ++(2,0) coordinate(Rg)
5874 to[R=$R_g$] (Rg |- start)
5875 (Rg) to[short,*-] ++(1,0)
5876 node[triode,anchor=control] (Tri) {} ++(2,0)
5877 (Tri.cathode) to[R=$R_c$,-*] (Tri.cathode |- start)
5878 (Tri.anode) to [R=$R_a$] ++(0,2)
5879 to [short] ++(3.5,0) node(Vatop) {}
5880 to [V<=$V_a$] (Vatop |- start)
5881 to [short] (start)
5882 (Tri.anode) ++(0,0.2) to[C=$C_o$,*-o] ++(2,0)
5883 (Tri.cathode) ++(0,-0.2) to[short,*-] ++(1.5,0) node(Cctop) {}
5884 to[C=$C_c$,-*] (start -| Cctop)
5885 ;
5886 \draw[red,thin,dashed] (Tri.north west) rectangle (Tri.south east);
5887 \draw (Tri.east) node[right] {12AX7};
5888 \end{circuitikz}
5889
5890 \subsubsection{Tubes anchors}
5891 \label{sec:tubes-anchors}
5892
5893 Apart from the geographic anchors, which take into account the leads of the components, you have several anchors on the border:
5894 \begin{quote}
5895 \geolrcoord{pentode, scale=0.8}
5896 \geolrcoord{triode, circuitikz/tubes/width=1.4, circuitikz/tubes/height=1, scale=0.8}
5897 \geolrcoord{triode, circuitikz/tubes/width=1, circuitikz/tubes/height=1, scale=0.8}
5898
5899 \showanchors{pentode, circuitikz/tubes/height=1.8}{}(%
5900 tube top/90/0.3, tube left/180/0.2, tube right/0/0.2, tube bottom/-90/0.3,
5901 tube top right/30/0.2, tube top left/150/0.4, tube bottom right/-45/0.4, tube bottom left/-150/0.2,
5902 tube top center/75/0.5, tube bottom center/-105/0.5)
5903 \showanchors{pentode,circuitikz/tubes/width=2.6, circuitikz/tubes/tube radius=0.3}{}(%
5904 tube top/90/0.5, tube left/160/0.5, tube right/0/0.2, tube bottom/-90/0.6,
5905 tube top right/70/0.4, tube top left/150/0.4, tube bottom right/-45/0.4, tube bottom left/-120/0.4,
5906 tube right center/30/0.4, tube left center/-120/0.4)
5907 \end{quote}
5908
5909 \subsubsection{Partially drawn tube borders}\label{sec:partial-tube-borders}
5910
5911 In some circuits, tubes are drawn with partial or dashed border (to convey the meaning of several active components encased in the same physical tube). To achieve this effect, you can use the \IndexKey{tubes/partial border}\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/602}{Jether Fernandes Reis}, implemented by Romano in \texttt{v1.5.2}.} key (default \texttt{none}). This key can be set to \texttt{none}, or must be a sequence of \textbf{exactly} 6 numbers, which can have value \texttt{0}, \texttt{1}, or \texttt{2}. Each number defines the style of a part of the border to be not drawn, solid or dashed respectively.
5912
5913 The part of the border are numbered from 1 to 6 as shown below:
5914 \begin{quote}
5915 \begin{circuitikz}[circuitikz/tubes/fill=cyan!20,
5916 circuitikz/tubes/partial borders=121212]
5917 \draw (0,0) node[pentode,anchor=control](V){};
5918 \draw (4,0) node[pentode,anchor=control,
5919 circuitikz/tubes/width=1.4,
5920 circuitikz/tubes/height=1](H){};
5921 \draw[red, font=\ttfamily\small\bfseries]
5922 ([shift={(-.2,-.2)}]V.ne) node{1}
5923 ([shift={(.1,0)}]V.e) node{2}
5924 ([shift={(-.2,.2)}]V.se) node{3}
5925 ([shift={(.2,.2)}]V.sw) node{4}
5926 ([shift={(-.1,0)}]V.w) node{5}
5927 ([shift={(.2,-.2)}]V.nw) node{6}
5928 ([shift={(.2,-.2)}]H.nw) node{1}
5929 ([shift={(0,.1)}]H.n) node{2}
5930 ([shift={(-.2,-.2)}]H.ne) node{3}
5931 ([shift={(-.2,.2)}]H.se) node{4}
5932 ([shift={(0,-.1)}]H.s) node{5}
5933 ([shift={(.2,.2)}]H.sw) node{6}
5934 ;
5935 \end{circuitikz}
5936 \end{quote}
5937 (notice that the straight parts, if they exist, are numbered \texttt{2} and \texttt{5} in both tubes, vertical or horizontal).
5938
5939 The dashed line pattern can be changed by setting the key \texttt{tubes/partial border dash} (default \verb|{{2pt}{2pt}}|).\footnote{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.} Be careful with the extra set of braces here.
5940
5941 \begin{ctikzExample}
5942 \begin{circuitikz}[circuitikz/tubes/fill=cyan!20,
5943 circuitikz/tubes/partial borders=012012]
5944 \draw (0,0) node[pentode]{};
5945 \draw (2,0) node[pentode,
5946 circuitikz/tubes/width=1.4,
5947 circuitikz/tubes/height=1]{};
5948 \draw (1,-2) node[triode,
5949 circuitikz/tubes/height=1,
5950 circuitikz/tubes/partial border dash=%
5951 {{3pt}{1pt}{1pt}{1pt}}]{};
5952 \end{circuitikz}
5953 \end{ctikzExample}
5954
5955
5956 \subsubsection{Multi-anode tube}
5957 \label{sec:multi-anode-tube}
5958
5959 The multi-anode tube (\texttt{matube}) is a component thought to be tailored for several different usages,\footnote{It was added in \texttt{v1.6.8} after suggestions by user \texttt{bogger33} on GitHub \href{https://github.com/circuitikz/circuitikz/issues/781}{here} and \href{https://github.com/circuitikz/circuitikz/issues/785}{here}.} as shown in the examples below.
5960
5961 The anchors for the multiple anodes have also alias names to ease the use in the case of implementing nixie tubes, because in that case the anode/cathode roles are swapped.
5962
5963 \begin{groupdesc}
5964 \circuitdesc*{matube}{Multi-anode tube}{}(anode 1/110/0.2, anode 2/60/0.2, anode 3/-30/0.2, cathode/-90/0.2, control/180/0.2 )
5965 \circuitdesc*{matube, nixieanode, anodedot, nogrid}{Multi-anode tube used for nixie tubes}{}(nixie k1/110/0.2, nixie k2/60/0.2, nixie k3/-30/0.2, nixie a/-90/0.2)
5966 \end{groupdesc}
5967
5968 Basically all the parameters available for triodes are available. The main difference is that the \texttt{anode width} parameter define the length of \emph{all} the anodes; those tubes are normally used with a \texttt{width} parameter bigger than \texttt{height}, to have an elongated device.
5969
5970 The additional parameters/flags available only for \IndexKey[matube (multi-anode tube) customizations]{matube}s are the following.
5971
5972 \begin{tabular}{l | l | l}
5973 Key/Flag & Default value & Description\\
5974 \hline
5975 \texttt{anodes} & 3 & number of anodes \\
5976 \texttt{anodedot} & false & substitute anodes bar for dots \\
5977 \texttt{nixieanode} & false & substitute the cathode for the nixie-style anode \\
5978 \texttt{nogrid} & false & suppresses the drawing of the grid \\
5979 \end{tabular}
5980
5981 In the next example, we define a 10-anodes VFD tube:
5982
5983 \begin{ctikzExample}
5984 \tikzset{vfd 10/.style={matube, filament, nocathode,
5985 circuitikz/tubes/.cd,
5986 width=3.6, height=1, anodes=10, anode width=0.6,
5987 cathode width=0.1,
5988 }}
5989 \begin{circuitikz}[european]
5990 \draw (0,0) node[vfd 10](A){};
5991 \foreach \i in {1,...,10} \path (A.anode \i)
5992 node[red, ocirc]{} node[above]{\tiny \i};
5993 \end{circuitikz}
5994 \end{ctikzExample}
5995
5996 And a 10-cathodes nixie tube:
5997
5998
5999 \begin{ctikzExample}
6000 \tikzset{nixie/.style={matube, nogrid, nixieanode,
6001 anodedot, circuitikz/tubes/.cd, cathode width=0.6,
6002 width=3.6, height=1, anodes=10, anode width=0.6,
6003 }}
6004 \begin{circuitikz}[european]
6005 \draw (0,0) node[nixie](A){};
6006 \foreach \i in {1,...,10} \path (A.nixie k\i)
6007 node[red, ocirc]{} node[above]{\tiny \i};
6008 \path (A.nixie a) node[red, ocirc]{};
6009 \end{circuitikz}
6010 \end{ctikzExample}
6011
6012 \subsubsection{Other tubes-like components}
6013 \label{sec:other-tubes-like}
6014
6015 The \texttt{magnetron} and \texttt{dynode} shapes will also scale with \texttt{tubes/scale}.
6016
6017 \begin{groupdesc}
6018 \circuitdesc*{magnetron}{Magnetron}{}( anode/-90/0.2, cathode1/135/0.2,
6019 cathode2/45/0.2, left/180/0.2, right/0/0.2, top/90/0.4 )
6020 \circuitdesc{dynode}{Dynode\footnotemark}{D}( top/90/0.1, bottom/180/0.3, left/180/0.3, right/0/0.3, center/0/0.3, arc/-30/0.4, top right/30/0.2, top left/150/0.2 )
6021 \footnotetext{Suggested by the user \texttt{ferdymercury} on \href{https://github.com/circuitikz/circuitikz/issues/469}{GitHub}.}
6022 \end{groupdesc}
6023
6024 \begin{ctikzExample}
6025 \begin{circuitikz}
6026 \draw (0,-2)node[rground](gnd){} to[voltage source,v<={HV}]++(0,3)--++(1,0)to[V,n=DC]++(2,0);
6027 \draw (2,-1) node[magnetron,scale=1](magn){};
6028 \draw (DC.left)++(-0.2,0)to [short,*-] ++(0,-1) to [short] (magn.cathode1);
6029 \draw (DC.right)++(0.2,0)to [short,*-] ++(0,-1) to [short] (magn.cathode2);
6030 \draw (magn.anode) to [short] (magn.anode|-gnd) node[rground]{};
6031 \draw (magn.cathode1)node[above]{$1$};
6032 \draw (magn.cathode2)node[above]{$2$};
6033 \draw[->](magn.east) --++(1,0)node[right]{$RF_{out}$};
6034 \end{circuitikz}
6035 \end{ctikzExample}
6036
6037
6038 \paragraph{Dynode customization.}
6039 \label{par:dynode-customization}
6040 The dynode element can be heavily customized. The parameters are the following (all of them under the \verb|\ctikzset| family \IndexKey[dynode customization]{monopoles/dynode}):
6041
6042 \begin{center}
6043 \begin{tabular}{>{\ttfamily}l>{\ttfamily}rp{0.75\linewidth}}
6044 \toprule
6045 parameter & default & description \\
6046 \midrule
6047 width & \ctikzvalof{monopoles/dynode/width} & Total width (relative to the base length) measured at the arc width.\\
6048 height & \ctikzvalof{monopoles/dynode/height} & Total height (same units as width).\\
6049 arc angle & \ctikzvalof{monopoles/dynode/arc angle} & Angle (from the horizontal, going down) where the arc starts. A value of \texttt{90} don't plot any arc, \texttt{0} plots a semicircle. To avoid artifacts, use a value between \texttt{-60} and \texttt{90}; the arc horizontal size is always equal to the \texttt{width}.\\
6050 arc pos & \ctikzvalof{monopoles/dynode/arc pos} & Vertical position (relative to the height) of the arc center. \\
6051 top width & \ctikzvalof{monopoles/dynode/top width} & Relative width of the top bar; a value of \texttt{1} means full width, \texttt{0} means no bar.\\
6052 \bottomrule
6053 \end{tabular}
6054 \end{center}
6055
6056
6057 \begin{ctikzExample}
6058 \begin{circuitikz}[american] \ctikzset{tubes/thickness=4}
6059 \draw (0,0) to[R] (2,0) node[dynode]{} to[R,-*] (4,0);
6060 \ctikzset{monopoles/dynode/.cd,
6061 arc angle=0, arc pos=0.7, top width=0.5}
6062 \draw (4,0) node[dynode]{};
6063 \end{circuitikz}
6064 \end{ctikzExample}
6065
6066 You can use styles and the parameters to create different types of electrodes:
6067
6068 \begin{ctikzExample}
6069 \begin{circuitikz}[american] \ctikzset{tubes/thickness=4}
6070 \tikzset{anode/.style={dynode,
6071 circuitikz/monopoles/dynode/arc angle=90},
6072 photocatode/.style={dynode,
6073 circuitikz/monopoles/dynode/arc pos=1,
6074 circuitikz/monopoles/dynode/top width=0},
6075 }
6076 \draw (0,0) node[dynode]{} (1,0) node[anode]{}
6077 (2,0) node[photocatode]{};
6078 \end{circuitikz}
6079 \end{ctikzExample}
6080
6081
6082 \subsection{RF components}\label{sec:RF}
6083
6084 For the RF components, similarly to the grounds and supply rails, the \texttt{center} anchor is put on the connecting point of the symbol, so that you can use them directly in a \texttt{path} specification.
6085
6086 Notes that in the transmission and receiving antennas, the ``waves'' are outside the geographical anchors.
6087
6088 \begin{groupdesc}
6089 \circuitdesc*{bareantenna}{Bare Antenna}{A}( top/90/0.1, bottom/180/0.3, left/180/0.3, right/45/0.3, center/0/0.3 )
6090 \circuitdesc*{dinantenna}{DIN antenna\footnotemark}{A}(left/135/0.6, right/45/0.6, center/-45/0.6)
6091 \footnotetext{Since 1.5.0, suggested by \href{https://github.com/circuitikz/circuitikz/issues/621}{GitHUb user myzinsky}}
6092 \circuitdesc*{bareTXantenna}{Bare TX Antenna}{Tx}( top/90/0.1, center/180/0.3, waves/90/0.3 )
6093 \circuitdesc*{bareRXantenna}{Bare RX Antenna}{Rx}( top/90/0.1, center/0/0.3, waves/90/0.3 )
6094 \circuitdesc{waves}{Waves}{}( north/90/0.4, north east/45/0.4, east/-45/0.4, south east/-45/0.4,
6095 south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4,
6096 left/135/0.2, top/45/0.2, right/45/0.2, bottom/-45/0.2 )
6097 \circuitdesc{harmonics}{Harmonics which could be combined with waves}{}
6098 \circuitdescbip*{mstline}{Microstrip transmission line\footnotemark}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
6099 \circuitdesc*{mslstub}{Microstrip linear stub}{text}(left/135/0.2, right/45/0.2, center/-45/0.3)
6100 \circuitdesc*{msport}{Microstrip port}{T}(left/135/0.2, right/45/0.2, center/-45/0.3)
6101 \circuitdesc*{msrstub}{Microstrip radial stub}{}(left/135/0.2, right/45/0.2, center/-45/0.3)
6102 \footnotetext{These four components were suggested by \texttt{@tcpluess} on GitHub}
6103 \circuitdesc{antenna}{Legacy antenna (with tails)}{}( center/0/0.3 )
6104 \circuitdesc{rxantenna}{Legacy receiving antenna (with tails)}{}
6105 \circuitdesc{txantenna}{Legacy transmitting antenna (with tails)}{}
6106 \circuitdesc*{tlinestub}{Transmission line stub}{}
6107 \circuitdescbip*[tline]{TL}{Transmission line}{transmission line, tline}(left/135/0.3, right/45/0.3, top left/90/0.2, top right/90/0.4, bottom left/-90/0.4, bottom right/-70/0.3, center right/-30/0.2, center left/-160/0.2)
6108 \circuitdescbip[tline]{TL, bipoles/tline/bare=true}{Transmission line without wires (notice that if you fill it, the fill will overwrite the exiting wire)}{transmission line, tline}(left/90/0.3, right/90/0.3)
6109 \circuitdesc{match}{match}{}
6110 \end{groupdesc}
6111
6112 The \texttt{waves} and \texttt{harmonics} can help with RF block diagrams
6113 \begin{ctikzExample}[varwidth=true, pos=t]
6114 % Author: Prof. Dr. Matthias Jung, DL9MJ % Year: 2023
6115 \begin{circuitikz}[european]
6116 \draw(0,0) node [dinantenna](ant1){};
6117 \draw[thick](ant1.south) -- ++(0,-1)
6118 node[anchor=south west](){$f=\qty{145,9}{\mega\hertz}$};
6119 \draw(3.5,0) node [dinantenna](ant2){};
6120 \draw(3.75,-0.5) node[tvsetshape, anchor=west, fill=gray](tv){};
6121 \draw[thick] (ant2) |- (tv);
6122 \draw(tv.north) node[above](){TV};
6123 %
6124 \draw[gray](ant1.right) node[harmonics, xscale=2, anchor=left](){};
6125 \draw[thick](ant1.right) node[waves, xscale=2, anchor=left](){};
6126 %
6127 \draw(tv.south) ++(0,-0.25)
6128 node[below](foo){$f=$\,\qtyrange{582}{590}{\mega\hertz}};
6129 \draw(foo.south) node[below](){DVB-T2 Kanal 35};
6130 \end{circuitikz}
6131 \end{ctikzExample}
6132
6133 \subsubsection{RF elements customization}
6134 \label{sec:rf-elements-customization}
6135
6136 The RF elements can be scaled using the key \IndexKey{RF/scale}, default \texttt{1.0}.
6137
6138 \subsubsection{Microstrip customization}
6139 \label{sec:microstrip-customization}
6140
6141 The microstrip linear components' (\texttt{mstline}, \texttt{mslstub}, \texttt{msport}) heights can be changed by setting the parameter \IndexKey{bipoles/mstline/height} (for the three of them, default 0.3). The widths are specified in \IndexKey{bipoles/mstline/width} for the first two and by \IndexKey{monopoles/msport/width} for the port (defaults: 1.2, 0.5).
6142 Finally, you can change the size of the smaller circle (the connecting part) of \texttt{msrstub} with the parameter \IndexKey{monopoles/msrstub/radius} (default \texttt{0.25}; using \texttt{0} will suppress the smaller circle\footnote{suggested by \href{https://tex.stackexchange.com/a/757589/38080}{user cis on TeX.SX}}).
6143
6144 For the length parameter of the transmission line there is a shortcut in the form of the direct parameter \IndexKey{mstlinelen}.
6145
6146 \begin{ctikzExample}[varwidth=true, pos=t]
6147 \begin{circuitikz}
6148 \draw (0,0) node[msport, right, xscale=-1]{}
6149 to[mstline, -o] ++(3,0) coordinate(there)
6150 to[mstline, mstlinelen=2, l=longer, o-*] ++(4,0)
6151 coordinate(here) -- ++(0.5,0) node[mslstub, fill=yellow]{stub}
6152 (here) -- ++(0,0.5) node[mslstub, rotate=90, mstlinelen=0.5]{short};
6153 \draw (there) to[short, o-] ++(0, 0.5) node[msrstub]{};
6154 \draw (here) -- ++(0, -0.5) node[msrstub, yscale=-1,
6155 circuitikz/monopoles/msrstub/radius=0]{};
6156 \end{circuitikz}
6157 \end{ctikzExample}
6158
6159 The legacy \texttt{tline} can be used as in the following example. You can change the length with the key \IndexKey{bipoles/tline/width} (default \texttt{0.6}). The ``bare'' version, which differs only for the small line on the visible ellipse, and activated with the boolean key \texttt{\dots/bare}, is useful as a substitute for \texttt{tlinestub} (with more flexibility).
6160
6161 \begin{ctikzExample}
6162 \begin{tikzpicture}[]
6163 \tikzset{bare tl/.style={tlineshape,
6164 circuitikz/bipoles/tline/bare=true}}
6165 \draw (0,0) node[bare tl](A){} (A.right)
6166 to[TL, bipoles/tline/width=1] ++(3,0)
6167 node[bare tl, anchor=left]{};
6168 \end{tikzpicture}
6169 \end{ctikzExample}
6170
6171 \subsection{Electro-Mechanical Devices}
6172 \label{sec:electro-mechanical-devices}
6173
6174 The internal part of the motor and generator are, by default, filled with white (to avoid compatibility problems with older versions of the package).
6175
6176 \begin{groupdesc}
6177 \circuitdesc*{elmech}{Motor}{M}(bottom/-90/0.2, left/180/0.2, right/0/0.2, top/90/0.4, 45/45/0.2)
6178 \circuitdesc*{elmech}{Generator}{G}(block down right/0/0.2, block north east/0/0.2)
6179 \end{groupdesc}
6180
6181 \subsubsection{Electro-Mechanical Devices anchors}
6182 \label{sec:electro-mechanical-devices-anchors}
6183
6184 Apart from the standard geographical anchors, \texttt{elmech} has the border anchors (situated on the inner circle) and the following anchors on the ``block'':
6185
6186 \begin{quote}
6187 \begin{circuitikz}
6188 \def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, }]#3:#1}](#1){}}
6189 \node [elmech](T) at(0,0) {A};
6190 \foreach \a/\d/\t in {block north east/0.2/45, block south east/0.2/-45,
6191 block south west/0.2/-135, block north west/0.1/135, 150/0.1/150,
6192 180/0.1/180, 210/0.1/210, 60/0.4/-15, -60/0.4/15}
6193 \path (T.\a) \coordx(\a)[\d:\t]{red};
6194 \node [elmech](T) at(6,0) {B};
6195 \foreach \a/\d/\t in {block up right/0.2/45, block down right/0.2/-45,
6196 block down left/0.2/-135, block up left/0.1/135, north/0.3/90,
6197 south/0.3/-90, east/0.3/0, west/0.3/180}
6198 \path (T.\a) \coordx(\a)[\d:\t]{red};
6199 \end{circuitikz}
6200 \end{quote}
6201
6202
6203 \begin{ctikzExample}
6204 \begin{circuitikz}
6205 \draw (2,0) node[elmech](motor){M};
6206 \draw (motor.north) |-(0,2) to [R] ++(0,-2) to[dcvsource]++(0,-2) -| (motor.bottom);
6207 \draw[thick,->>](motor.right)--++(1,0)node[midway,above]{$\omega$};
6208 \end{circuitikz}
6209 \end{ctikzExample}
6210 \begin{ctikzExample}
6211 \begin{circuitikz}
6212 \draw (2,0) node[elmech](motor){};
6213 \draw (motor.north) |-(0,2) to [R] ++(0,-2) to[dcvsource]++(0,-2) -| (motor.bottom);
6214 \draw[thick,->>](motor.center)--++(1.5,0)node[midway,above]{$\omega$};
6215 \end{circuitikz}
6216 \end{ctikzExample}
6217
6218 The symbols can also be used along a path, using the transistor-path-syntax(\texttt{T} in front of the shape name, see section \ref{sec:transasbip}). Don't forget to use parameter $n$ to name the node and get access to the anchors:
6219
6220 \begin{ctikzExample}
6221 \begin{circuitikz}
6222 \draw (0,0) to [Telmech=M,n=motor] ++(0,-3) to [Telmech=M] ++(3,0) to [Telmech=G,n=generator] ++(0,3) to [R] (0,0);
6223 \draw[thick,->>](motor.left)--(generator.left)node[midway,above]{$\omega$};
6224 \end{circuitikz}
6225 \end{ctikzExample}
6226
6227
6228
6229 \subsection{Double bipoles (transformers)}\label{sec:transformers}
6230
6231 Transformers automatically use the inductor shape currently selected. These are the three possibilities:
6232 \begin{groupdesc}
6233 \ctikzset{inductor=cute}
6234 \circuitdesc{transformer}{Transformer (cute inductor)}{$T_1$}( A1/180/0.1,
6235 A2/180/0.1, B1/0/0.1, B2/0/0.1, north/45/0.4,
6236 inner dot A1/-135/0.2, inner dot A2/135/0.2, inner dot B1/-45/0.1,
6237 inner dot B2/45/0.1 )
6238 \ctikzset{inductor=american}
6239 \circuitdesc{transformer}{Transformer (american inductor)}{}( %
6240 outer dot A1/180/0.2, outer dot A2/180/0.2,
6241 outer dot B1/0/0.2, outer dot B2/0/0.2 )
6242 \ctikzset{inductor=european}
6243 \circuitdesc{transformer}{Transformer (european inductor)}{}
6244 \circuitdesc*{gyrator}{Gyrator}{}
6245 \end{groupdesc}
6246
6247
6248 Transformers with core are also available:
6249 \begin{groupdesc}
6250 \ctikzset{inductor=cute}
6251 \circuitdesc{transformer core}{Transformer core (cute inductor)}{}
6252 \ctikzset{inductor=american}
6253 \circuitdesc{transformer core}{Transformer core (american inductor)}{}
6254 \ctikzset{inductor=european}
6255 \circuitdesc{transformer core}{Transformer core (european inductor)}{}
6256 \ctikzset{inductor=cute} % reset default
6257 \end{groupdesc}
6258
6259 You can also build generic double bipoles\footnote{The idea of generic double bipoles was originated by user \href{https://github.com/circuitikz/circuitikz/issues/641}{erwindenboer on GitHub}.} (although it's often better to use subcircuits in this case; see section~\ref{sec:subcircuits}).
6260
6261 \begin{groupdesc}
6262 \circuitdesc{double bipole}{Generic double bipole (configurable components)}{$A_v$}(north/45/0.4, center/-90/0.6, east/45/0.2)[L.south/180/0.2, R.west/-45/0.2]
6263 \ctikzset{double bipole L=fulllediodeshape, double bipole R=emptydiodeshape, double bipole R invert, diodes/scale=0.6}
6264 \circuitdesc{double bipole}{Generic double bipole (this specific configuration is shown in section~\ref{sec:doublebipoles})}{$A_v$}(north/45/0.4, center/-90/0.6, east/45/0.2)[L.south/180/0.2, R.west/-45/0.2]
6265 \end{groupdesc}
6266
6267 \subsubsection{Transformer anchors}
6268 \label{sec:transformer-anchors}
6269
6270 All the double bipoles/quadrupoles have the four anchors, two for each port.
6271 The first port, to the left, is port \texttt{A}, having the anchors \texttt{A1} (up) and \texttt{A2} (down); same for port \texttt{B}.
6272
6273 They also expose the \texttt{base} anchor, for labeling, and anchors for setting dots or signs to specify polarity.
6274 The set of anchors, to which you should add the standard ``geographical'' \texttt{north}, \texttt{north east}, etc. is here:
6275
6276 \medskip
6277 \begin{quote}
6278 \begin{circuitikz}[cute inductors,
6279 ]
6280 \def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, overlay,}]#3:#1}](#1){}}
6281 \foreach \comp/\pos/\case in {%
6282 transformer/0/0%
6283 ,transformer core/4/1%
6284 ,gyrator/8/2%
6285 }{
6286 \draw (\pos, 0) node[\comp](T){};
6287 \ifcase\case
6288 \foreach \a/\d/\t in {inner dot A1/0.2/75, inner dot A2/0.2/-75, inner dot B1/0.1/-45, inner dot B2/0.1/45}
6289 \path (T.\a) \coordx(\a)[\d:\t]{red};
6290 \or
6291 \foreach \a/\d/\t in {outer dot A1/0.2/75, outer dot A2/0.2/-75, outer dot B1/0.2/-45, outer dot B2/0.2/45}
6292 \path (T.\a) \coordx(\a)[\d:\t]{blue};
6293 \or
6294 \foreach \a/\t in {A1/120, A2/-120, B1/120, B2/-120, base/-90}
6295 \path (T.\a) \coordx(\a)[0.2:\t]{green!50!black};
6296 \fi
6297 }
6298 \end{circuitikz}
6299 \end{quote}
6300 \medskip
6301
6302 Also, the standard ``geographical'' \texttt{north}, \texttt{north east}, etc. are defined.
6303 A couple of examples follow:
6304
6305 \begin{ctikzExample}
6306 \begin{circuitikz} \draw
6307 (0,0) node[transformer] (T) {}
6308 (T.A1) node[anchor=east] {A1}
6309 (T.A2) node[anchor=east] {A2}
6310 (T.B1) node[anchor=west] {B1}
6311 (T.B2) node[anchor=west] {B2}
6312 (T.base) node{K}
6313 (T.inner dot A1) node[circ]{}
6314 (T.inner dot B2) node[circ]{}
6315 ;\end{circuitikz}
6316 \end{ctikzExample}
6317
6318 \begin{ctikzExample}
6319 \begin{circuitikz} \draw
6320 (0,0) node[gyrator] (G) {}
6321 (G.A1) node[anchor=east] {A1}
6322 (G.A2) node[anchor=east] {A2}
6323 (G.B1) node[anchor=west] {B1}
6324 (G.B2) node[anchor=west] {B2}
6325 (G.base) node{K}
6326 ;\end{circuitikz}
6327 \end{ctikzExample}
6328
6329 Moreover, you can access the two internal coils (inductances); if your transformer node is called \texttt{T}, they are named \texttt{T-L1} and \texttt{T-L2}. Notice that the two inductors are rotated (by -90 degrees the first, +90 degrees the second) so you have to be careful with the anchors. Also, the \texttt{midtap} anchor of the inductors can be on the external or internal side depending on the numbers of coils. Finally, the anchors \texttt{L1.a} and \texttt{L1.b} are marking the start and end of the coils.
6330
6331 \begin{quote}
6332 \begin{circuitikz}[american inductors,
6333 ]
6334 \def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, overlay,}]#3:#1}](){}}
6335 \draw (-2,0) (0, 0) node[transformer](T){};
6336 \foreach \a/\d/\t in {L1.midtap/0.2/180, L1.south west/0.2/180, L1.south east/0.2/180,
6337 L2.south/0.2/0, L2.south west/0.2/0, L2.south east/0.2/0}
6338 \path (T-\a) \coordx(T-\a)[\d:\t]{red};
6339 \ctikzset{cute inductors}
6340 \draw (4, 0) node[transformer](T){};
6341 \foreach \a/\d/\t in {L1.a/0.2/-120, L1.b/0.2/120,
6342 L2.midtap/0.5/0, L2.south west/0.2/0, L2.south east/0.2/0}
6343 \path (T-\a) \coordx(T-\a)[\d:\t]{blue};
6344 \node[font=\small\ttfamily,above] at (T.north) {inductors/coils=5};
6345 \draw (8, 0) node[transformer, circuitikz/inductors/coils=6](T){};
6346 \foreach \a/\d/\t in {L2.a/0.2/120, L2.b/0.2/-120,
6347 L2.midtap/0.2/0, L2.south west/0.2/0, L2.south east/0.2/0}
6348 \path (T-\a) \coordx(T-\a)[\d:\t]{red};
6349 \node[font=\small\ttfamily,above] at (T.north) {inductors/coils=6};
6350 \end{circuitikz}
6351 \end{quote}
6352
6353 \begin{ctikzExample}
6354 \begin{circuitikz}
6355 \draw (0,0) node[ground](GND){} to [sV] ++(0,2) -- ++(1,0)
6356 node[transformer, circuitikz/inductors/coils=6,
6357 anchor=A1](T){};
6358 \draw (T.A2) to[short, -*] (T.A2-|GND);
6359 \draw (T-L2.midtap) to[short, *-o] (T.B1 |- T-L2.midtap);
6360 \node [ocirc] at (T.B1){}; \node [ocirc] at (T.B2){};
6361 \end{circuitikz}
6362 \end{ctikzExample}
6363 \subsubsection{Transformers customization}
6364 \label{sec:transformers-customization}
6365
6366 Transformers are in the \texttt{inductors} class (also the gyrator\dots), so they scale with the key \IndexKey{inductors/scale}.
6367
6368 You can change the aspect of a quadpole using the corresponding parameters \IndexKey{quadpoles/*/width} and \IndexKey{quadpoles/*/heigth} (substitute the star for \texttt{transformer}, \texttt{transformer core} or \texttt{gyrator}; default value is \texttt{1.5} for all). You have to be careful to not choose value that overlaps the components!
6369
6370 \begin{ctikzExample}
6371 \begin{circuitikz}
6372 \ctikzset{quadpoles/transformer/width=1,
6373 quadpoles/transformer/height=2}
6374 \draw (0,0) node[transformer] (T) {}
6375 (T.base) node{K}
6376 (T.inner dot A1) node[circ]{}
6377 (T.inner dot B2) node[circ]{};
6378 \end{circuitikz}
6379 \end{ctikzExample}
6380
6381 Transformers also inherit the \texttt{inductors/scale} (see~\ref{sec:tweak-l}) and similar parameters. It's your responsibility to set the aforementioned parameters if you change the scale or width of inductors.
6382
6383 Transformers core line distance is specified by the parameter \IndexKey{quadpoles/transformer core/core width} (default \texttt{0.05}) and the thickness of the lines follows the choke one; in other words, you can set it changing \IndexKey{bipoles/cutechoke/cthick}.
6384
6385 You can change the style of the core lines\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/702}{user myzinsky on GitHub}, implemented in \texttt{v1.6.2}.} in a similar way to the one used for transistor's bodydiodes, by setting keys with the \verb!\ctikzset! command under the \IndexKey[transformer core customizations]{transformer core} hierarchy. The available keys are:
6386
6387 \begin{center}
6388 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{0.5\linewidth}}
6389 \toprule
6390 parameter & default & description \\
6391 \midrule
6392 relative thickness & 1.0 & multiply the default thickness (which is the same of the \texttt{choke} component).\\
6393 color & default & stroke color: \texttt{default} is the same as the component. \\
6394 dash & default & dash pattern: \texttt{default} means not to change the setting for the component; \texttt{none} means unbroken line; every other input is a dash pattern.\footnotemark \\
6395 \bottomrule
6396 \end{tabular}
6397 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
6398 \end{center}
6399
6400 \begin{ctikzExample}
6401 \begin{circuitikz}[]
6402 \draw (0,0) node[transformer core](A){};
6403 \ctikzset{transformer core/.cd, relative thickness=2, color=red, dash={{4pt}{2pt}}}
6404 \draw (2,0) node[transformer core](B){};
6405 \end{circuitikz}
6406 \end{ctikzExample}
6407
6408 Another very useful parameter is \IndexKey{quadpoles/*/inner} (default \texttt{0.4}) that determine which part of the component is the ``vertical'' one. So, setting that parameter to 1 will eliminate the horizontal part of the component (obviously, to maintain the general aspect ratio you need to change the width also):
6409
6410
6411 \begin{ctikzExample}
6412 \begin{circuitikz}
6413 \draw (0,0) node[transformer] (T) {}
6414 (T.A1) node[anchor=east] {A1}
6415 (T.A2) node[anchor=east] {A2}
6416 (T.B1) node[anchor=west] {B1}
6417 (T.B2) node[anchor=west] {B2}
6418 (T.base) node{K} ;
6419 \ctikzset{quadpoles/transformer/inner=1, quadpoles/transformer/width=0.6}
6420 \draw (0,-3) node[transformer] (P) {}
6421 (P.base) node{T}
6422 (P.inner dot A2) node[ocirc]{}
6423 (P.inner dot B2) node[ocirc]{};
6424 \end{circuitikz}
6425 \end{ctikzExample}
6426
6427 This can be useful if you want to put seamlessly something in series with either side of the component; for simplicity, you have a style setting \IndexKey{quadpoles style} to toggle between the standard shape of double bipoles (called \IndexKey[quadpoles style inward]{inward}, default) and the one without horizontal leads (called \IndexKey[quadpoles style inline]{inline}):
6428
6429 \begin{ctikzExample}
6430 \begin{circuitikz}
6431 \ctikzset{inductor=cute, quadpoles style=inline}
6432 \draw
6433 (0,0) to[R] ++(0,-2)
6434 node[transformer, anchor=A1](T){}
6435 (T.A2) node[ground](GND){}
6436 (T.inner dot A1) node[font=\small\boldmath]{$\oplus$}
6437 (T.inner dot B2) node[]{$+$}
6438 (T.B1) node[above, ocirc]{}
6439 (T.B2) -- (GND);
6440 \end{circuitikz}
6441 \end{ctikzExample}
6442
6443
6444 \subsubsection{Styling transformer's coils independently}
6445 \label{sec:styling-transformer-s}
6446
6447 Since \texttt{0.9.6}, you can tweak the style of each of the coils of the transformers by
6448 changing the value of the two styles \IndexKey{transformer L1} and \IndexKey{transformer L2};
6449 the default for both are \texttt{\{\}}, that means inherit the inductors style in force.
6450
6451 \begin{ctikzExample}[pos=t]
6452 \begin{circuitikz}[american]
6453 \begin{scope}
6454 \ctikzset{transformer L1/.style={inductors/coils=1, inductors/width=0.2}}
6455 \draw (0,0) node[transformer core](T1){};
6456 \end{scope}
6457 \draw (3,0) node[transformer](T2){};
6458 \ctikzset{cute inductors, quadpoles style=inline}
6459 \ctikzset{transformer L1/.style={inductors/coils=2, inductors/width=0.2}}
6460 \draw (6,0) node[transformer core](T3){};
6461 \ctikzset{transformer L1/.style={american inductors, inductors/coils=1, inductors/width=0.2}}
6462 \ctikzset{transformer L2/.style={inductors/coils=7, inductors/width=1.0}}
6463 \draw (9,0) node[transformer ](T4){};
6464 \foreach \t in {T1, T2, T3, T4} {
6465 \foreach \l in {L1, L2} {
6466 \foreach \a/\c in {a/blue, b/red}
6467 \node [circle, fill=\c, inner sep=1pt] at (\t-\l.\a) {};
6468 }
6469 }
6470 \end{circuitikz}
6471 \end{ctikzExample}
6472
6473 \textbf{Caveat:} the size of the transformer is independent from the styles for \texttt{L1} and \texttt{L2}, so they follow whatever the parameters for the inductances were before applying them. In other words, the size of the transformer could result too small if you are not careful.
6474
6475 \begin{ctikzExample}
6476 \begin{circuitikz}
6477 \ctikzset{transformer L1/.style={inductors/width=1.8, inductors/coils=13}}
6478 % too small!
6479 \draw (0,0) node[transformer core](T1){};
6480 % adjust it
6481 \ctikzset{quadpoles/transformer core/height=2.4}
6482 \draw (2.5,0) node[transformer core](T1){};
6483 \end{circuitikz}
6484 \end{ctikzExample}
6485
6486 You can obviously define a style for a ``non-standard'' transformer. For example, you can have a current transformer\footnote{Suggested by Alex Pacini on \href{https://github.com/circuitikz/circuitikz/issues/297}{GitHub}} defined like this:
6487
6488 \begin{ctikzExample}
6489 \begin{circuitikz}[
6490 TA core/.style={transformer core,
6491 % at tikz level, you have to use circuitikz/ explicitly
6492 circuitikz/quadpoles style=inline,
6493 circuitikz/transformer L1/.style={
6494 american inductors, inductors/coils=1,
6495 inductors/width=0.3},
6496 } ]
6497 \draw (0,0) node[TA core](T1){};
6498 % changes are local
6499 \draw (0,-3) node[transformer]{};
6500 \end{circuitikz}
6501 \end{ctikzExample}
6502
6503 Remember that the default \texttt{pgfkeys} directory is \texttt{/tikz} for nodes and for the options of the environment, so you \emph{have} to use the full path (with \texttt{circuitikz/}) there.
6504
6505 \subsubsection{Generic double bipoles}\label{sec:doublebipoles}
6506
6507 Generic double bipoles have more or less the same keys for size that the transformers (like \texttt{../width}, \texttt{.../inner} etc.) using the component name \IndexKey[double bipole generic]{double bipole}. Also the anchors are similar, with the main difference that the ``dot'' anchors are fixed, so they do \emph{not} adapt to the size of the component.
6508 Another important difference is that the class of the generic double bipole is \texttt{misc}, not \texttt{inductors} (which is reserved to transformers and, for an historical hiccup, to the gyrator).
6509
6510 By default, the left component is a generic impedance, and the right one is an (American-style, it will not change automatically) voltage generator. You can use \texttt{quadpoles style=inner} as shown in the rightmost drawing below.
6511
6512 \geocoord{double bipole} {\ctikzset{quadpoles style=inline}\geocoord{double bipole}}
6513
6514 The other anchors behave similarly to the transistor's ones; you also have access to the internal components nodes by using \texttt{\emph{nodename}-R} and \texttt{\emph{nodename}-L} names for the right and left element, which is supposed to be \texttt{T} in the drawing below. Be wary that given that here you can (see later) reverse the direction of one or both of the elements, the rotation (and so the anchors) is not fixed (you can see that in the blue and green examples below).
6515
6516 \begin{quote}
6517 \begin{circuitikz}[cute inductors,
6518 ]
6519 \def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, overlay,}]#3:#1}](#1){}}
6520 \tikzset{ddpinv/.style={double bipole, circuitikz/double bipole R invert}}
6521 \foreach \comp/\pos/\case in {%
6522 double bipole/0/0%
6523 ,double bipole/4/1%
6524 ,ddpinv/8/2%
6525 }{
6526 \draw (\pos, 0) node[\comp](T){};
6527 \ifcase\case
6528 \foreach \a/\d/\t in {inner dot A1/0.2/75, inner dot A2/0.2/-75, inner dot B1/0.1/-45, inner dot B2/0.1/45}
6529 \path (T.\a) \coordx(\a)[\d:\t]{red};
6530 \path (T-L.south) \coordx(T-L.south)[0.6:180]{red};
6531 \or
6532 \foreach \a/\d/\t in {outer dot A1/0.4/90, outer dot A2/0.4/-90, outer dot B1/0.2/45, outer dot B2/0.2/-45}
6533 \path (T.\a) \coordx(\a)[\d:\t]{blue};
6534 \path (T-R.a) \coordx(T-R.a)[0.6:0]{blue};
6535 \path (T-R.b) \coordx(T-R.b)[0.6:0]{blue};
6536 \path (T-R.south) \coordx(T-R.south)[0.6:0]{blue};
6537 \or
6538 \foreach \a/\t in {A1/120, A2/-120, B1/120, B2/-120, base/-90}
6539 \path (T.\a) \coordx(\a)[0.2:\t]{green!50!black};
6540 \path (T-R.a) \coordx(T-R.a)[0.6:0]{green!50!black};
6541 \path (T-R.b) \coordx(T-R.b)[0.6:0]{green!50!black};
6542 \path (T-R.north) \coordx(T-R.north)[0.6:0]{green!50!black};
6543 \fi
6544 }
6545 \end{circuitikz}
6546 \end{quote}
6547
6548 Generic double bipoles are meant to be used through a style, choosing the left and right components. The keys that let you change the components are the following ones:
6549 \begin{itemize}
6550 \item \IndexKey{double bipole L}, \IndexKey{double bipole R}: the \textbf{nodename} of the component you want on the left and right side (default: \texttt{genericshape} and \texttt{vsourceAMshape}).
6551 \item \IndexKey{double bipole L invert}, \IndexKey{double bipole R invert}: controls the direction of the element inserted (default \texttt{false} for both; that means that the left bipole goes ``down'' and the right one ``up'').
6552 \item \IndexKey{every double bipole L}, \IndexKey{every double bipole R}: a style that is enacted when drawing the component; by default it's void.
6553 \end{itemize}
6554 For example, the LED-diode double bipole at the start of the section could be obtained this way:
6555 \begin{ctikzExample}
6556 \begin{circuitikz}[
6557 led to D/.style={double bipole,
6558 % at tikz level, you have to use circuitikz/ explicitly
6559 circuitikz/double bipole L=fulllediodeshape,
6560 circuitikz/double bipole R=emptydiodeshape,
6561 circuitikz/every double bipole L/.style={diodes/scale=0.6},
6562 circuitikz/every double bipole R/.style={diodes/scale=0.6},
6563 circuitikz/double bipole R invert,
6564 },
6565 ]
6566 \draw (0,0) node[led to D]{};
6567 \end{circuitikz}
6568 \end{ctikzExample}
6569
6570 As a final example, and given that the addition of generic double bipole was stimulated by an issue opened by \href{https://github.com/circuitikz/circuitikz/issues/641}{user erwindenboer on GitHub} suggesting the addition of a \IndexKey[nullor]{nullor} shape, the nullor can be obtained like this:
6571 \begin{ctikzExample}
6572 \begin{circuitikz}[
6573 nullor/.style={double bipole,
6574 % at tikz level, you have to use circuitikz/ explicitly
6575 circuitikz/double bipole L=nullatorshape,
6576 circuitikz/double bipole R=noratorshape,
6577 circuitikz/every double bipole L/.style={sources/scale=0.5},
6578 },
6579 ]
6580 \draw (0,0) node[nullor](T1){};
6581 \end{circuitikz}
6582 \end{ctikzExample}
6583 although now adding currents and voltages is not as trivial as if the component is built with a subcircuit\dots
6584
6585
6586
6587 \subsection{Amplifiers}\label{sec:amplifiers}
6588
6589 \begin{groupdesc}
6590 \circuitdesc*{op amp}{Operational amplifier}{}( +/180/0.2, -/180/0.2, out/0/0.2, up/90/0.2, down/-90/0.2 )
6591 \circuitdesc*{en amp}{Operational amplifier compliant to DIN/EN 60617 standard}{}
6592 \circuitdesc*{fd op amp}{Fully differential operational amplifier\footnotemark}{}( out +/0/0.2, out -/0/0.2 )
6593 \footnotetext{Contributed by Kristofer M. Monisit.}
6594 \circuitdesc*{gm amp}{transconductance amplifier}{}
6595 \circuitdesc*{inst amp}{plain instrumentation amplifier}{}( up/90/0.2, down/-90/0.2, refv up/45/0.2, refv down/-45/0.2 )
6596 \circuitdesc*{fd inst amp}{Fully differential instrumentation amplifier}{}
6597 \circuitdesc*{inst amp ra}{instrumentation amplifier with amplification resistance terminals}{}( ra+/180/0.1, ra-/180/0.1 )
6598 \circuitdesc*{plain amp}{Plain amplifier, unmarked, two inputs}{A$_1$}(in up/180/0.1, in down/180/0.1, up/90/0.2, out/-90/0.2, bin up/145/0.2, bin down/-145/0.2, bout/90/0.3)
6599 \circuitdesc*{plain mono amp}{Plain amplifier, one input}{}(in/180/0.2, out/0/0.2, up/90/0.2, center/-30/0.6, bin/145/0.1, bout/45/0.3)
6600 \circuitdesc*{buffer}{Buffer}{}(in/180/0.2, out/0/0.2, center/-30/0.6, bin/145/0.1, bout/45/0.3)
6601 \circuitdesc*{plain gm mono amp}{Plain transconductance amplifier, one input\footnotemark}{}(in/180/0.2, out/0/0.2, up/90/0.2, center/-30/0.8, bin/145/0.1, bout/45/0.3)
6602 \footnotetext{Added by \href{https://github.com/circuitikz/circuitikz/pull/873}{Matthias Schweikardt}.}
6603 \end{groupdesc}
6604
6605 \subsubsection{Amplifiers anchors}\label{sec:amplifiers-anchors}
6606
6607 The op amp defines the inverting input (\texttt{-}), the non-inverting input (\texttt{+}) and the output (\texttt{out}) anchors:
6608
6609 \begin{ctikzExample}
6610 \begin{circuitikz} \draw
6611 (0,0) node[op amp] (opamp) {}
6612 (opamp.+) node[left] {$v_+$}
6613 (opamp.-) node[left] {$v_-$}
6614 (opamp.out) node[right] {$v_o$}
6615 (opamp.up) --++(0,0.5) node[vcc]{5\,\textnormal{V}}
6616 (opamp.down) --++(0,-0.5) node[vee]{-5\,\textnormal{V}}
6617 ;\end{circuitikz}
6618 \end{ctikzExample}
6619
6620 There are also two more anchors defined, \texttt{up} and \texttt{down}, for the power supplies:
6621 \begin{ctikzExample}
6622 \begin{circuitikz} \draw
6623 (0,0) node[op amp] (opamp) {}
6624 (opamp.+) node[left] {$v_+$}
6625 (opamp.-) node[left] {$v_-$}
6626 (opamp.out) node[right] {$v_o$}
6627 (opamp.down) node[ground] {}
6628 (opamp.up) ++ (0,.5) node[above] {\SI{12}{\volt}}
6629 -- (opamp.up)
6630 ;\end{circuitikz}
6631 \end{ctikzExample}
6632
6633 The fully differential op amp defines two outputs:
6634 \begin{ctikzExample}
6635 \begin{circuitikz} \draw
6636 (0,0) node[fd op amp] (opamp) {}
6637 (opamp.+) node[left] {$v_+$}
6638 (opamp.-) node[left] {$v_-$}
6639 (opamp.out +) node[right] {out +}
6640 (opamp.out -) node[right] {out -}
6641 (opamp.down) node[ground] {}
6642 ;\end{circuitikz}
6643 \end{ctikzExample}
6644
6645 The instrumentation amplifier inst amp defines also references (normally you use the \texttt{down}, unless you are flipping the component):
6646 \begin{ctikzExample}
6647 \begin{circuitikz} \draw
6648 (0,0) node[inst amp] (opamp) {}
6649 (opamp.+) node[left] {$v_+$}
6650 (opamp.-) node[left] {$v_-$}
6651 (opamp.out) node[right] {out}
6652 (opamp.up) node[vcc]{}
6653 (opamp.down) node[vee] {}
6654 (opamp.refv down) node[ground]{}
6655 (opamp.refv up) to[short, -o] ++(0,0.3)
6656 ;\end{circuitikz}
6657 \end{ctikzExample}
6658
6659 The fully differential instrumentation amplifier inst amp defines two outputs:
6660 \begin{ctikzExample}
6661 \begin{circuitikz} \draw
6662 (0,0) node[fd inst amp] (opamp) {}
6663 (opamp.+) node[left] {$v_+$}
6664 (opamp.-) node[left] {$v_-$}
6665 (opamp.out +) node[right] {out +}
6666 (opamp.out -) node[right] {out -}
6667 (opamp.up) node[vcc]{}
6668 (opamp.down) node[vee] {}
6669 (opamp.refv down) node[ground]{}
6670 (opamp.refv up) to[short, -o] ++(0,0.3)
6671 ;\end{circuitikz}
6672 \end{ctikzExample}
6673
6674 The instrumentation amplifier with resistance terminals (\texttt{inst amp ra}) also defines terminals to add an amplification resistor:
6675 \begin{ctikzExample}
6676 \begin{circuitikz} \draw
6677 (0,0) node[inst amp ra] (opamp) {}
6678 (opamp.+) node[left] {$v_+$}
6679 (opamp.-) node[left] {$v_-$}
6680 (opamp.out) node[right] {out}
6681 (opamp.up) node[vcc]{}
6682 (opamp.down) node[vee] {}
6683 (opamp.refv down) node[ground]{}
6684 (opamp.refv up) to[short, -o] ++(0,0.3)
6685 (opamp.ra-) to[R] (opamp.ra+)
6686 ;\end{circuitikz}
6687 \end{ctikzExample}
6688
6689 Amplifiers also have ``border''\IndexKey[amplifier border anchors]{} anchors (just add \texttt{b}, without space, to the anchor, like \texttt{b+} or \texttt{bin up} and so on). These can be useful to add ``internal components'' or to modify the component. Also the \IndexKey{leftedge} anchor (on the border midway between input) is available.
6690
6691 \begin{ctikzExample}
6692 \begin{circuitikz}[]
6693 \draw (0,2.2) node[op amp](OA){IA1};
6694 \node[oosourceshape, rotate=90, scale=0.5]
6695 at (OA.leftedge) {};
6696 \draw (0,0) node[plain amp](A){$A$};
6697 \draw [color=red] (A.bin up) -- ++(0.2,0)
6698 coordinate (tmp)
6699 to[R, resistors/scale=0.5]
6700 (tmp|-A.bin down) -- (A.bin down);
6701 \end{circuitikz}
6702 \end{ctikzExample}
6703
6704 \subsubsection{Amplifiers customization}\label{sec:amplifiers-customization}
6705
6706 You can scale the amplifiers using the key \IndexKey{amplifiers/scale} and setting it to something different from \texttt{1.0}. The font used for symbols will not scale, so it's your responsibility to change it if the need arises.
6707
6708 \paragraph{Input polarity.}
6709 \label{par:input-polarity}
6710 All these amplifiers have the possibility to flip input and output (if needed) polarity. You can change polarity of the input with the
6711 \IndexKey{noinv input down} (default) or \IndexKey{noinv input up} key; and the output with \IndexKey{noinv output up} (default) or \IndexKey{noinv output down} key:
6712 \begin{ctikzExample}
6713 \begin{circuitikz} \draw
6714 (0,0) node[fd inst amp,
6715 noinv input up,
6716 noinv output down] (opamp) {}
6717 (opamp.+) node[left] {$v_+$}
6718 (opamp.-) node[left] {$v_-$}
6719 (opamp.out +) node[right] {out +}
6720 (opamp.out -) node[right] {out -}
6721 (opamp.up) node[vcc]{}
6722 (opamp.down) node[vee] {}
6723 (opamp.refv down) node[ground]{}
6724 (opamp.refv up) to[short, -o] ++(0,0.3)
6725 ;\end{circuitikz}
6726 \end{ctikzExample}
6727
6728 When you use the \texttt{noinv input/output ...} keys the anchors (\texttt{+}, \texttt{-}, \texttt{out +}, \texttt{out -}) will change with the effective position of the terminals. You also have the anchors \IndexKey{in up}, \IndexKey{in down}, \IndexKey{out up}, \IndexKey{out down} that will not change with the positive or negative sign.
6729
6730 \paragraph{Input and output pins symbols.}
6731 \label{par:input-and-output}
6732 You can change the symbols ``$+$'' or ``$-$'' appearing in the amplifiers if you want, both globally and on component-by-component basis. The plus and minus symbols can be changed with \verb|\ctikzset| of the keys \IndexKey{amplifiers/plus} and \IndexKey{amplifiers/minus} (which defaults to the math mode plus or minus cited before), or using the styles \IndexKey{amp plus} and \IndexKey{amp minus}.
6733
6734 The font used is set in several keys, but you can change it globally with \IndexKey[amp symbol font]{}\texttt{\textbackslash tikzset\{amp symbol font\}}, which has a default of 10-point (in \LaTeX, and the corresponding one in \ConTeXt). You can change it for example with
6735 \begin{lstlisting}
6736 \tikzset{amp symbol font={%
6737 \color{blue}\fontsize{12}{12}\selectfont\boldmath}}
6738 \end{lstlisting}
6739 to have plus and minus symbols that are bigger and blue.
6740
6741 \begin{ctikzExample}
6742 \begin{circuitikz}[]
6743 % change in this circuit only
6744 \tikzset{amp symbol font={\color{blue}\small\boldmath}}
6745 % local change
6746 \draw (0,2.2) node[op amp, amp plus=$\oplus$]{};
6747 \draw (0,0) node[op amp]{};
6748 % from now on...
6749 \ctikzset{amplifiers/plus={$\oplus$}}
6750 \ctikzset{amplifiers/minus={$\ominus$}}
6751 \draw (0,-2.2) node[fd op amp]{};
6752 \end{circuitikz}
6753 \end{ctikzExample}
6754
6755 You can remove the symbols by setting them to the null symbol \texttt{\{\}}.
6756 If you want different symbols for input and output you can use a null symbol and put them manually using the border anchors.
6757
6758 \begin{ctikzExample}
6759 \begin{circuitikz}[]
6760 % unset ampflier symbols
6761 \ctikzset{amplifiers/plus={}}
6762 \ctikzset{amplifiers/minus={}}
6763
6764 % place a transconductor without symbols
6765 \draw (0,2.2) node[gm amp](A){$G_\mathrm{m}$};
6766
6767 % fully differential op amp with 1, 2, 3 and 4 as symbols
6768 \draw (0,0) node[fd op amp](A){};
6769 \node [font=\small\bfseries, right] at(A.bin up) {1};
6770 \node [font=\small\bfseries, right] at(A.bin down) {2};
6771 \node [font=\small\bfseries, below] at(A.bout up) {3};
6772 \node [font=\small\bfseries, above] at(A.bout down) {4};
6773 \end{circuitikz}
6774 \end{ctikzExample}
6775
6776 \paragraph{Input and output pins length.}
6777 \label{par:input-and-output-pin-lengths}
6778 The length of the wires that extends outside the main amplifier shape is not easily changed globally. You can use a trick\footnote{See the discussion with \href{https://github.com/circuitikz/circuitikz/issues/645}{user @erwindenboer on GitHub};notice that this method is using internal keys and can stop working in the future.} though if you want to remove them completely:
6779 the size of an amplifier (included the pins) is set by the \texttt{circuitikz} key \texttt{tripoles/\emph{amplifier style}/width} and the size of the body of the amplifier, relative to it, is set by the key\texttt{tripoles/\emph{amplifier style}/port width}.
6780 Making the latter equal to one will set the length of the pin to zero\IndexKey[amplifier pin length]{}; if you want to maintain the same aspect ratio of the shape you need to compensate with the width.
6781
6782 For example, for the normal operational amplifier the key \IndexKey{tripoles/op amp/width} defaults to 1.7 and \IndexKey{tripoles/op amp/port width} is 0.7 (you need to peek that values in the source file \IndexKey{pgfcirctripoles.tex}). So you can do this:
6783
6784 \begin{ctikzExample}
6785 \begin{tikzpicture}[]
6786 \draw (0,0) node[op amp](A){};
6787 \ctikzset{tripoles/op amp/port width=1,
6788 tripoles/op amp/width=1.19, % 1.7*0.7
6789 }
6790 \draw (2.5,0) node[op amp](B){};
6791 \draw
6792 (A.out) node[red, circ]{} (A.+) node[blue, circ]{}
6793 (B.out) node[red, circ]{} (B.+) node[blue, circ]{};
6794 \end{tikzpicture}
6795 \end{ctikzExample}
6796
6797 \paragraph{Main amplifier label.} The amplifier label (given as the text of the node) is normally more or less centered in the shape (in the case of the triangular shape, it is shifted a bit to the left to \emph{seem} visually centered); since version \texttt{1.1.0} you can move it at the left side plus a fixed offset setting the key \IndexKey{component text} or the style with the same name to \texttt{left}; by default the key is \texttt{center}.
6798 \label{par:main-amplifier-label}
6799 You can change the offset with the key \IndexKey{left text distance} (default \texttt{0.3em}; you must use a length here). These parameters are shared with IEEE-style logic ports.
6800
6801 \begin{ctikzExample}
6802 \begin{circuitikz}[]
6803 \draw (0,2.5) node[plain amp]{\texttt{741}};
6804 \draw (3,2.5)
6805 node[plain amp, component text=left]
6806 {\texttt{741}};
6807 \ctikzset{component text=left}
6808 \draw (0,0) node[op amp]{\texttt{741}};
6809 \ctikzset{left text distance=0.6em}
6810 \draw (3,0) node[op amp]{\texttt{741}};
6811 \end{circuitikz}
6812 \end{ctikzExample}
6813
6814 These keys are also used for the positioning of the labels in the label positioning of IEEE logic gates (see~\ref{sec:ieeestdports}).
6815
6816 \paragraph{European-style amplifier customization.}
6817 \label{par:european-style-amplifier}
6818 Thanks to the suggestions from David Rouvel (\email{[email protected]}) there are several possible customization for the European-style amplifiers.
6819
6820 Since 0.9.0, the default appearance of the symbol has changed to be more in line with the standard; notice that to have a bigger triangle by default we should require more packages, and I fear {Con\TeX t} compatibility; but see later on how to change it. Notice that the font used for the symbol is defined in \IndexKey{tripoles/en amp/font2} and that the font used for the \texttt{+} and \texttt{-} symbols is \IndexKey{tripoles/en amp/font}.
6821
6822 You can change the distances of the inputs, using \IndexKey{tripoles/en amp/input height} (default 0.3):
6823
6824 \begin{ctikzExample}
6825 \begin{circuitikz}
6826 \ctikzset{tripoles/en amp/input height=0.45}
6827 \draw (0,0)node[en amp](E){}
6828 (E.out) node[right] {$v_{\mathrm{out}}$}
6829 (E.-) node[left] {$v_{\mathrm{in}-}$}
6830 (E.+) node[left] {$v_{\mathrm{in}+}$};
6831 \end{circuitikz}
6832 \end{ctikzExample}
6833
6834 and of course the key \IndexKey{noinv input up} is fully functional:
6835
6836 \begin{ctikzExample}
6837 \begin{circuitikz}
6838 \ctikzset{tripoles/en amp/input height=0.45}
6839 \draw (0,0)node[en amp, noinv input up](E){}
6840 (E.out) node[right] {$v_{\mathrm{out}}$}
6841 (E.-) node[left] {$v_{\mathrm{in}-}$}
6842 (E.+) node[left] {$v_{\mathrm{in}+}$};
6843 \end{circuitikz}
6844 \end{ctikzExample}
6845
6846 To flip the amplifier in the horizontal direction, you can use \texttt{xscale=-1} as usual:
6847
6848 \begin{ctikzExample}
6849 \begin{circuitikz}
6850 \ctikzset{tripoles/en amp/input height=0.45}
6851 \draw (0,0)node[en amp, xscale=-1, noinv input up](E){}
6852 (E.out) node[left] {$v_{\mathrm{out}}$}
6853 (E.-) node[right] {$v_{\mathrm{in}-}$}
6854 (E.+) node[right] {$v_{\mathrm{in}+}$};
6855 \end{circuitikz}
6856 \end{ctikzExample}
6857
6858 Notice that the label is fully mirrored, so check below for the generic way to change this.
6859
6860 You can use the new key \IndexKey{en amp text A} to change the infinity symbol with an A:
6861
6862 \begin{ctikzExample}
6863 \begin{circuitikz}
6864 \draw (0,0)node[en amp, en amp text A](E){}
6865 (E.out) node[right] {$v_{\mathrm{out}}$}
6866 (E.-) node[left] {$v_{\mathrm{in}-}$}
6867 (E.+) node[left] {$v_{\mathrm{in}+}$} ;
6868 \end{circuitikz}
6869 \end{ctikzExample}
6870
6871 And if you want, you can completely change the text using the key \IndexKey{en amp text={}}, which by default is \verb|$\mathstrut{\triangleright}\,{\infty}$|:
6872
6873 \begin{ctikzExample}
6874 \begin{circuitikz}
6875 \draw (0,0)node[en amp, en amp text={%
6876 ${\triangleright}$ \small 200}](E){}
6877 (E.out) node[right] {$v_{\mathrm{out}}$}
6878 (E.-) node[left] {$v_{\mathrm{in}-}$}
6879 (E.+) node[left] {$v_{\mathrm{in}+}$} ;
6880 \end{circuitikz}
6881 \end{ctikzExample}
6882
6883 Notice two things here: the first, that \verb|\triangleright| is enclosed in braces to remove the default spacing it has as a binary operator, and that \texttt{en amp text A} is simply a shortcut for
6884
6885 \begin{lstlisting}
6886 en amp text={$\mathstrut{\triangleright}\,\mathrm{A}$}
6887 \end{lstlisting}
6888
6889
6890 To combine flipping with a generic label you just do:
6891
6892 \begin{ctikzExample}
6893 \begin{circuitikz}
6894 \draw (0,0)node[en amp, xscale=-1, en amp text A](E){}
6895 (E.out) node[left] {$v_{\mathrm{out}}$}
6896 (E.-) node[right] {$v_{\mathrm{in}-}$}
6897 (E.+) node[right] {$v_{\mathrm{in}+}$} ;
6898 \end{circuitikz}
6899 \end{ctikzExample}
6900
6901 But notice that the ``A'' is also flipped by the \texttt{xscale} parameter. So the solution in this case is to use \texttt{scalebox}, like this:
6902
6903 \begin{ctikzExample}
6904 \begin{circuitikz}
6905 \draw (0,0)node[en amp, xscale=-1, en amp text={%
6906 ${\triangleright}$ \scalebox{-1}[1]{\small 200}}](E){}
6907 (E.out) node[left] {$v_{\mathrm{out}}$}
6908 (E.-) node[right] {$v_{\mathrm{in}-}$}
6909 (E.+) node[right] {$v_{\mathrm{in}+}$} ;
6910 \end{circuitikz}
6911 \end{ctikzExample}
6912
6913
6914 \subsubsection{Designing your own amplifier}\label{sec:muxdemux-amplis}
6915
6916 If you need a different kind of amplifier\IndexKey[amplifier, generic shapes]{}, you can use the \IndexKey[amplifiers defined with muxdemux]{muxdemux}
6917 (see section~\ref{sec:muxdemuxes}) shape for defining one that suits your needs
6918 (you need version \texttt{1.0.0} for this to work,
6919 and \texttt{1.3.8} for the \texttt{draw only...} option).
6920
6921 \begin{ctikzExample}
6922 \tikzset{tdax/.style={muxdemux,
6923 muxdemux def={NL=2, Lh=3, NR=1, Rh=0,
6924 NB=4, NT=5}, font=\scriptsize\ttfamily}}
6925 \begin{circuitikz}
6926 \draw (0,0) node[tdax](A){TDA1};
6927 \draw (2.5,0) node[tdax, muxdemux def={Rh=0.5},
6928 draw only top pins={1,4-5}]{TDA2};
6929 \end{circuitikz}
6930 \end{ctikzExample}
6931
6932
6933 \subsection{Switches, buttons and jumpers}
6934 \label{sec:switches-buttons-and}
6935
6936 Switches and buttons come in to-style (the simple ones and the pushbuttons), and as nodes.
6937
6938 The switches can be scaled with the key \IndexKey{switches/scale} (default \texttt{1.0}). Notice that scaling the switches will not scale the poles, which are controlled with their own parameters (see section~\ref{sec:terminals}).
6939
6940 \subsubsection{Traditional switches}
6941 \label{sec:traditional-switches}
6942 These are all of the to-style type:
6943
6944 \begin{groupdesc}
6945 \circuitdescbip[cspst]{switch}{Switch}{spst}(left/135/0.1, right/45/0.1, mid/90/0.3)
6946 \circuitdescbip[cspst]{closing switch}{Closing switch}{cspst}
6947 \circuitdescbip[ospst]{opening switch}{Opening switch}{ospst}
6948 \circuitdescbip[nos]{normal open switch}{Normally open switch}{nos}(left/135/0.1, right/45/0.1, mid/90/0.3)
6949 \circuitdescbip[ncs]{normal closed switch}{Normally closed switch}{ncs}
6950 \circuitdescbip[oncs]{opening normal closed switch}{Opening normally closed switch}{oncs}
6951 \circuitdescbip[cncs]{closing normal closed switch}{Closing normally closed switch}{cncs}
6952 \circuitdescbip[onos]{opening normal open switch}{Opening normally open switch}{onos}
6953 \circuitdescbip[cnos]{closing normal open switch}{Closing normally open switch\footnotemark}{cnos}
6954 \footnotetext{These last four were contributed by \href{https://tex.stackexchange.com/questions/693446/new-switch-components-for-circuitikz}{Jakob Leide}}
6955 \circuitdescbip[pushbutton]{push button}{Normally open push button}{normally open push button, nopb}(tip/0/0.2, mid/-90/0.2)
6956 \circuitdescbip[ncpushbutton]{normally closed push button}{Normally closed push button}{ncpb}(tip/0/0.2, mid/-90/0.2)
6957 \circuitdescbip[pushbuttonc]{normally open push button closed}{Normally open push button (in closed position)}{nopbc}(tip/0/0.2, mid/-90/0.2)
6958 \circuitdescbip[ncpushbuttono]{normally closed push button open}{Normally closed push button (in open position)}{ncpbo}(tip/0/0.2, mid/-90/0.2)
6959 \circuitdescbip[toggleswitch]{toggle switch}{Toggle switch}{}(out 1/0/0.2, out 2/0/0.2, in/135/0.1, mid/-90/0.2)
6960 \circuitdescbip*{reed}{Reed switch}{}(left/135/0.1, right/45/0.1, mid/90/0.3)
6961 \end{groupdesc}
6962
6963 while this is a node-style component:
6964
6965 \begin{groupdesc}
6966 \circuitdesc{spdt}{spdt}{}(in/180/0.2, out 1/0/0.2, out 2/0/0.2, mid/90/0.2)
6967 \end{groupdesc}
6968
6969 \begin{ctikzExample}
6970 \begin{circuitikz} \draw
6971 (0,0) node[spdt] (Sw) {}
6972 (Sw.in) node[left] {in}
6973 (Sw.out 1) node[right] {out 1}
6974 (Sw.out 2) node[right] {out 2}
6975 ;\end{circuitikz}
6976 \end{ctikzExample}
6977
6978 \begin{ctikzExample}
6979 \begin{circuitikz} \draw
6980 (0,0) to[C] (1,0) to[toggle switch , n=Sw] (2.5,0)
6981 -- (2.5,-1) to[battery1] (1.5,-1) to[R] (0,-1) -| (0,0)
6982 (Sw.out 2) -| (2.5, 1) to[R] (0,1) -- (0,0)
6983 ;\end{circuitikz}
6984 \end{ctikzExample}
6985
6986 \subsubsection{Cute switches}
6987 \label{sec:cute-switches}
6988 These switches have been introduced after version 0.9.0, and they come in also in to-style and in node-style, but they are size-matched so that they can be used together in a seamless way.
6989
6990 The path element (to-style) are:
6991 \begin{groupdesc}
6992 \circuitdescbip[cuteclosedswitch]{cute closed switch}{Cute closed switch}{ccsw}(mid/90/0.2, in/-135/0.2, out/-45/0.2)
6993 \circuitdescbip[cuteopenswitch]{cute open switch}{Cute open switch}{cosw}(out/45/0.2)[out.s/-90/0.2]
6994 \circuitdescbip[cuteclosingswitch]{cute closing switch}{Cute closing switch}{ccgsw}
6995 \circuitdescbip[cuteopeningswitch]{cute opening switch}{Cute opening switch}{cogsw}
6996 \end{groupdesc}
6997 while the node-style components are the single-pole, double-throw (\texttt{spdt}) ones:
6998 \begin{groupdesc}
6999 \circuitdesc{cute spdt up}{Cute spdt up}{}( in/180/0.2, out 1/0/0.2, out 2/0/0.2 , mid/0/0.4)
7000 \circuitdesc{cute spdt mid}{Cute spdt mid}{}
7001 \circuitdesc{cute spdt down}{Cute spdt down}{}(mid/0/0.4)
7002 \circuitdesc{cute spdt up arrow}{Cute spdt up with arrow}{}
7003 \circuitdesc{cute spdt mid arrow}{Cute spdt mid with arrow}{}
7004 \circuitdesc{cute spdt down arrow}{Cute spdt down with arrow}{}
7005 \end{groupdesc}
7006
7007
7008 \paragraph{Cute switches anchors}
7009 \label{par:cute-switches-anchors}
7010
7011 The nodes-style switches have the following anchors:
7012
7013 \bigskip
7014 \begin{circuitikz}
7015 \def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
7016 \path (0,-1) -- (3,1); %bbox
7017 \draw (0, 0) node[spdt](S){};
7018 \foreach \a/\b in {center/0, in/-135, out 1/45, out 2/-45}
7019 \path (S.\a) \coorda(\a)<\b>;
7020 \draw (3, 0) node[cute spdt up arrow](CS){};
7021 \foreach \a/\b in {center/0, in/-135, out 1/45, out 2/-45, mid/135}
7022 \path (CS.\a) \coorda(\a)<\b>;
7023 \draw (6, 0) node[cute spdt up arrow](CS2){};
7024 \foreach \a/\b in {cin/-135, cout 1/45, cout 2/-45}
7025 \path (CS2.\a) \coorda(\a)<\b>;
7026 \end{circuitikz}
7027
7028 Please notice the position of the normal anchors at the border of the \texttt{ocirc} shape for the cute switches; they are thought to be compatible with an horizontal wire going out.
7029 Additionally, you have the \texttt{cin}, \texttt{cout 1} y \texttt{cout 2} which are anchors on the center of the contacts.
7030
7031 For more complex situations, the contact nodes are available\footnote{Thanks to \texttt{@marmot} on \href{https://tex.stackexchange.com/a/492599/38080}{tex.stackexchange.com}.} using the syntax \emph{name of the node}\texttt{-in}, \dots\texttt{-out 1} and \dots\texttt{-out 2}, with all their anchors.
7032
7033 \begin{ctikzExample}
7034 \begin{circuitikz}
7035 \draw (0,0) node[cute spdt up] (S1) {}
7036 (S1.in) node[left] {in}
7037 (S1.out 1) node[right] {out 1};
7038 \draw (0,-2) node[cute spdt up,
7039 /tikz/circuitikz/bipoles/cuteswitch/height=0.8] (S2) {}
7040 (S2.in) node[left] {in}
7041 (S2.out 2) node[right] {out 2};
7042 \draw [red] (S1-in.s) -- (S2-in.n);
7043 \draw [blue] (S1-out 2.s) -- (S2-out 1.n);
7044 \end{circuitikz}
7045 \end{ctikzExample}
7046
7047 The \texttt{mid} anchor in the cute switches (both path- and node-style) can be used to combine switches to get more complex configurations:
7048
7049 \begin{ctikzExample}
7050 \begin{circuitikz}
7051 \draw (0,1.4) node[cute spdt up](S1){};
7052 \draw (0,0) node[cute spdt up](S2){};
7053 \draw (0,-1) node[cuteclosedswitchshape, yscale=-1](S3){};
7054 \draw [densely dashed] (S1.mid)--(S2.mid)--(S3.mid);
7055 \end{circuitikz}
7056 \end{ctikzExample}
7057
7058 \paragraph{Cute switches customization}
7059 \label{par:cute-switches-customization}
7060
7061 You can use the key \IndexKey{bipoles/cuteswitch/thickness} to decide the thickness of the switch lever.
7062 The units are the diameter of the \texttt{ocirc} connector, and the default is \texttt{1}.
7063
7064 \begin{ctikzExample}
7065 \begin{circuitikz}
7066 \ctikzset{bipoles/cuteswitch/thickness=0.5}
7067 \draw (0,1.4) node[cute spdt up](S1){};
7068 \draw (0,0) node[cute spdt up](S2){};
7069 \draw (0,-1) node[cuteclosedswitchshape, yscale=-1](S3){};
7070 \draw [densely dashed] (S1.mid)--(S2.mid)--(S3.mid);
7071 \end{circuitikz}
7072 \end{ctikzExample}
7073
7074 Finally, the switches are normally drawn using the \texttt{ocirc} shape, but you can change it, as in the following example, with the key \IndexKey{bipoles/cuteswitch/shape}. Be careful that the shape is used with its defaults (which can lead to strange results), and that the standard anchors will be correct only for \texttt{circ} and \texttt{ocirc} shapes, so you have to use the internal node syntax to connect it.
7075
7076 \begin{ctikzExample}
7077 \begin{circuitikz}
7078 \begin{scope}
7079 \ctikzset{bipoles/cuteswitch/thickness=0.5,
7080 bipoles/cuteswitch/shape=circ}
7081 \draw (0,2) node[cute spdt up](S1){};
7082 \ctikzset{bipoles/cuteswitch/thickness=0.25,
7083 bipoles/cuteswitch/shape=emptyshape}
7084 \draw (0,0) node[cute spdt up](S2){};
7085 \draw (S2.cin) node[draw, inner sep=2pt]{};
7086 \draw (S2.cout 1) node[draw, inner sep=2pt]{};
7087 \draw (S2.cout 2) node[draw=red, inner sep=2pt]{};
7088 \end{scope}
7089 \draw (0,-2) node[cuteclosedswitchshape, yscale=-1](S3){};
7090 \draw [densely dashed] (S1.mid)--(S2.mid)--(S3.mid);
7091 \end{circuitikz}
7092 \end{ctikzExample}
7093
7094 \subsubsection{Proximity switches}
7095 \label{sec:proximity-switches}
7096
7097 \begin{groupdesc}
7098 \circuitdesc*{proximeter}{proximeter}{text}(hlines nw/135/0.4, hlines ne/45/0.4, hlines sw/-135/0.4, hlines se/-45/0.4, center/-90/0.4)
7099 \circuitdescbip*{inline proximeter}<proximeter>{proximeter switch, inline}{}(left/135/0.4, right/45/0.4)
7100 \end{groupdesc}
7101
7102 The \texttt{proximeter} shape\footnote{Suggested by \href{https://github.com/circuitikz/circuitikz/issues/631}{Anisio Rogerio Braga}, implemented in \texttt{v1.5.2}; see also \href{https://knowledge.autodesk.com/support/autocad-electrical/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/AutoCAD-Electrical/files/GUID-1B18023D-241C-4E50-822A-94F873FC258B-htm.html}{here}.} can be used as a dipole with the \texttt{inline proximeter} variant.
7103
7104 It has been assigned to the \texttt{switches} class; you can adjust the (relative) thickness of the inside horizontal lines with the key \IndexKey{proximeter/hlines thickness} (default \texttt{0.5}) and their vertical position with \IndexKey{proximeter/hlines position} (default \texttt{0.3}). You can also change the default size of \emph{all} proximeter symbols by changing \IndexKey{proximeter/width} (only safe at picture level; better set in the preamble if you need to change it. The default value is \texttt{0.3}).
7105
7106 Notice in the following example that, as ever for node-type shape, the text is not included in the bounding box:
7107 \begin{ctikzExample}
7108 \begin{tikzpicture}
7109 \tikzset{small up proxi/.style={proximeter, solid,
7110 circuitikz/switches/scale=0.707,
7111 circuitikz/proximeter/hlines thickness=1,
7112 circuitikz/proximeter/hlines position=0.1}}
7113 \draw (0,0) to[inline proximeter, l=P1] ++(2,0)
7114 to[ccgsw, name=P2] ++(2,0);
7115 \draw[dashed] (P2.mid) -- ++(0,0.5)
7116 node[small up proxi, above](P2p){Fe}
7117 (P2p.north) ++ (0,0.5); % extend bounding box
7118 \end{tikzpicture}
7119 \end{ctikzExample}
7120
7121 \subsubsection{Rotary switches}
7122 \label{sec:rotary-switches}
7123
7124 Rotary switches are a kind of generic multipole switches; they are implemented as a strongly customizable element (and a couple of styles to simplify its usage). The basic element is the following one, and it has the same basic anchors of the cute switches, included the access to internal nodes (shown in blue here).
7125
7126 \begin{groupdesc}
7127 \circuitdesc{rotaryswitch}{Rotary switch}{}(in/-180/0.2, cin/145/0.2, center/-90/0.2, mid/0/0.4, out 1/0/0.2,
7128 cout 1/180/0.2)[out 1.n/90/0.2, out 4.w/0/0.3]
7129 \end{groupdesc}
7130
7131 Notice that the name of the shape is \IndexKey[rotary switches]{rotaryswitch}, no spaces.
7132 The default rotary switch component has 5 channels (this is set in the parameter \IndexKey{multipoles/rotary/channels}), spanning form \SI{-60}{\degree} to \SI{60}{\degree} (parameter \IndexKey{multipoles/rotary/angle}) and with the wiper at \SI{20}{\degree} (parameter \IndexKey{multipoles/rotary/wiper}).
7133
7134 Moreover, there are by default no arrows on the wiper; if needed, you can change this default setting the parameter \IndexKey{multipoles/rotary/arrow} which can assume the values \texttt{none}, \texttt{cw} (clockwise), \texttt{ccw} (counterclockwise) or \texttt{both}.
7135
7136 To simplify the usage of the component, a series of styles are defined: \IndexKey[rotary switch]{rotary switch=\textsl{<channels>} in \textsl{<angle>} wiper \textsl{<wiper angle>}} (notice the space in the name of the style!). Using \texttt{rotary switch} without parameters will generate a default switch.
7137
7138 To add arrows, you can use the styles \IndexKey{rotary switch -} (no arrow, whatever the default), \IndexKey{rotary switch <-} (counterclockwise arrow), \IndexKey{rotary switch ->} (clockwise) and \IndexKey{rotary switch <->} (both).
7139
7140 Notice that the defaults of the styles are the same as the default values of the parameters, but that if you change globally the defaults using the keys mentioned above, you only change the defaults for the ``bare'' component \texttt{rotaryswitch}, not for the styles.
7141
7142
7143 \begin{ctikzExample}[varwidth=true, pos=t]
7144 \begin{circuitikz}
7145 \ctikzset{multipoles/rotary/arrow=both}
7146 \draw (0,0) -- ++(1,0) node[rotary switch <-=8 in 120 wiper 40, anchor=in](A){};
7147 \draw (3,0) -- ++(1,0) node[rotary switch, anchor=in](B){}; % default values
7148 \draw[red] (A.out 4) -| (3,0);
7149 \draw[blue] (A-out 2.n) -- ++(0,0.5) -| (B-out 1.n);
7150 \draw (B.out 3) -- ++(1,0) node[rotary switch -=5 in 90 wiper 15, anchor=in](C){};
7151 \draw (C.out 3) -- ++(1,0) node[rotary switch ->, xscale=-1, anchor=out 3](D){};
7152 \draw[green, dashed] (B.mid) -- ++(-.5,-1) -| (C.mid);
7153 \end{circuitikz}
7154 \end{ctikzExample}
7155
7156 \paragraph{Rotary switch anchors}
7157 \label{par:rotary-switch-anchors}
7158
7159 Rotary switches anchors are basically the same as the cute switches, including access (with the \texttt{\textsl{<node name>}-<anchor name>} notation) to the internal connection nodes. The geographical anchors work as expected, marking the limits of the component.
7160
7161 \showanchors{rotary switch}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
7162 south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4, center/-120/0.3)
7163 \qquad
7164 \showanchors{rotary switch=25 in 120 wiper 10}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
7165 south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4, center/-120/0.3)
7166
7167 In addition to the anchors they have in common with the cute switches, the rotary switch has the so called ``angled'' anchors and the ``external square anchors''. \emph{Angled anchors}, called \texttt{aout 1}, \texttt{aout 2} and so forth, are anchors placed on the output poles at the same angle as the imaginary lines coming from the input pole; \emph{square anchors}, called \texttt{sqout 1}\dots, are located on an imaginary square surrounding the rotary switch on the same line.
7168
7169 \bigskip
7170
7171 \begin{circuitikz}
7172 \begin{scope}[scale=2, transform shape]
7173 \clip (-1,-.4) rectangle (1,.6);
7174 \draw (0,0) node[rotary switch=9 in 90 wiper 10](Z){};
7175 \draw [dashed, blue] (Z.cin) -- (Z.sqout 4);
7176 \end{scope}
7177 \path (Z.aout 4) \showcoord(aout 4)<-15:0.4>;
7178 \path (Z.sqout 4) \showcoord(sqout 4)<0:0.4>;
7179 \path (Z.out 3) \showcoord(out 3)<15:0.4>;
7180 \path (Z.cout 3) \showcoord(cout 3)<180:0.4>;
7181 \draw (8,0) node[rotary switch -=31 in 150 wiper 10](D){};
7182 \foreach \i in {1,...,31} \draw (D.sqout \i) -- (D.aout \i);
7183 \foreach \l/\a/\d in {north/90/0.2, north east/45/0.2, east/0/0.2,
7184 south east/-45/0.2, south/-90/0.2, south west/-135/0.2, west/180/0.2, north west/135/0.2,
7185 center/-145/0.7}
7186 \path (D.ext \l) \showcoord(ext \l)<\a:\d>;
7187 \path (D.aout 12) \showcoordb(aout 12)<-5:0.4>;
7188 \path (D.sqout 12) \showcoordb(sqout 12)<0:0.4>;
7189 \draw[blue, densely dotted] (D.ext north west) rectangle (D.ext south east);
7190 \end{circuitikz}
7191
7192 The code for the diagram at the left, above, without the markings for the anchors, is:
7193 \begin{lstlisting}[basicstyle=\small\ttfamily]
7194 \begin{circuitikz}
7195 \draw (8,0) node[rotary switch -=31 in 150 wiper 10](D){};
7196 \foreach \i in {1,...,31} \draw (D.sqout \i) -- (D.aout \i);
7197 \draw[blue, densely dotted] (D.ext north west) rectangle (D.ext south east);
7198 \end{circuitikz}
7199 \end{lstlisting}
7200
7201 One possible application for the angled and the ``on square'' anchors is that you can use them to move radially from the output poles, for example for adding numbers:
7202
7203 \begin{ctikzExample}
7204 \begin{circuitikz}
7205 \draw (0,0) node[rotary switch=13 in 120 wiper 0](S){};
7206 \foreach \i in {1,...,13} % requires "calc"
7207 \path ($(S.aout \i)!1ex!(S.sqout \i)$)
7208 node[font=\tiny\color{red}]{\i};
7209 \end{circuitikz}
7210 \end{ctikzExample}
7211
7212 Finally, notice that the value of width for the rotary switches is taken from the one for the ``cute switches'' which in turn is taken from the width of traditional \texttt{spdt} switch, so that they match (notice that the ``center'' anchor is better centered in the rotary switch, so you have to explicitly align them).
7213
7214 \begin{ctikzExample}
7215 \begin{circuitikz}
7216 \draw (0,0) node[color=blue, rotary switch=2 in 35 wiper 30,
7217 anchor=in](R){};
7218 \draw (0,-1) node[cute spdt up, anchor=in](C){};
7219 \draw (0,-2) node[color=blue, rotary switch=3 in 35 wiper 30,
7220 anchor=in](R){};
7221 \end{circuitikz}
7222 \end{ctikzExample}
7223
7224 \paragraph{Rotary switch customization}
7225 \label{par:rotary-switch-customization}
7226
7227 Apart from the basic customization seen above (number of channels, etc.) you can change, as in the cute switches, the shape used by the connection points with the parameter \IndexKey{multipoles/rotary/shape}, and the thickness of the wiper with \IndexKey{multipoles/rotary/thickness}; if you specify a negative value here, the wiper is not drawn at all\footnote{Suggested by users \texttt{kabenyuk} and \texttt{cis} on TeX-SX.com; see \href{https://tex.stackexchange.com/questions/755499/circuitkiz-customize-the-style-of-the-rotary-switch-position-display}{this question\&answer for an application}.}(but the anchors, and the additional arrow if you specify it, are still there).
7228 The optional arrow has thickness equal to the standard bipole thickness \texttt{bipoles/thickness} (default 2).
7229
7230 \begin{ctikzExample}
7231 \begin{circuitikz}
7232 \ctikzset{multipoles/rotary/thickness=0.5}
7233 \draw (0,2) node[rotary switch ->, color=blue](S1){};
7234 \ctikzset{multipoles/rotary/shape=circ}
7235 \draw (0,0) node[rotary switch ->](S2){};
7236 \ctikzset{bipoles/thickness=0.5}
7237 \draw (2,2) node[rotary switch ->, color=red](S3){};
7238 \ctikzset{multipoles/rotary/thickness=-1}
7239 \draw (2,0) node[rotary switch, color=purple](S4){};
7240 \end{circuitikz}
7241 \end{ctikzExample}
7242
7243 Finally, the size can be changed using the parameter \IndexKey{tripoles/spdt/width} (default 0.85).
7244
7245 \begin{ctikzExample}
7246 \begin{circuitikz}
7247 \draw (0,2) node[rotary switch ->, color=blue](S1){};
7248 \ctikzset{tripoles/spdt/width=1.6, fill=cyan,
7249 multipoles/rotary/shape=osquarepole}
7250 \draw (0,0) node[rotary switch ->](S2){};
7251 \end{circuitikz}
7252 \end{ctikzExample}
7253
7254 \subsubsection{Switch arrows}\label{sec:switcharrows}
7255 \label{sec:switch-arrows-sec}
7256
7257 You can change the arrow tips used in all switches (traditional and ``cute'') with the key \IndexKey{switch end arrow} (by default the key is the word ``\texttt{default}'' to obtain the default arrow, which is \texttt{latexslim}).
7258 Also you can change the start arrow with the corresponding \IndexKey{switchable start arrow} or \IndexKey{wiper start arrow} (the default value ``\texttt{default}'' is equivalent to \texttt{\{\}}, which means no arrow). The keys are settable with \verb|\ctikzset| as with \verb|\tikzset| (to ease their usage in nodes).
7259
7260 You can change that globally or locally, as ever. The tip specification is the one you can find in the \TikZ{} manual (\href{https://tikz.dev/tikz-arrows\#sec-16.4}{``Arrow Tip Specifications''}).
7261
7262 \begin{ctikzExample}
7263 \begin{circuitikz}
7264 \draw (0,2) to[cspst] ++(2,0)
7265 node[cute spdt up arrow, anchor=in]{};
7266 \draw (0,0) to[cspst] ++(2,0)
7267 node[cute spdt up arrow, anchor=in,
7268 switch start arrow={Bar[red]},
7269 switch end arrow={Triangle[blue]}]{};
7270 \end{circuitikz}
7271 \end{ctikzExample}
7272
7273 You can also have the option to change the color, relative thickness, and dash pattern by setting keys with the \verb!\ctikzset! command under the \IndexKey[switch arrows]{switch arrows customization} hierarchy. The available keys are:
7274
7275 \begin{center}
7276 \begin{tabular}{>{\ttfamily}l>{\ttfamily}lp{0.5\linewidth}}
7277 \toprule
7278 parameter & default & description \\
7279 \midrule
7280 relative thickness & 1.0 & multiply the class thickness \\
7281 color & default & stroke color: \texttt{default} is the same as the component \\
7282 dash & default & dash pattern: \texttt{default} means not to change the setting for the component; \texttt{none} means unbroken line; every other input is a dash pattern.\footnotemark \\
7283 \bottomrule
7284 \end{tabular}
7285 \footnotetext{Follows the syntax of the pattern sequence \texttt{\textbackslash pgfsetdash} --- see \TikZ{} manual \href{https://tikz.dev/tikz-actions\#sec-15.3.2}{for details}; phase is always zero. Basically you pass pairs of dash-length -- blank-length dimensions, see the examples.}
7286 \end{center}
7287
7288 \begin{ctikzExample}
7289 \begin{circuitikz}
7290 \draw (0,2) to[spst] ++(1,0) to[cogsw]
7291 ++(1,0) to[oncs] ++(1,0);
7292 \ctikzset{switch arrows/color=red}
7293 \ctikzset{switch arrows/relative thickness=0.5}
7294 \ctikzset{switch arrows/dash={{1pt}{1pt}}}
7295 \draw (0,0) to[spst] ++(1,0) to[cogsw, switch arrows/dash=none]
7296 ++(1,0) to[oncs, switch arrows/color=blue] ++(1,0);
7297 \end{circuitikz}
7298 \end{ctikzExample}
7299
7300 \paragraph{Rotary switch arrows.} You can change the rotary switch arrow shape in the same way as you change the ones in regular switches. Notice however that if you set either \texttt{switch end arrow} or \texttt{switch start arrow} they will be followed only if you have set both arrows with \texttt{<->} or equivalent, otherwise just one will be used.
7301 \label{par:rotary-switch-arrows}
7302
7303 \begin{ctikzExample}[varwidth=true, pos=t]
7304 \begin{circuitikz}
7305 \ctikzset{multipoles/rotary/arrow=both}
7306 \draw (0,0) -- ++(1,0) node[rotary switch <-=8 in 120 wiper 40, anchor=in](A){};
7307 \draw (3,0) -- ++(1,0) node[rotary switch, anchor=in](B){}; % default values
7308 \draw (B.out 3) -- ++(1,0) node[rotary switch -=5 in 90 wiper 15, anchor=in](C){};
7309 \draw (C.out 3) -- ++(1,0) node[rotary switch ->, xscale=-1, anchor=out 3](D){};
7310 \ctikzset{switch end arrow={Triangle[blue]}}
7311 \ctikzset{switch start arrow={Bar[red]}}
7312 \begin{scope}[yshift=-2cm]
7313 \draw (0,0) -- ++(1,0) node[rotary switch <-=8 in 120 wiper 40, anchor=in](A){};
7314 \draw (3,0) -- ++(1,0) node[rotary switch, anchor=in](B){}; % default values
7315 \draw (B.out 3) -- ++(1,0) node[rotary switch -=5 in 90 wiper 15, anchor=in](C){};
7316 \draw (C.out 3) -- ++(1,0) node[rotary switch ->, xscale=-1, anchor=out 3](D){};
7317 \end{scope}
7318 \end{circuitikz}
7319 \end{ctikzExample}
7320
7321 \subsubsection{Jumpers}
7322 \label{sec:jumpers}
7323
7324 You can think of jumpers like a kind of switches (they have the same function, just the way of operating them is different).
7325 \Circuitikz{} has two types of jumper symbols available, the simple ones and the three pins (or two-ways) ones.
7326
7327 \paragraph{Simple jumpers.} These are the most common ones. They come in three variations, bare, open and closed.
7328 \label{par:simple-jumpers}
7329
7330 \begin{groupdesc}
7331 \circuitdescbip*[bjumper]{bare jumper}{Bare jumper}{}(in/135/0.6, out/45/0.6)[out.n/90/0.2]
7332 \circuitdescbip*[ojumper]{open jumper}{Open jumper}{}(in/135/0.6, out/45/0.6, top arc/90/0.3)[out.s/-90/0.2]
7333 \circuitdescbip*[cjumper]{closed jumper}{Closed jumper}{}(left/135/0.6, right/45/0.6, top arc/90/0.3)[in.s/-90/0.2]
7334 \end{groupdesc}
7335
7336 The \texttt{top arc} anchor can be used to locate the position of the top of the wire (when present). In bare jumper, the anchor is located in the middle of the connectors gap.
7337
7338 \begin{ctikzExample}
7339 \begin{circuitikz}[scale=0.8]
7340 \draw (0,0) to[open jumper, l=J1] ++(2,0)
7341 to[closed jumper, l_=J2, name=J2] ++(2,0)
7342 to[bare jumper=J3] ++(2,0);
7343 \draw [dashed] (J2.top arc) -- ++(0,0.5)
7344 node[above] {\tiny open to enable};
7345 \end{circuitikz}
7346 \end{ctikzExample}
7347
7348 Similarly to switches, you have access to the subnodes representing the contacts, to be able to draw wires at different angles.
7349
7350 The kind of poles used in the diagram can be changed with the \verb!\ctikzset! key \IndexKey{bipoles/jumpers/shape}.
7351
7352 \begin{ctikzExample}
7353 \begin{circuitikz}[scale=0.8]
7354 \draw (0,0) to[open jumper, l=J1, name=J1] ++(2,0)
7355 to[closed jumper, l_=J2, name=J2,
7356 bipoles/jumper/shape=odiamondpole] ++(2,0);
7357 \draw [red] (J2-in.-135) -- ++(-135:1)
7358 node[font=\tiny, below]{marked \emph{hot}};
7359 \end{circuitikz}
7360 \end{ctikzExample}
7361
7362 \paragraph{Two-ways (three-pins) jumpers.} In this case, the symbol represent two-ways jumpers (normally, three pins that can be connected in a couple of ways).
7363 \label{par:two-ways-three}
7364
7365 To maintain flexibility, every possible combination of bare, open or closed is available; but to avoid having to define too much different bipoles, a different approach is used here. You have to specify the style using a different key, namely \IndexKey{tjumper connections}.
7366
7367 \begin{groupdesc}
7368 \circuitdescbip*[tjumper]{three-pins jumper}{Three-pins jumper (see later for connections)}{}(in/135/0.6, out/45/0.6, tap/-90/0.2)[out.n/90/0.2]
7369 \ctikzset{tjumper connections=12}
7370 \circuitdescbip*[tjumper]{three-pins jumper}{Three-pins jumper (connections \texttt{\ctikzvalof{tjumper connections}})}{}(top arc left/135/0.6, top arc right/45/0.6, tap/-145/0.2)[out.n/-90/0.2]
7371 \ctikzset{tjumper connections=S1}
7372 \circuitdescbip*[tjumper]{three-pins jumper}{Three-pins jumper (connections \texttt{\ctikzvalof{tjumper connections}})}{}(top arc left/135/0.6, top arc right/45/0.6, tap/-145/0.2)[out.n/-90/0.2]
7373 \end{groupdesc}
7374
7375 The option is used as shown in the following example, or by setting the key using \verb!\ctikzset!. The value \textbf{must} be two characters, either two numbers (where \texttt{0} means ``bare'', \texttt{1} means ``open'', and \texttt{2} means ``closed'') or the letter \texttt{S} (for ``span'') and one number. In the latter case, the arc will connect the fist and last pole\footnote{Although really I never saw an example of this use\dots You never know.}
7376
7377 \begin{ctikzExample}[varwidth=true, pos=t]
7378 \begin{circuitikz}
7379 \draw (0,1.5) to[three-pins jumper, l=J1, name=T] ++(3,0)
7380 to[three-pins jumper, tjumper connections=21, l=J2] ++(3,0)
7381 to[three-pins jumper, tjumper connections=20, l=J3] ++(3,0);
7382 \draw (T.tap) -- ++(0,-0.5);
7383 \ctikzset{bipoles/jumper/shape=osquarepole}
7384 \draw (0,0) to[three-pins jumper, l=JA, name=T] ++(3,0)
7385 to[three-pins jumper, tjumper connections=S1, l=JB] ++(3,0)
7386 to[three-pins jumper, tjumper connections=S2, l=JB] ++(3,0);
7387 \end{circuitikz}
7388 \end{ctikzExample}
7389
7390 \subsubsection{Solder jumpers.} Solder jumpers are basically jumpers that can be closed or opened on the printed circuit board. Although electrically they behave exactly as jumpers, these are thought to change configurations in a more stable way (to change them from their default connection you have to use a cutter and/or a soldering iron).
7391 \label{sec:solder-jumpers}
7392
7393 \begin{groupdesc}
7394 \circuitdescbip[osjumper]{open solder jumper}{Open solder jumper}{}(in/135/0.3, out/45/0.3)
7395 \circuitdescbip[csjumper]{closed solder jumper}{Closed solder jumper}{}(left/135/0.3, right/45/0.3)
7396 \circuitdescbip[odsjumper]{open double solder jumper}{Open double solder jumper}{}(in/135/0.3, out/45/0.3, tap/90/0.1)
7397 \circuitdescbip[ldsjumper]{left double solder jumper}{Left double solder jumper}{}(left/135/0.3, right/45/0.3,
7398 tap up/90/0.1, tap down/-90/0.1)
7399 \circuitdescbip[rdsjumper]{right double solder jumper}{Right double solder jumper}{}(left/135/0.3, right/45/0.3,
7400 tap up/90/0.1, tap down/-90/0.1)
7401 \circuitdescbip[cdsjumper]{closed double solder jumper}{Closed double solder jumper}{}
7402 \end{groupdesc}
7403
7404 \begin{ctikzExample}
7405 \begin{circuitikz}[scale=0.8]
7406 \draw (0,0) to[open solder jumper, l=J1] ++(2,0)
7407 to[closed solder jumper, l_=J2, name=J2] ++(2,0)
7408 to[right double solder jumper, l=J3,
7409 name=J3] ++(2,0);
7410 \draw (J3.tap down) -- ++(0,-1) node[ocirc]{};
7411 \end{circuitikz}
7412 \end{ctikzExample}
7413
7414
7415 \subsection{Logic gates}
7416 \label{sec:logic-gates}
7417
7418 Logic gates, with two or more input, are supported. Albeit in principle these components are multipoles, the are considered tripoles here, for historical reasons (when they just had two inputs).
7419
7420 \subsubsection{American Logic gates}
7421 \label{sec:american-logic-gates}
7422 \begin{groupdesc}
7423 \circuitdesc*{american and port}{American \textsc{and} port}{}( in 1/180/0.2, in 2/180/0.2, out/0/0.2 )
7424 \circuitdesc*{american or port}{American \textsc{or} port}{}( bin 1/135/0.2, bin 2/-135/0.2, bout/-45/0.2 )
7425 \circuitdesc*{american nand port}{American \textsc{nand} port}{}
7426 \circuitdesc*{american nor port}{American \textsc{nor} port}{}
7427 \circuitdesc*{american xor port}{American \textsc{xor} port}{}
7428 \circuitdesc*{american xnor port}{American \textsc{xnor} port}{}
7429 \circuitdesc*{american buffer port}{American \textsc{buffer} port}{}
7430 \circuitdesc*{american not port}{American \textsc{not} port}{}
7431 \end{groupdesc}
7432
7433 There is no ``european'' version of the following symbols; for now they are used both in \texttt{american} and \texttt{european} styles, but iy may change in the future.
7434
7435 \begin{groupdesc}
7436 \circuitdesc*{schmitt}{Non-Inverting Schmitt trigger}{}
7437 \circuitdesc*{invschmitt}{Inverting Schmitt trigger}{}
7438 \end{groupdesc}
7439
7440 \subsubsection{IEEE logic gates}\label{sec:ieeestdports}
7441
7442 In addition to the legacy ports, since release 1.1.0, logic ports following the recommended geometry of distinctive-shape symbols in IEEE Std 91a-1991 Annex A (Recommended symbol proportions) are also available\footnote{Thanks to Jason for proposing it and digging out the info, see this \href{https://github.com/circuitikz/circuitikz/issues/383}{GitHub issue}.}.
7443
7444 These ports are completely independent from the legacy set (either \texttt{american} or \texttt{european}); they are not enabled by default because the relative size of the ports is very different from the legacy ones, and that will disrupt every schematic (especially if drawn with absolute coordinate). If you want to use them as default, you can use the command \IndexKey[logic ports=ieee]{}\verb|\ctikzset{logic ports=ieee}| and by default the shapes \texttt{and port}, \texttt{or port} and so on will be the IEEE standard ones.
7445
7446 The transmission gate (also known as ``bowtie'') components are not described in the IEEE standard, so they are simply inspired by the other IEEE ports --- this is why their name is prefixed by \texttt{ieee} and not by \texttt{ieeestd}. They are aliased to \texttt{tgate} and \texttt{double tgate} though, and it is recommended to use those names (maybe in the future there will be \texttt{american ports} and/or \texttt{european ports} versions available).
7447
7448 \begin{groupdesc}
7449 \circuitdesc*{ieeestd and port}{IEEE standard ``and'' port}{}(in 1/180/0.2, in 2/180/0.2, out/0/0.2, bout/45/0.2)
7450 \circuitdesc*{ieeestd nand port}{IEEE standard ``nand'' port}{}(in 1/180/0.2, out/0/0.2, bout/45/0.2)
7451 \circuitdesc*{ieeestd or port}{IEEE standard ``or'' port}{}(in 1/180/0.2, bin 2/-155/0.2, out/0/0.2, bout/45/0.2)
7452 \circuitdesc*{ieeestd nor port}{IEEE standard ``nor'' port}{}(left/180/0.2, center/-45/0.4, up/30/0.2,
7453 down/-30/0.2)[not/45/0.3]
7454 \circuitdesc*{ieeestd xor port}{IEEE standard ``xor'' port xor}{}(left/180/0.2, bin 1/145/0.3, ibin 1/45/0.3, right/45/0.2)
7455 \circuitdesc*{ieeestd xnor port}{IEEE standard ``xnor'' port}{}(body left/70/0.4, body right/-70/0.3,
7456 out/0/0.2, bout/45/0.2)
7457 \circuitdesc*{ieeestd buffer port}{IEEE standard buffer port}{}(in 1/180/0.2, bin 1/-155/0.2, up/30/0.2, down/-30/0.2, out/0/0.2, bout/45/0.2)
7458 \circuitdesc*{ieeestd not port}{IEEE standard ``not'' port}{}(in/180/0.2, bin/-155/0.2, out/0/0.2, bout/45/0.2)
7459 \circuitdesc*{ieeestd schmitt port}{Schmitt port matched to IEEE standard ports}{}(in/180/0.2, out/0/0.2, bout/45/0.2)
7460 \circuitdesc*{ieeestd invschmitt port}{Inverting Schmitt port matched to IEEE standard ports}{}
7461 \circuitdesc*{ieee tgate}{IEEE style transmission gate}{}(in 1/180/0.2, bin 1/-155/0.2, up/30/0.2, down/-30/0.2, out/0/0.2, bout/45/0.2, notgate/135/0.4, gate/-135/0.4)
7462 \circuitdesc*{ieee double tgate}{IEEE style double transmission gate}{}(in/180/0.2, bin/-155/0.2, out/0/0.2, bout/45/0.2, up/30/0.2, down/-30/0.2, bnotgate/135/0.4, bgate/-115/0.4)
7463 \circuitdesc*{notcirc}{Inverting dot for IEEE ports}{}(west/180/0.1, east/0/0.1)
7464 \circuitdesc*{schmitt symbol}{Schmitt symbol to add to input pins if needed}{}(north west/145/0.1, south east/-45/0.1)
7465
7466 \end{groupdesc}
7467
7468 \subsubsection{European Logic gates}
7469 \label{sec:european-logic-gates}
7470 \begin{groupdesc}
7471 \circuitdesc*{european and port}{European \textsc{and} port}{}( in 1/180/0.2, in 2/180/0.2, out/0/0.2 )
7472 \circuitdesc*{european or port}{European \textsc{or} port}{}( bin 1/135/0.2, bin 2/-135/0.2, bout/-45/0.2 )
7473 \circuitdesc*{european nand port}{European \textsc{nand} port}{}
7474 \circuitdesc*{european nor port}{European \textsc{nor} port}{}
7475 \circuitdesc*{european xor port}{European \textsc{xor} port}{}
7476 \circuitdesc*{european xnor port}{European \textsc{xnor} port}{}
7477 \circuitdesc*{european buffer port}{European \textsc{buffer} port}{}
7478 \circuitdesc*{european not port}{European \textsc{not} port}{}
7479 \circuitdesc*{european blank port}{European blank port}{A}
7480 \circuitdesc*{european blank not port}{European blank not port}{B}
7481 \end{groupdesc}
7482
7483 \begin{framed}
7484 If (default behaviour) \IndexKey{americanports} option is active (or the style \IndexKey{american ports} is used), the shorthands \texttt{and port}, \texttt{or port}, \texttt{buffer port}, \texttt{nand port}, \texttt{nor port}, \texttt{not port}, \texttt{xor port}, \texttt{xnor port}, \texttt{schmitt port} and \texttt{invschmitt port} are equivalent to the american version of the respective logic port.
7485
7486 If otherwise \IndexKey{europeanports} option is active (or the style \IndexKey{european ports} is used), the shorthands \texttt{and port}, \texttt{or port}, \texttt{buffer port}, \texttt{nand port}, \texttt{nor port}, \texttt{not port}, \texttt{xor port}, \texttt{xnor port} are equivalent to the european version of the respective logic port; \texttt{schmitt port} and \texttt{invschmitt port} are the same as in \texttt{american ports} style.
7487
7488 Finally, for version \texttt{1.1.0} and up, you can use the style \IndexKey{ieee ports} to set the shorthands to the set of \texttt{ieeestd} ports. (There is no global option for this).
7489 \end{framed}
7490
7491 \subsubsection{Path-style logic ports}
7492 \label{sec:path-style-logic}
7493
7494 The one-input, one-output ports have a handy path-style equivalent; they are the following:
7495
7496 \begin{groupdesc}
7497 \ctikzset{logic ports=ieee}
7498 \circuitdescbip*{inline not}<not port>{``not'' logic port}{}
7499 \circuitdescbip*{inline buffer}<buffer port>{``buffer'' logic port}{}
7500 \circuitdescbip*{inline schmitt}<schmitt port>{Schmitt logic port}{}
7501 \circuitdescbip*{inline invschmitt}<invschmitt port>{Inverting Schmitt logic port}{}
7502 \circuitdescbip*{inline tgate}<tgate>{transmission gate}{}(bgate/-90/0.2, bnotgate/90/0.2)
7503 \circuitdescbip*{inline double tgate}<double tgate>{double transmission gate}{}(bgate/-90/0.2, bnotgate/90/0.2)
7504 \end{groupdesc}
7505
7506 Those ports follow the current selected style, although you can change it on the fly (even if it does not have a lot of sense); you can apply labels, annotations and (again, not a lot of sense) voltages to them. The assigned value is typeset as if it were the main text of the node.
7507
7508 \begin{ctikzExample}
7509 \begin{circuitikz}[american]
7510 \ctikzset{logic ports=ieee}
7511 \draw (0,0) to[inline not=I1, l=label, v=$\Delta V$] ++(2,0);
7512 \draw (0,-2) to[inline not, a=ann, european ports] ++(2,0);
7513 \end{circuitikz}
7514 \end{ctikzExample}
7515
7516 Notice that in the inline version the leading pins are not drawn,
7517 so in the case of the transmission gates
7518 you have to use the border pins to connect the gates.
7519
7520 \begin{ctikzExample}
7521 \begin{circuitikz}[ ]
7522 \ctikzset{logic ports=ieee,
7523 logic ports/fill=yellow}
7524 \draw (0,0) to[inline not] ++(2,0)
7525 to[inline double tgate, name=P] ++(3,0)
7526 (P.bnotgate) |- ++(-3,1);
7527 \end{circuitikz}
7528 \end{ctikzExample}
7529
7530 \subsubsection{American ports usage}
7531 \label{sec:american-ports-usage}
7532
7533 Since version \texttt{1.0.0}, the default shape of the family of american ``or'' ports has changed to a more ``pointy'' one, for better distinguish them from the ``and''-type ports. You can still go back to the previous aspect with the key \IndexKey{american or shape} that can be set to \texttt{pointy} or \texttt{roundy}. The \texttt{legacy} style will enact the old, roundy style also.
7534
7535 \begin{ctikzExample}
7536 \begin{circuitikz}[
7537 american]
7538 % legacy shapes
7539 \ctikzset{american or shape=roundy}
7540 \ctikzset{logic ports/fill=yellow}
7541 \node [or port](O1) at (0,0) {};
7542 \node [nor port](O2) at (0,-1.5) {};
7543 \node [xor port](O3) at (0,-3) {};
7544 \node [xnor port](O4) at (0,-4.5) {};
7545 \begin{scope}[xshift=3cm]
7546 % new shapes
7547 \ctikzset{american or shape=pointy}
7548 \node [or port](O1) at (0,0) {};
7549 \node [nor port](O2) at (0,-1.5) {};
7550 \node [xor port](O3) at (0,-3) {};
7551 \node [xnor port](O4) at (0,-4.5) {};
7552 \end{scope}
7553 \end{circuitikz}
7554 \end{ctikzExample}
7555
7556 \paragraph{American logic port customization}
7557 \label{par:american-logic-port}
7558
7559 Logic port class is called \texttt{logic ports}, so you can scale them all with \IndexKey{logic ports/scale} (default \texttt{1.0}).
7560
7561 As for most components, you can change the width and height of the ports; the thickness is given by the parameter \texttt{tripoles/thickness} (default 2).
7562
7563 It is possible to change height and width of the logic ports using the parameters \texttt{tripoles/american \emph{type} port/} plus \texttt{width} or \texttt{height}:
7564
7565 \begin{ctikzExample}[varwidth=true]
7566 \tikz \draw (0,0) node[nand port] {}; \par
7567 \ctikzset{tripoles/american nand port/input height=.2}
7568 \ctikzset{tripoles/american nand port/port width=.4}
7569 \ctikzset{tripoles/thickness=4}
7570 \tikz \draw (0,0) node[nand port] {};
7571 \end{ctikzExample}
7572
7573
7574 This is especially useful if you have ports with more than two inputs, which are instantiated
7575 with the parameter \IndexKey{number inputs} :
7576
7577 \begin{ctikzExample}
7578 \begin{circuitikz}
7579 \draw (0,3) node[american and port] (A) {P1};
7580 \begin{scope}
7581 \ctikzset{tripoles/american or port/height=1.6}
7582 \draw (A.out) -- ++(0.5,0)
7583 node[american or port,
7584 number inputs=5,
7585 anchor=in 1] (B) {P2};
7586 \end{scope}
7587 \draw (0,1.5) node[american or port] (C) {P3};
7588 \draw (C.out) |- (B.in 2);
7589 \end{circuitikz}
7590 \end{ctikzExample}
7591
7592 You can suppress the drawing of the logic ports input leads by using the boolean key \IndexKey{logic ports draw input leads} (default \texttt{true}) or, locally, with the style \IndexKey{no input leads} (that can be reverted with \IndexKey{input leads}), like in the following example. The anchors do not change and you have to take responsibility to make the connection to the ``border''-anchors.
7593
7594 \begin{ctikzExample}
7595 \begin{circuitikz}
7596 \node [or port](O1) at (0,2) {};
7597 \node [or port, no input leads](O1) at (2,2) {};
7598 \ctikzset{logic ports draw input leads=false}
7599 \node [and port](O1) at (0,0) {};
7600 \node [nand port, input leads](O1) at (2,0) {};
7601 \end{circuitikz}
7602 \end{ctikzExample}
7603
7604 This is useful if you need to draw a generic port, like the one following here:
7605
7606 \begin{ctikzExample}
7607 \begin{circuitikz}
7608 \ctikzset{tripoles/american nand port/height=1.6}
7609 \draw (0,0)
7610 node[american nand port,
7611 circuitikz/tripoles/american nand port/height=1.1,
7612 number inputs=5, no input leads,
7613 ] (B) {Pn};
7614 \draw (B.in 1) -- (B.bin 1) (B.in 5) -- (B.bin 5);
7615 \node[rotate=90] at (B.in 3) {\dots};
7616 \end{circuitikz}
7617 \end{ctikzExample}
7618
7619 In an analogous manner, there is a setting \IndexKey{logic ports draw output leads} (and a corresponding style \IndexKey{no output leads}) that suppresses the drawing of the output lead. A shortcut boolean key \IndexKey{logic ports draw leads} will suppress or enable all leads (the corresponding styles are \IndexKey{no leads} and \IndexKey{all leads}).
7620
7621 You can tweak the appearance of american ``or'' family (\texttt{or}, \texttt{nor}, \texttt{xor} and \texttt{xnor}) ports, too, with the parameters \texttt{inner} (how much the base circle goes ``into'' the shape, default 0.3) and \texttt{angle} (the angle at which the base starts, default 70).
7622
7623 \begin{ctikzExample}[varwidth=true]
7624 \tikz \draw (0,0) node[xnor port] {};
7625 \ctikzset{tripoles/american xnor port/inner=.7}
7626 \ctikzset{tripoles/american xnor port/angle=40}
7627 \tikz \draw (0,0) node[xnor port] {};
7628 \end{ctikzExample}
7629
7630 \paragraph{American logic port anchors}
7631 \label{par:american-logic-port-anchors}
7632
7633 These are the anchors for logic ports:
7634
7635 \bigskip
7636 \begin{circuitikz} [american]
7637 \def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
7638 \path(-2,1) -- (11,-1);
7639
7640 \draw (0,0) node[and port, number inputs=3](A){IC1} ;
7641 \foreach \a/\d in {left/45, right/45, out/-45, in 1/135, in 2/135, in 3/135}
7642 \path (A.\a) \coorda(\a)<\d>;
7643
7644 \draw (4.5,0) node[and port, number inputs=3](A){IC1};
7645 \foreach \a/\d in {north/90, north west/135, west/180, south west/-135,
7646 south/-90, south east/45, east/45, north east/45}
7647 \path (A.\a) \coorda(\a)<\d>;
7648
7649 \draw (9,0) node[nand port, ](A){} ;
7650 \foreach \a/\d in {left/45, right/45, center/-90}
7651 \path (A.\a) \coorda(\a)<\d>;
7652 \end{circuitikz}
7653 \bigskip
7654
7655 You also have ``border pin anchors'':
7656
7657 \bigskip
7658 \begin{circuitikz} [american]
7659 \def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
7660 \path(-2,1) -- (11,-1);
7661
7662 \draw (0,0) node[american and port, number inputs=3](A){IC1} ;
7663 \foreach \a/\d in {bin 1/-135, bin 2/-135, bin 3/-135, bout/-45}
7664 \path (A.\a) \coorda(\a)<\d>;
7665
7666 \draw (4.5,0) node[american or port, number inputs=3](A){IC1};
7667 \foreach \a/\d in {bin 1/-135, bin 2/-135, bin 3/-135, bout/-45}
7668 \path (A.\a) \coorda(\a)<\d>;
7669
7670 \draw (9,0) node[nand port, ](A){} ;
7671 \foreach \a/\d in {bin 1/-135, bin 2/-135, bout/-45}
7672 \path (A.\a) \coorda(\a)<\d>;
7673 \end{circuitikz}
7674 \bigskip
7675
7676 These anchors are especially useful if you want to negate inputs:
7677
7678 \begin{ctikzExample}
7679 \begin{circuitikz}
7680 \draw (0,3) node[american and port] (A) {P1};
7681 \node at (A.bin 1) [ocirc, left]{} ;
7682 \begin{scope}
7683 \ctikzset{tripoles/american or port/height=1.6}
7684 \draw (A.out) -- ++(0.5,0) node[american or port,
7685 number inputs=5, anchor=in 1] (B) {P2};
7686 \node at (B.bin 3) [ocirc, left]{} ;
7687 \end{scope}
7688 \draw (0,1.5) node[american or port] (C) {P3};
7689 \node at (C.bin 2) [ocirc, left]{} ;
7690 \draw (C.out) |- (B.in 2);
7691 \end{circuitikz}
7692 \end{ctikzExample}
7693 As you can see, the \texttt{center} anchor is (for historic reasons) not in the center at all. You can fix this with the command \IndexKey[logic ports origin]{}\verb|\ctikzset{logic ports origin=center}|:
7694
7695 \begin{ctikzExample}
7696 \begin{circuitikz}
7697 \ctikzset{logic ports origin=center}
7698 \draw (0,0) node[and port] (myand) {}
7699 (myand.in 1) node[anchor=east] {1}
7700 (myand.in 2) node[anchor=east] {2}
7701 (myand.out) node[anchor=west] {3};
7702 \draw[<-] (myand.center) -- ++(1,-1)
7703 node{center};
7704 \end{circuitikz}
7705 \end{ctikzExample}
7706
7707 \begin{ctikzExample}
7708 \begin{circuitikz} \draw
7709 (0,2) node[and port] (myand1) {}
7710 (0,0) node[and port] (myand2) {}
7711 (2,1) node[xnor port] (myxnor) {}
7712 (myand1.out) -| (myxnor.in 1)
7713 (myand2.out) -| (myxnor.in 2)
7714 ;\end{circuitikz}
7715 \end{ctikzExample}
7716
7717 In the case of \textsc{not}, there are only \texttt{in} and \texttt{out} (although for compatibility reasons \texttt{in 1} is still defined and equal to \texttt{in}):
7718
7719 \begin{ctikzExample}
7720 \begin{circuitikz} \draw
7721 (1,0) node[not port] (not1) {}
7722 (3,0) node[not port] (not2) {}
7723 (0,0) -- (not1.in)
7724 (not2.in) -- (not1.out)
7725 ++(0,-1) node[ground] {} to[C] (not1.out)
7726 (not2.out) -| (4,1) -| (0,0)
7727 ;\end{circuitikz}
7728 \end{ctikzExample}
7729
7730 This last circuit could be drawn also (and probably in a more natural manner) using the path-style components:
7731
7732 \begin{ctikzExample}
7733 \begin{circuitikz}[american]
7734 \draw (0,0) node[ground]{} to[C] ++(0,1.5)
7735 coordinate(c)
7736 to[inline not] ++(2.5,0) -- ++(0,1)
7737 -| ++(-5,-1)
7738 to[inline not] (c);
7739 \end{circuitikz}
7740 \end{ctikzExample}
7741
7742 \subsubsection{IEEE logic gates usage.}
7743 \label{sec:ieee-logic-gates}
7744
7745 \begingroup % for IEEE ports
7746 The rest of this section will assume you have issued the command \verb|\ctikzset{logic ports=ieee}|, so that the short form of the names is used.
7747 \ctikzset{logic ports=ieee}
7748
7749 IEEE standard logic gates have a basic difference with the legacy ones: the proportions of their shapes do not change when you change the size, so you can't have a ``tall'' port or a ``squatty'' one. The two-inputs gates, by default, have their default size designed so that they match the chips component (see~\ref{sec:chips}).
7750
7751 \begin{ctikzExample}
7752 \begin{circuitikz}
7753 \draw (0,0) node[dipchip](C){IC} (C.pin 8)
7754 node[or port, anchor=in 1,
7755 color=red](A){IC2A};
7756 \end{circuitikz}
7757 \end{ctikzExample}
7758
7759 If you need, say\IndexKey[logic gates, ieee, multiple inputs]{}, a 4-inputs port, the port will look like this:
7760
7761 \begin{ctikzExample}
7762 \begin{circuitikz}
7763 \draw (0,0) node[dipchip](C){IC} (C.pin 8)
7764 node[or port, anchor=in 1, number inputs=4,
7765 color=red](A){IC2A};
7766 \end{circuitikz}
7767 \end{ctikzExample}
7768
7769 \dots and in this case it is clear that it does not match. With standard ports, there are two possibilities.
7770 The first one is to scale the port; if you set the port height so that it has the same size (see ``IEEE logic gates customization'' below for details) as the number of ports, they will match again.
7771
7772 \begin{ctikzExample}
7773 \begin{circuitikz}
7774 \draw (0,0) node[dipchip](C){IC} (C.pin 8)
7775 node[or port, anchor=in 1,
7776 number inputs=4,
7777 circuitikz/ieeestd ports/height=4,
7778 color=red](A){IC2A};
7779 \end{circuitikz}
7780 \end{ctikzExample}
7781
7782 But then the size of the port is quite ``unusual''. The solution in technical literature is to use what we can call a ``rack'' for the inputs; basically, only a certain number of pins are kept on the port, and the others are put on an extended input line.
7783
7784 \begin{ctikzExample}
7785 \begin{circuitikz}
7786 \draw (0,0) node[dipchip](C){IC} (C.pin 8)
7787 node[or port, anchor=in 1,
7788 number inputs=4,
7789 inner inputs=2,
7790 color=red](A){IC2A};
7791 \end{circuitikz}
7792 \end{ctikzExample}
7793
7794 When using the \IndexKey{inner inputs} key, keep in mind the rule of thumbs:
7795 \begin{itemize}
7796 \item the distance between the pins is matched with the chip ones when the \texttt{inner inputs} match the \texttt{/}\IndexKey{ieeestd ports/height} key;
7797 \item when the number of pins in the rack is odd, the result is often quite ugly, so try to avoid it.
7798 \end{itemize}
7799 For example, look at the following example; given that we are asking an odd number of pins on the rack, some of the inputs are drawn on the port's border, resulting in a less-than-ideal diagram.
7800
7801 \begin{ctikzExample}
7802 \begin{circuitikz}
7803 \draw (0,0) node[dipchip](C){IC} (C.pin 8)
7804 node[or port, anchor=in 1,
7805 number inputs=5,
7806 inner inputs=2,
7807 color=red](A){IC2A};
7808 \end{circuitikz}
7809 \end{ctikzExample}
7810
7811 In this case, if you don't like the solution, the better approach is to let the gate grow a bit.
7812
7813 \begin{ctikzExample}
7814 \begin{circuitikz}
7815 \draw (0,0) node[dipchip](C){IC} (C.pin 8)
7816 node[or port, anchor=in 1,
7817 number inputs=5,
7818 inner inputs=3,
7819 circuitikz/ieeestd ports/height=3,
7820 color=red](A){IC2A};
7821 \end{circuitikz}
7822 \end{ctikzExample}
7823
7824 The good thing about the rack mechanism is that you can have quite big ports without problems.
7825
7826 \begin{ctikzExample}[varwidth=true, pos=t]
7827 \begin{circuitikz}[scale=0.75, transform shape]
7828 \draw node[nor port, number inputs=32, inner inputs=2,
7829 rotate=90](A){\rotatebox{-90}{IC1A}};
7830 \end{circuitikz}
7831 \end{ctikzExample}
7832
7833 You can use the additional elements (the \texttt{notcirc} and the \texttt{schmitt symbol} to obtain circuits like the following ones (well, a bit of a mix of conventions, but...):
7834
7835 \begin{ctikzExample}
7836 \begin{circuitikz}
7837 \draw (0,0) node[and port](A){A} (A.out)
7838 node[buffer port, anchor=in,
7839 component text=left](B){B} (B.bin)
7840 node[schmitt symbol, above left]{}
7841 (A.bin 1) node[schmitt symbol, right]{};
7842 \node [notcirc, left] at (A.bin 1) {};
7843 \node [notcirc, above](C) at (B.up) {};
7844 \draw (C.north) |- ++(-1,1) (B.down) --++(0,-1);
7845 \end{circuitikz}
7846 \end{ctikzExample}
7847
7848 Notice the key \IndexKey{component text=left} that moves the label near to the left border of the component. There is also a \verb|\ctikzset{component text=left}| if you prefer to have it as a default for all the IEEE ports.\footnote{You can use the same key with amplifiers, too.}
7849
7850
7851 \paragraph{Stacking and aligning IEEE standard gates.} The standard gates are designed so that they stacks up nicely when positioned using the external leads as anchors. Notice that the ports \textbf{do} have different sizes, but the leads lengths are designed to counter the differences.
7852 \label{par:stacking-and-aligning}
7853
7854 \begin{ctikzExample}
7855 \begin{circuitikz}
7856 \draw
7857 (0,0) node[and port, anchor=in 1]{A1}
7858 (0,-1.2) node[nand port, anchor=in 1]{A2}
7859 (0,-2.4) node[or port, anchor=in 1]{A3}
7860 (0,-3.6) node[xnor port, anchor=in 1]{A4};
7861 \draw
7862 (3,0) node[and port, anchor=in 1](A1){A1}
7863 (3,-1.2) node[nand port, anchor=in 1]{A2}
7864 (3,-2.4) node[or port, anchor=in 1]{A3}
7865 (3,-3.6) node[xnor port, anchor=in 1](A4){A4};
7866 \draw[red, dashed]([yshift=0.8cm]A1.body left)
7867 -- ([yshift=-0.8cm]A4.body left);
7868 \end{circuitikz}
7869 \end{ctikzExample}
7870
7871 The length of the external leads can be changed by the user, but notice that if you use a too small value you can jeopardize that property.
7872
7873 The single input ports (\texttt{not port}, \texttt{buffer port} and their Schmitt equivalent) are smaller than the six standard ports, so they are not kept aligned by default; the just have the same distance at the input side. For the not ports, the \texttt{left} position of the text results often in a better look (the centered text in the triangle seems to be much more at the right).
7874
7875 \begin{ctikzExample}
7876 \begin{circuitikz}
7877 \ctikzset{component text=left}
7878 \draw (0,0) node[nand port, anchor=in 1]{A1}
7879 (0,-1.8) node[buffer port, anchor=in 1]{A2}
7880 (0,-3.2) node[not port, anchor=in 1]{A3};
7881 \draw (3,0) node[nand port, anchor=in 1](A1){A1}
7882 (3,-1.8) node[buffer port, anchor=in 1]{A2}
7883 (3,-3.2) node[not port, anchor=in 1](A3){A3};
7884 \draw[red, dashed]([yshift=0.8cm]A1.body left)
7885 -- ([yshift=-0.8cm]A3.body left);
7886 \end{circuitikz}
7887 \end{ctikzExample}
7888
7889 \paragraph{IEEE standard ports customization}
7890 \label{par:ieee-standard-ports}
7891
7892 There are several parameters that can be used to customize the IEEE standard ports, although less than the ones in the legacy american ones --- the basic shape is set to follow the IEEE recommendation. The basic parameters are shown in the following table, and they can be set via \IndexKey[ieeestd ports customizazion]{}\verb|\ctikzset{ieeestd ports/...}|
7893
7894 \begin{tabular}{@{}>{\ttfamily}l >{\ttfamily} l >{\RaggedRight}p{0.6\textwidth}@{}}
7895 \toprule
7896 \multicolumn{1}{l}{\textbf{key}} &
7897 \multicolumn{1}{l}{\textbf{default}} &
7898 \multicolumn{1}{l}{\textbf{description}} \\
7899 \midrule
7900 baselen & 0.4 & the basic length for every dimension, as a fraction of the (scaled) resistor length \\
7901 height & 2 & the height of the port, in term of \texttt{baselen}. Pin distance is given by this parameter divided by the inner pins.\\
7902 pin length & 0.7 & length of the external pin leads that are drawn with the port. This length is always calculated starting from the inner body of the shape.\\
7903 not radius & 0.154 & radius of the ``not circle'' added to the negated-output ports. The default value is the IEEE recommended one. \\
7904 xor bar distance & 0.192 & distance of the detached input shape in \texttt{xor} and \texttt{xnor} ports. The default value is the IEEE recommended one. \\
7905 xor leads in & 1 & If set to \texttt{0}, there will be no leads drawn between the detached input line and the body in the \texttt{xor} and \texttt{xnor} ports. IEEE recommends \texttt{1} here. \\
7906 schmitt symbol size & 0.3 & Size of the small Schmitt symbol to use near input leads. \\
7907 \bottomrule
7908 \end{tabular}
7909
7910 For example, using a \IndexKey{not radius} of \texttt{0.1} will give a ``not ball'' of the same size of a connecting pole, as it is in the legacy ports.
7911
7912 \begin{ctikzExample}
7913 \begin{circuitikz}
7914 \draw (0,2) node[xnor port](P){}
7915 (P.out) to[short, -o] ++(1,0);
7916 \ctikzset{ieeestd ports/.cd, not radius=0.1,
7917 xor bar distance=0.3, xor leads in=0}
7918 \draw (0,0) node[xnor port](P){}
7919 (P.out) to[short, -o] ++(1,0);
7920 \end{circuitikz}
7921 \end{ctikzExample}
7922
7923 In addition to the specific parameters, you can also apply to these ports the boolean style \IndexKey{no input leads} as in legacy ones (this simply \emph{does not draw} the input leads, but the anchors stays where they should):
7924
7925 \begin{ctikzExample}
7926 \begin{circuitikz}
7927 \draw (0,0) node[nand port,
7928 number inputs=5, no input leads,](B){Pn};
7929 \draw (B.in 1) -- (B.bin 1) (B.in 5) -- (B.bin 5);
7930 \node[rotate=90] at (B.in 3) {\dots};
7931 \end{circuitikz}
7932 \end{ctikzExample}
7933
7934 Changing the leads length must be done with a bit of care, because if the length is shorter than the port left or right extrusions strange things can happen (yes, a 4-inputs xnor gates is not so well defined\dots but it's a nice example to show):
7935
7936 \begin{ctikzExample}
7937 \begin{circuitikz}
7938 \ctikzset{ieeestd ports/pin length=0.2}
7939 \draw (0,0) node[xnor port,
7940 number inputs=4, inner inputs=2](B){};
7941 \end{circuitikz}
7942 \end{ctikzExample}
7943
7944 \paragraph{IEEE standard ports anchors} Geographical anchors define the rectangular space that the port is using, included the leads if presents.
7945 \label{par:ieee-standard-ports-anchors}
7946
7947 \geocoord{ieeestd and port}
7948 \geocoord{ieeestd xnor port, number inputs=6, inner inputs=2,
7949 circuitikz/ieeestd ports/height=1}
7950
7951 Most of the anchors can be seen in the following diagram:
7952
7953 \begin{circuitikz}[]
7954 \draw (0,0) node[ieeestd and port, number inputs=4](A){};
7955 \draw (5.8,0) node[ieeestd xnor port, number inputs=2,
7956 circuitikz/ieeestd ports/.cd, baselen=0.6, pin length=1, xor bar distance=0.4](B){};
7957 \draw (11,0) node[ieeestd or port, number inputs=6, inner inputs=2](C){};
7958 %
7959 \foreach \i in {1,2,3,4} {
7960 \path (A.in \i) \showcoord(in \i)<180:0.3>;
7961 \path (A.bin \i) \showcoordb(bin \i)<45:0.3>;
7962 }
7963 \path (A.out) \showcoord(out)<0:0.2>;
7964 \path (A.bout) \showcoordb(bout)<-45:0.2>;
7965 \path (A.left) \showcoord(left)<-45:0.4>;
7966 \path (A.right) \showcoord(right)<45:0.4>;
7967
7968 \path (B.ibin 1) \showcoordb(ibin 1)<90:0.4>;
7969 \path (B.ibin 2) \showcoordb(ibin 2)<-90:0.4>;
7970 \path (B.bin 1) \showcoordb(bin 1)<-145:0.2>;
7971 \path (B.out) \showcoord(out)<0:0.2>;
7972 \path (B.bout) \showcoordb(bout)<-45:0.2>;
7973 \path (B.left) \showcoord(left)<-145:0.4>;
7974 \path (B.body left) \showcoord(body left)<145:0.6>;
7975 \path (B.right) \showcoord(right)<45:0.4>;
7976 \path (B.body right) \showcoord(body right)<90:0.5>;
7977
7978 \path (C.up) \showcoordb(up)<90:0.2>;
7979 \path (C.down) \showcoordb(down)<-90:0.2>;
7980 \foreach \i in {1,...,6} {
7981 \path (C.in \i) \showcoord(in \i)<180:0.2>;
7982 }
7983 \end{circuitikz}
7984
7985 The inputs anchor are \texttt{in \emph{number}} (on the tip of the lead) and \texttt{bin \emph{number}} (\textbf{b}order \textbf{in}puts) on the component's border (useful if you draw the ports with \texttt{no inut leads}).
7986 Additionally, you have \texttt{ibin \emph{number}} (\textbf{i}nner \textbf{b}order \textbf{in}puts) for the \emph{x}-type ports. The anchor named \texttt{left} is where a central border input would be.
7987
7988 In one-input ports (\texttt{not port}, the buffer, and Schmitt-type ports) you can use plain \texttt{in} or \texttt{in 1} indifferently.
7989
7990 On the output, \texttt{out} is on the tip of the lead, and \texttt{bout} on the rightmost border (so, if there is a negation circle, it is on it); \texttt{right} is the same as \texttt{bout}.
7991
7992 The main body of the port is marked with \texttt{body left} and \texttt{body right} anchors (as seen in the middle port in the diagram above); you also have an \texttt{up} and \texttt{down} anchors centered on the body (you can use them as enable signals or similar things).
7993
7994 Finally, the internal \texttt{notcirc} node used for the output negation is accessible with the name \texttt{\emph{nodename}-not}, where \emph{nodename} is the name given to the logic port node.
7995
7996 \endgroup % for IEEE ports ctikzset
7997 %%
7998
7999 \paragraph{Transmission gate symbols.}\label{sec:passgate}
8000
8001
8002 The \texttt{tgate} and \texttt{double tgate} components are available since \texttt{1.2.4} but only in the IEEE style. An additional parameter \IndexKey{tgate scale} (default \texttt{0.7}; if you set this to \texttt{1} the triangles will have the same size as a \texttt{ieeestd buffer port}) select the relative scale of the components.
8003
8004
8005 \begin{ctikzExample}
8006 \begin{circuitikz}
8007 \ctikzset{logic ports=ieee}
8008 \draw (0,0) to[inline not, *-*] ++(2,0)
8009 node[tgate, anchor=in]{};
8010 \end{circuitikz}
8011 \end{ctikzExample}
8012
8013 The anchors for the tgate's control point are called \texttt{gate} and \texttt{notgate} (and the corresponding \texttt{bgate} and \texttt{bnotgate} for the border anchors).
8014
8015 \begin{quote}
8016 \begin{circuitikz}
8017 \ctikzset{logic ports=ieee, tgate scale=1}
8018 \node[ieee tgate](A) at (0,0) {};
8019 \path (A.in) \showcoord(in)<180:0.2>;
8020 \path (A.bin) \showcoordb(bin)<-135:0.2>;
8021 \path (A.out) \showcoord(out)<0:0.2>;
8022 \path (A.bout) \showcoordb(bout)<-45:0.2>;
8023 \path (A.left) \showcoord(left)<135:0.4>;
8024 \path (A.right) \showcoord(right)<45:0.4>;
8025 \path (A.gate) \showcoord(gate)<-160:0.3>;
8026 \path (A.bgate) \showcoordb(bgate)<-75:0.3>;
8027 \path (A.notgate) \showcoord(notgate)<160:0.3>;
8028 \path (A.bnotgate) \showcoordb(bnotgate)<75:0.3>;
8029 \node[ieee double tgate](A) at (5,0) {};
8030 \path (A.in) \showcoord(in)<180:0.2>;
8031 \path (A.bin) \showcoordb(bin)<-135:0.2>;
8032 \path (A.out) \showcoord(out)<0:0.2>;
8033 \path (A.bout) \showcoordb(bout)<-45:0.2>;
8034 \path (A.left) \showcoord(left)<135:0.4>;
8035 \path (A.right) \showcoord(right)<45:0.4>;
8036 \path (A.gate) \showcoord(gate)<-160:0.3>;
8037 \path (A.bgate) \showcoordb(bgate)<-75:0.3>;
8038 \path (A.notgate) \showcoord(notgate)<160:0.3>;
8039 \path (A.bnotgate) \showcoordb(bnotgate)<75:0.3>;
8040 \end{circuitikz}
8041 \end{quote}
8042
8043
8044 \subsubsection{European logic port usage}
8045 \label{sec:european-logic-port}
8046
8047 European logic port are in the same class as american and IEEE-style ones, and they obey the same class modifier. Moreover, you can use the \IndexKey{no inputs pin} as in the other logic ports to suppress input pins.
8048
8049 The standard text inside the port does not rotate (not flip) with the component\footnote{since \texttt{1.6.4}, thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/730}{user \texttt{@sputeanus} on GitHub}.}, but you can change the font (and color and so on) with the key \IndexKey{european ports font} (default nothing, which means it uses the standard font and color).
8050 For more complex customization, you can use the two ``blank'' European ports, and add the text you want on them.
8051
8052 \begin{ctikzExample}
8053 \begin{tikzpicture}
8054 \ctikzset{
8055 logic ports=european,
8056 logic ports origin=center,
8057 logic ports/scale=1.5,
8058 tripoles/european not symbol=ieee circle,
8059 }
8060 % Draw the Nand with big AND symbol
8061 \ctikzset{european ports font=\Huge\color{red}}
8062 \draw(0,0) node [nand port, rotate=90,
8063 number inputs=4]{};
8064 \draw(3,0) node [nand port, xscale=-1]{};
8065 % the un-rotation is not automatic for node text!
8066 \draw(0,-3) node [blank port, rotate=90,
8067 ]{\rotatebox{-90}{\Huge ?}};
8068 \draw(3,-3) node [blank not port, xscale=-1]{?};
8069 \end{tikzpicture}
8070 \end{ctikzExample}
8071
8072 \paragraph{European logic port customization} Normally the European-style logic port with inverted output are marked with a small triangle; if you want you can change it with the key \IndexKey{tripoles/european not symbol}; its default is \texttt{triangle} but you can set it to \texttt{circle} like in the following example. As you can see, the circle size is the same as the circuit poles; if you prefer the size used in the IEEE standard ports, you can use set it to \texttt{ieee circle}.
8073 \label{par:european-logic-port}
8074
8075 \begin{ctikzExample}
8076 \begin{circuitikz}[european]
8077 \draw (0,3) node[nand port](A){}
8078 (A.out) to[short, *-o] ++(0.5,0);
8079 \ctikzset{tripoles/european not symbol=circle}
8080 \draw (0,1.5) node[nand port](A){}
8081 (A.out) to[short, *-o] ++(0.5,0);
8082 \ctikzset{tripoles/european not symbol=ieee circle}
8083 \draw (0,0) node[european nand port](A){}
8084 (A.out) to[short, *-o] ++(0.5,0);
8085 \end{circuitikz}
8086 \end{ctikzExample}
8087
8088 In some standard, the \texttt{xnor} port is different --- without the negation at the end and with just an $=$ sign.\footnote{Suggested by user \texttt{Schlepptop} on GitHub.}
8089 You can switch to this if you like, with the key \IndexKey{european xnor style} that can be \texttt{default} or \texttt{direct}.
8090
8091 \begin{ctikzExample}
8092 \begin{circuitikz}[european]
8093 \draw (0,0) node[xnor port]{};
8094 \ctikzset{european xnor style=direct}
8095 \draw (3,0) node[xnor port]{};
8096 \end{circuitikz}
8097 \end{ctikzExample}
8098
8099 \paragraph{European logic port anchors} The anchors are basically the same as in the american-style ports.
8100 \label{par:european-logic-port-anchors}
8101
8102 \bigskip
8103 \begin{circuitikz} [american]
8104 \def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
8105
8106 \draw (0, 0) node[european and port, ](A){} ;
8107 \foreach \a/\d in {left/45, right/45, center/-90}
8108 \path (A.\a) \coorda(\a)<\d>;
8109
8110 \draw (3,0) node[european and port, ](A){} ;
8111 \foreach \a/\d in {bin 1/-135, bin 2/-135, bout/-45}
8112 \path (A.\a) \coorda(\a)<\d>;
8113
8114 \draw (6,0) node[european nand port, ](A){} ;
8115 \foreach \a/\d in {bin 1/-135, bin 2/-135, bout/-45}
8116 \path (A.\a) \coorda(\a)<\d>;
8117
8118 \ctikzset{tripoles/european not symbol=circle}
8119
8120 \draw (9,0) node[european nand port, ](A){} ;
8121 \foreach \a/\d in {bin 1/-135, bin 2/-135, bout/-45}
8122 \path (A.\a) \coorda(\a)<\d>;
8123
8124 \end{circuitikz}
8125 \bigskip
8126
8127
8128 \subsection{Flip-flops}\label{sec:flipflops}
8129
8130 Flip-flops (available since version \texttt{1.0.0}) are an hybrid between the logic ports and the chips. They have a class by themselves (\texttt{flipflops}) but the default parameters are set at the same values as the logic gates one.
8131
8132 The default flip flop is empty: it is just a rectangular box like a blank \texttt{dipchip} with 6 pins.
8133 \begin{groupdesc}
8134 \circuitdesc*{flipflop}{Blank (void) flip flop}{FF}(
8135 pin 1/180/0.2, pin 2/180/0.2, pin 3/180/0.2,
8136 bpin 1/120/0.3, bpin 6/60/0.3, up/90/0.2, down/-90/0.2, bup/30/0.2, bdown/-30/0.2,
8137 pin 6/0/0.2, pin 5/0/0.2, pin 4/0/0.2)
8138 \end{groupdesc}
8139
8140 As you can see, in a void flip flop no external pins are drawn: you have to define the meaning of each of them to see them.
8141 To define a specific flip-flop, you have to set a series of keys under the \verb|\ctikzset| directory \IndexKey{multipoles/flipflop/}, corresponding to pins \texttt{1}\dots \texttt{6}, \texttt{u} for ``up'' and \texttt{d} for ``down'':
8142 \begin{itemize}
8143 \item a \emph{text} value \texttt{t0}, \texttt{t1}, \dots \texttt{t6}, and \texttt{tu} and \texttt{td} (the last ones for up and down) which will set a label on the pin;
8144 \item a \emph{clock wedge} flag (\texttt{c0}, \dots \texttt{c6}, \texttt{cu}, \texttt{cd}), with value \texttt{0} or \texttt{1}, which will draw a triangle shape on the border of the corresponding pin;
8145 \item a \emph{negation} flag (\texttt{n0}, \dots \texttt{n6}, \texttt{nu}, \texttt{nd}), with value \texttt{0} or \texttt{1}, which will put an \texttt{ocirc} shape on the outer border of the corresponding pin.
8146 \end{itemize}
8147
8148 To set all these keys, an auxiliary style \IndexKey{flipflop def} is defined, so that you can do the following thing:
8149
8150 \begingroup
8151
8152 \begin{ctikzExample}[exec outside]
8153 \tikzset{flipflop AB/.style={flipflop,
8154 flipflop def={t1=A, t3=B, t6=Q, t4={\ctikztextnot{Q}},
8155 td=rst, nd=1, c2=1, n2=1, t2={\texttt{CLK}}},
8156 }}
8157 \end{ctikzExample}
8158
8159 to obtain:
8160
8161 \begin{groupdesc}
8162 \circuitdesc*{flipflop AB}{Example custom flip flop}{}(
8163 pin 1/180/0.2, pin 2/180/0.2, pin 3/180/0.2,
8164 bpin 1/120/0.3, bpin 6/60/0.3, down/-90/0.2, bdown/-30/0.2,
8165 pin 6/0/0.2)
8166 \end{groupdesc}
8167 \endgroup
8168
8169 \verb|\ctikztextnot{}|\IndexKey[ctikztextnot]{} is a small utility macro to set a overbar to a text, like \ctikztextnot{RST} (created by \verb|\ctikztextnot{RST}|).
8170
8171 By default, the following flip-flops are defined, as well as a support shape for the clock wedge:
8172 \begin{groupdesc}
8173 \circuitdesc*{latch}{D-type latch}{}
8174 \circuitdesc*{flipflop SR}{flip-flop SR}{}
8175 \circuitdesc*{flipflop D}{Edge-triggered synchronous flip-flop D}{}
8176 \circuitdesc*{flipflop T}{Edge-triggered synchronous flip-flop T}{}
8177 \circuitdesc*{flipflop JK}{Edge-triggered synchronous flip-flop JK}{}
8178 \circuitdesc{clockwedge}{clock wedge shape}{text}(center/180/0.6, nw/90/0.2, sw/-90/0.2, right/45/0.5)
8179 \end{groupdesc}
8180
8181 If you prefer that the negated output is labelled \texttt{Q} and a dot indicating negation is shown, you can add the \IndexKey{dot on notQ} key:
8182
8183 \begin{groupdesc}
8184 \circuitdesc*{flipflop JK, dot on notQ}{synchronous flip-flop JK with asynchronous set and reset}{}
8185 \end{groupdesc}
8186
8187 You can also add ``vertical'' asynchronous set and reset (active low) adding the style \IndexKey{add async SR} to all of them:
8188
8189 \begin{groupdesc}
8190 \circuitdesc*{flipflop JK, add async SR}{synchronous flip-flop JK with asynchronous set and reset}{}
8191 \end{groupdesc}
8192
8193 \subsubsection{Custom flip-flops}
8194 \label{sec:custom-flip-flops}
8195
8196 If you like different pin distributions, you can easily define different flip-flops to your taste. For example, somebody likes the clock pin on the bottom pin:
8197
8198 \begingroup
8199
8200 \begin{ctikzExample}[exec outside]
8201 \tikzset{flipflop myJK/.style={flipflop,
8202 flipflop def={t1=J, t2=K, t6=Q, t4={\ctikztextnot{Q}}, c3=1}}
8203 }
8204 \end{ctikzExample}
8205
8206 \begin{groupdesc}
8207 \circuitdesc*{flipflop myJK}{Example custom flip flop}{}
8208 \end{groupdesc}
8209 \endgroup
8210
8211 The standard definition of the default flip-flops are the following (in the file \texttt{pgfcircmultipoles.tex}):
8212
8213 \begin{lstlisting}[basicstyle=\small\ttfamily]
8214 \tikzset{
8215 % async
8216 latch/.style={flipflop, flipflop def={t1=D, t6=Q, t3=CLK, t4=\ctikztextnot{Q}}},
8217 flipflop SR/.style={flipflop, flipflop def={t1=S, t3=R, t6=Q, t4=\ctikztextnot{Q}}},
8218 % sync
8219 flipflop D/.style={flipflop, flipflop def={t1=D, t6=Q, c3=1, t4=\ctikztextnot{Q}}},
8220 flipflop T/.style={flipflop, flipflop def={t1=T, t6=Q, c3=1, t4=\ctikztextnot{Q}}},
8221 flipflop JK/.style={flipflop,
8222 flipflop def={t1=J, t3=K, c2=1, t6=Q, t4=\ctikztextnot{Q}}},
8223 % additional features
8224 add async SR/.style={flipflop def={%
8225 tu={\ctikztextnot{SET}}, td={\ctikztextnot{RST}}}},
8226 dot on notQ/.style={flipflop def={t4={Q}, n4=1}},
8227 }
8228 \end{lstlisting}
8229
8230
8231 \subsubsection{Flip-flops anchors}
8232 \label{sec:flip-flops-anchors}
8233
8234 Flip-flops have all the standard geometrical anchors, although it should be noticed that the external pins are \emph{outside} them. The pins are accessed by the number \texttt{1} to \texttt{6} for the lateral ones (like in DIP chips), and with the \texttt{up} and \texttt{down} anchors for the top and bottom one. All the pins have the ``border'' variant (add a \texttt{b} in front of them, no spaces).
8235
8236 \begin{quote}
8237 \geocoord{flipflop JK}\qquad
8238 \showanchors{flipflop JK, add async SR, external pins width=0.5}{}(%
8239 pin 1/180/0.5, pin 2/180/0.5, pin 3/180/0.5,
8240 up/90/0.2, down/-90/0.2,
8241 pin 6/0/0.5, pin 5/0/0.5, pin 4/0/0.5,
8242 bpin 1/120/0.3, bpin 2/135/0.3, bpin 3/-120/0.2,
8243 bup/30/0.3, bdown/-30/0.3,
8244 bpin 6/60/0.3, bpin 5/30/0.3, bpin 4/-30/0.4)
8245 \end{quote}
8246
8247 If you have negated pins, you can access the \texttt{ocirc} shapes with the name as \texttt{\textsl{<nodename>}-N\textsl{<pin number>}}, and all the respective anchors (for example --- \verb|myFFnode-N4.west|).
8248
8249 \subsubsection{Flip-flops customization}\label{sec:flip-flop-cust}
8250
8251 Flip-flop's size is controlled by the class parameters (like \IndexKey{flipflops/scale}) and the specific \verb|\ctikzset| keys \IndexKey{multipoles/flipflop/width} and \IndexKey{multipoles/flipflop/pin spacing}. Class parameters are also used for line thickness and fill color. The default values are matched with the logic ports ones.
8252
8253 The fonts used for the pins \texttt{1}\dots \texttt{6} is set by the key \IndexKey{multipoles/flipflop/font} (by default \verb|\small| in \LaTeX{} and the equivalent in other formats) and the font used for pins \texttt{u} and \texttt{d} is \IndexKey{multipoles/flipflop/fontud} (\verb|\tiny| by default).
8254 You can change it globally or specifically for each flip flop.
8255
8256 As in chips, you can change the length of the external pin with the key \IndexKey{external pins width}; you can for example have a pinless flip-flop like this:
8257
8258 \begin{groupdesc}
8259 \circuitdesc*{flipflop JK, add async SR, external pins width=0}{synchronous flip-flop JK}{}
8260 \end{groupdesc}
8261
8262 Notice however that negated pins when the pins width is zero has to be handled with care. As explained in the poles sections, the \texttt{ocirc} shape is drawn at the end of the shape to cancel out the wires below; so if you use a pinless flipflop when you make the connection you should take care of connecting the symbol correctly. To this end, the shapes of the negation circles are made available as \texttt{\textsl{<nodename>}-N\textsl{<pin number>}}, as you can see in the next (contrived) example.
8263
8264
8265 \begin{ctikzExample}
8266 \begin{circuitikz}[scale=3, transform shape]
8267 \clip (0.2,0.5) rectangle (1.2,-1.3);
8268 \node [flipflop JK,
8269 flipflop def={n5=1,n4=1,t5={/c},c5=1},
8270 external pins width=0,
8271 ](A){};
8272 \draw (A-N5.east) -- ++(1,0); % correct
8273 \draw (A.pin 4) -- ++(1,0); % wrong
8274 \end{circuitikz}
8275 \end{ctikzExample}
8276
8277 Normally the symbols on the flip-flop are un-rotated when you rotate the symbol, but as in case of chips, you can avoid it.
8278
8279 \begin{ctikzExample}[pos=t]
8280 \begin{tikzpicture}
8281 \draw (0,0) node[flipflop JK, add async SR]{};
8282 \draw (3,0) node[flipflop JK, add async SR, rotate=90]{};
8283 \draw (7,0) node[flipflop JK, add async SR, rotate=90, rotated numbers]{};
8284 \end{tikzpicture}
8285 \end{ctikzExample}
8286
8287 You can also change the size of the wedge, with the key \IndexKey{multipoles/flipflop/clock wedge size} (default value \texttt{0.2}).
8288
8289 \begin{ctikzExample}
8290 \begin{circuitikz}[]
8291 \draw (0,0) node[flipflop JK]{JK};
8292 \ctikzset{multipoles/flipflop/clock wedge size=0.1}
8293 \draw (2.3,0) node[flipflop JK]{JK};
8294 \ctikzset{multipoles/flipflop/clock wedge size=0.4}
8295 \draw (4.6,0) node[flipflop JK]{JK};
8296 \end{circuitikz}
8297 \end{ctikzExample}
8298
8299 Flip-flops ``not circles'' follows the current logic port setting (either if you choose \texttt{ieee ports}, or if you are using \texttt{european ports} with \texttt{european not symbol} set to \texttt{cirle} or \texttt{ieee circle}.
8300
8301 \begin{ctikzExample}
8302 \begin{circuitikz}[]
8303 \ctikzset{logic ports=european,
8304 tripoles/european not symbol=ieee circle}
8305 \draw (0,0) node[nand port](A){}
8306 (A.out) to[short] ++(0.5,0)
8307 node[flipflop JK, dot on notQ, anchor=pin 2]{JK};
8308 \ctikzset{logic ports=european,
8309 tripoles/european not symbol=circle}
8310 \draw (0,-3) node[nand port](A){}
8311 (A.out) to[short] ++(0.5,0)
8312 node[flipflop JK, dot on notQ, anchor=pin 2]{JK};
8313 \end{circuitikz}
8314 \end{ctikzExample}
8315
8316
8317 \subsection{Multiplexer and de-multiplexer}\label{sec:muxdemuxes}
8318
8319 The shape used for muxes and de-muxes is probably the most configurable shape of the package; it has been added by Romano in \texttt{v1.0.0}. The basic shape is a multiplexer with 8 input pin, one output pin, and three control pins ($2^3\to1$ multiplexer). The pins are not named as input or output pins (see below for a full description for anchors) for reasons that will be clear later.
8320
8321 \begin{groupdesc}
8322 \circuitdesc*[0.7]{muxdemux}{mux-demux}{MD1}(lpin 1/180/0.2, lpin 2/180/0.2, bpin 1/-90/0.2, blpin 1/0/0.2, blpin 2/0/0.2, bbpin 1/90/0.2, rpin 1/0/0.1, brpin 1/-110/0.1)
8323 \circuitdesc{wedgeinv, scale=2}{Inversion marker for European logic symbols\footnotemark}{}(base/180/0.2, top/90/0.2, apex/0/0.2, mid/45/0.2, center/135/0.2)
8324 \footnotetext{Thanks for the contribution by \href{https://github.com/circuitikz/circuitikz/issues/679}{\texttt{yashpalgoyal1304} on GitHub}.}
8325 \circuitdesc{circleinv, scale=2}{Circle-shaped inversion marker}{}(base/180/0.2, top/90/0.2, apex/0/0.2, mid/45/0.2, center/135/0.2, bottom/-90/0.1)
8326 \end{groupdesc}
8327
8328 You can define a custom shape for the \texttt{muxdemux}es using an interface similar to the one used in flip-flops; for example:
8329
8330 \begin{lstlisting}
8331 \tikzset{demux/.style={muxdemux, muxdemux def={Lh=4, Rh=8, NL=1, NB=3, NR=8}}}
8332 \end{lstlisting}
8333
8334 will generate the following shape (the definition above is already defined in the package):
8335
8336 \begin{groupdesc}
8337 \circuitdesc*[0.7]{demux}{Demultiplexer $1\to2^3$ with \texttt{Lh=4, Rh=8, NL=1, NB=3, NR=8} }{MD2}
8338 \end{groupdesc}
8339
8340 The shape can also be defined with an inset. For example it can be used like this to define a 1-bit adder (also already available):
8341
8342 \begin{lstlisting}
8343 \tikzset{one bit adder/.style={muxdemux,
8344 muxdemux def={Lh=4, NL=2, Rh=2, NR=1, NB=1, w=1.5,
8345 inset w=0.5, inset Lh=2, inset Rh=1.5}}}
8346 \end{lstlisting}
8347 \begin{groupdesc}
8348 \circuitdesc*{one bit adder}{One-bit adder}{\Large$\oplus$}
8349 \end{groupdesc}
8350
8351 Or a Arithmetic Logic Unit (again, already defined by default):
8352
8353 \begin{lstlisting}
8354 \tikzset{ALU/.style={muxdemux,
8355 muxdemux def={Lh=5, NL=2, Rh=2, NR=1, NB=2, NT=1, w=2,
8356 inset w=1, inset Lh=2, inset Rh=0, square pins=1}}}
8357 \end{lstlisting}
8358 \begin{groupdesc}
8359 \circuitdesc*{ALU}{ALU}{\rotatebox{90}{\small\ttfamily ALU}}
8360 \end{groupdesc}
8361
8362 \subsubsection{Mux-Demux: design your own shape}
8363 \label{sec:mux-demux-design}
8364
8365 \begin{minipage}{0.45\linewidth}
8366 \RaggedRight
8367 In designing the shape there are several parameters to be taken into account. In the diagram on the right they are shown in a (hopefully) practical way. The parameter can be set in a node or in a style using the \texttt{muxdemux def} key as shown above, or set with \verb|\ctikzset| as \IndexKey[multipoles/muxdemux/...]{multipoles/muxdemux/Lh} keys and so on.
8368 \end{minipage}%
8369 \begin{minipage}{0.5\linewidth}
8370 \centering
8371 \begin{circuitikz}[quote/.style={thin, blue, <->}, refline/.style={red, dashed}]
8372 \def\myquotev#1#2#3#4{%
8373 \draw [refline] (A.#1) -- ++(#2,0) coordinate(tmp) --++(#3,0);
8374 \draw [quote] (tmp|-A.center) -- (tmp |- A.#1)
8375 node [midway, below=4pt, sloped, fill=white]{\texttt{#4}};
8376 }
8377 \def\myquoteh#1#2#3#4#5{%
8378 \draw [refline] (A.#1) -- ++(0,#2) coordinate(tmp) --++(0,#3);
8379 \draw [quote] (tmp) -- (tmp -| A.#5)
8380 node [right, fill=white]{\texttt{#4}};
8381 }
8382 \begin{scope}
8383 \clip (-4,-0.5) rectangle (2,3);
8384 \node [muxdemux, muxdemux def={NL=6, NR=3, NT=3,
8385 inset w=1.0, inset Lh=3.0, inset Rh=2.0}, no input leads](A) at(0,0) {};
8386 \draw [refline] (-4,0) -- (2,0);
8387 \draw [refline] (0,-1) -- (0,3);
8388 \end{scope}
8389 \myquotev{top left}{-2.8}{-.2}{Lh}
8390 \myquotev{inset top left}{-2.0}{-.2}{inset Lh}
8391 \myquotev{inset top right}{-1.4}{-.2}{inset Rh}
8392 \myquotev{top right}{.5}{.2}{Rh}
8393 \myquoteh{top left}{.3}{.2}{w}{center}
8394 \myquoteh{inset top left}{-1.5}{-.2}{inset w}{inset top right}
8395 \end{circuitikz}
8396 \end{minipage}
8397
8398 \bigskip
8399
8400 The default values are $\texttt{Lh}=8$, $\texttt{Rh}=6$, $\texttt{w}=3$ and no inset: $\texttt{inset Lh}=\texttt{inset Rh}=\texttt{inset w}=0$. In addition, you can set the following parameters:
8401 \begin{description}
8402 \item [NL, NR, NB, NT]: number of pins relatively on the left, right, bottom and top side (default \texttt{8}, \texttt{1}, \texttt{3}, \texttt{0}). When an inset is active (in other words, when $\texttt{Lh}>0$) the pins are positioned on the top and bottom part, not in the inset; the exception is when the number of left pins is odd, in which case you have one pin set on the center of the inset.
8403 If you do not want a pin in one side, use \texttt{0} as number of pins.
8404 \item [square pins]: set to \texttt{0} (default) if you want the square pins to stick out following the slope of the bottom or top side, \texttt{1} if you want them to stick out in a square way (see the example above for the ALU).
8405 \end{description}
8406 All the distances are multiple of \IndexKey{multipoles/muxdemux/base len} (default \texttt{0.4}, to be set with \verb|\ctikzset|), which is relative to the basic length. That value has been chosen so that, if you have a number of pins which is equal to the effective distance where they are spread (which is \texttt{Lh} without inset, $\texttt{Lh}- (\texttt{inset Lh})$ with an inset), then the distance is the same as the default pin distance in chips, as shown in the next circuit. In the same drawing you can see the effect of \texttt{square pins} parameters (without it, the rightmost bottom lead of the \texttt{mux 4by2} shape will not connect with the below one).
8407
8408 \begin{ctikzExample}
8409 \begin{circuitikz}
8410 \tikzset{mux 4by2/.style={muxdemux,
8411 muxdemux def={Lh=4, NL=4, Rh=3,
8412 NB=2, w=2, square pins=1}}}
8413 \node [dipchip, num pins=8](A) at (0,0) {IC1};
8414 \node [one bit adder, scale=-1, anchor=lpin 2]
8415 at (A.pin 1){};
8416 \node [mux 4by2, anchor=lpin 1](B)
8417 at (A.pin 8){MUX};
8418 \node [qfpchip, num pins=8, anchor=pin 8] at
8419 (B.bpin 1) {IC2};
8420 \end{circuitikz}
8421 \end{ctikzExample}
8422
8423 \subsubsection{Mux-Demux customization}
8424 \label{sec:mux-demux-customization}
8425
8426 Mux-demuxes have the normal parameters of their class (\texttt{muxdemuxes}): you can scale them with the \verb|\ctikzset| key \IndexKey{muxdemuxes/scale}, control the border thickness with \IndexKey{muxdemuxes/thickness} and the default fill color with \IndexKey{muxdemuxes/fill} --- they are set, by default, at the same values than \texttt{logic ports}.
8427
8428 External pins' length is controlled by the key \IndexKey{multipoles/external pins width} (default \texttt{0.2}) or by the style \IndexKey{external pins width}. The parameter
8429 \IndexKey{multipoles/external pins thickness} is also respected.
8430 like in chips. In addition, like in logic ports, you can suppress the
8431 drawing of the leads by using the boolean key
8432 \IndexKey{logic ports draw input leads} (default \texttt{true}) or, locally,
8433 with the style \IndexKey{no input leads} (that can be reverted with
8434 \IndexKey{input leads}).
8435 The main difference between setting \texttt{external pins width} to \texttt{0} or using \texttt{no input lead} is that in the first case the normal pin anchors and the border anchors will coincide, and in the second case they will not move and stay where they should have been if the leads were drawn.
8436
8437 You can draw only selected pins and leave out the rest by setting the keys
8438 \IndexKey[multipoles/draw only * pins]{multipoles/draw only \emph{side} pins} and the corresponding style
8439 \texttt{draw only \emph{side} pins} where \texttt{\emph{side}} can be \texttt{left}, \texttt{right},
8440 \texttt{top}, \texttt{bottom}.
8441 Those key accept a comma-separated list of
8442 pin numbers or ranges of pin numbers (a range is given as
8443 \texttt{$\langle$start$\rangle$ - $\langle$end$\rangle$}, ends are inclusive).
8444 The numbers will not be expanded in any way, except those given as ends of
8445 ranges. A special value (and the initial one) is \texttt{all}, in which case all
8446 pins are drawn. The anchors will be adjusted, such that each \texttt{\emph{x}pin
8447 \textit{n}} will be placed at the end of the pins which are drawn, and coincide
8448 with the \texttt{b\emph{x}pin \textit{n}} anchors for the suppressed pins.
8449
8450 \begin{ctikzExample}
8451 \begin{circuitikz}
8452 \node [muxdemux, muxdemux def={NL=4, NR=3, NT=5, NB=3, w=2,
8453 inset w=0.5, Lh=4, inset Lh=2.0, inset Rh=1.0,
8454 square pins=1},
8455 draw only right pins={1,3},
8456 draw only top pins={1-3},
8457 draw only bottom pins={3}](C) at (0,0) {X};
8458 \end{circuitikz}
8459 \end{ctikzExample}
8460
8461 \subsubsection{Mux-Demux anchors}
8462 \label{sec:mux-demux-anchors}
8463
8464 Mux-demuxes have a plethora of anchors. As in the case of chips, the geographic anchors mark the rectangle occupied by the component, without taking into account the pin leads.
8465
8466 \begin{quote}
8467 \scalebox{0.7}{%
8468 \geocoord[baseline=(N.center)]{muxdemux}
8469 \showanchors[baseline=(N.center)]{muxdemux}{X}(top left/180/0.3, top/90/0.3, top right/0/0.3,
8470 bottom left/180/0.3, bottom/-90/0.3, bottom right/0/0.3, left/180/0.3, right/0/0.3,
8471 center/45/0.2, center up/0/0.4, center down/0/0.4)
8472 \showanchors[baseline=(N.center)]{muxdemux, muxdemux def={NL=6, NR=3, NT=3, inset w=1.0,
8473 inset Lh=3.0, inset Rh=2.0}, no input leads}{}(inset top left/180/0.3, inset top/90/0.5,
8474 inset top right/0/0.3, inset bottom left/180/0.3, inset bottom/-90/0.5,
8475 inset bottom right/-20/0.3, inset left/180/0.3, inset right/-20/0.2, inset center/135/0.2,
8476 narrow center/20/0.2, center up/45/0.4, center down/-45/0.4)
8477 }
8478 \end{quote}
8479
8480 The pins anchors are named \texttt{lpin}, \texttt{rpin}, \texttt{bpin} and \texttt{tpin} for the left, right, bottom and top pin respectively, and points to the ``external'' pin. The border pins are named the same, with a \texttt{b} added in front: \texttt{blpin}, \texttt{brpin}, \texttt{bbpin} and \texttt{btpin}.
8481 The following graph will show the numbering and position of the pin anchors.
8482
8483 \begin{quote}
8484 \begin{circuitikz}
8485 \node [muxdemux, muxdemux def={NL=4, NR=3, NT=3, NB=3, w=2, inset w=0.5,
8486 Lh=4, inset Lh=2.0, inset Rh=1.0, square pins=1}](C) at (0,0) {X};
8487 \node [muxdemux, muxdemux def={NL=7, NR=8, NT=4, inset w=1.0,
8488 inset Lh=4.0, inset Rh=0.0}](D) at (4,0) {X};
8489 \foreach \myn/\NL/\NR/\NB/\NT in {C/4/3/3/3,D/7/8/3/4} {
8490 \foreach \myp in {1,...,\NL} \node[right, font=\tiny] at (\myn.blpin \myp){\myp};
8491 \foreach \myp in {1,...,\NR} \node[left, font=\tiny] at(\myn.brpin \myp) {\myp};
8492 \foreach \myp in {1,...,\NB} \node[above, font=\tiny] at (\myn.bbpin \myp){\myp};
8493 \foreach \myp in {1,...,\NT} \node[below, font=\tiny] at (\myn.btpin \myp){\myp};
8494 }
8495 \path (C.lpin 1) \showcoord(lpin 1)<180:0.3>;
8496 \path (D.blpin 1) \showcoord(blpin 1)<135:0.3>;
8497 \path (C.tpin 1) \showcoord(tpin 1)<180:0.3>;
8498 \path (D.btpin 1) \showcoord(btpin 1)<45:0.3>;
8499 \path (C.rpin 1) \showcoord(rpin 1)<0:0.3>;
8500 \path (D.brpin 1) \showcoord(brpin 1)<45:0.3>;
8501 \path (C.bpin 2) \showcoord(bpin 2)<-90:0.3>;
8502 \path (C.bbpin 2) \showcoord(bbpin 2)<-60:0.3>;
8503 \path (D.bbpin 2) \showcoord(bbpin 2)<-45:0.3>;
8504 \end{circuitikz}
8505 \end{quote}
8506
8507
8508 The code that implemented the printing of the numbers (which in \texttt{muxdemux}es, differently from chips, are never printed automatically) in the last graph is the following one.
8509
8510 \begin{lstlisting}[basicstyle=\small\ttfamily]
8511 \begin{circuitikz}
8512 \node [muxdemux, muxdemux def={NL=4, NR=3, NT=3, NB=3, w=2, inset w=0.5,
8513 Lh=4, inset Lh=2.0, inset Rh=1.0, square pins=1}](C) at (0,0) {X};
8514 \node [muxdemux, muxdemux def={NL=7, NR=8, NT=4, inset w=1.0,
8515 inset Lh=4.0, inset Rh=0.0}](D) at (4,0) {X};
8516 \foreach \myn/\NL/\NR/\NB/\NT in {C/4/3/3/3,D/7/8/3/4} {
8517 \foreach \myp in {1,...,\NL} \node[right, font=\tiny] at (\myn.blpin \myp){\myp};
8518 \foreach \myp in {1,...,\NR} \node[left, font=\tiny] at(\myn.brpin \myp) {\myp};
8519 \foreach \myp in {1,...,\NB} \node[above, font=\tiny] at (\myn.bbpin \myp){\myp};
8520 \foreach \myp in {1,...,\NT} \node[below, font=\tiny] at (\myn.btpin \myp){\myp};
8521 }
8522 \end{circuitikz}
8523 \end{lstlisting}
8524
8525 \subsubsection{Adding labels to the pins}\label{sec:muxdemux-labels}
8526
8527 In \texttt{muxdemux}es, there is no automatic labelling of pins with numbers as in chips; there is no simple standard enumeration possible. But since \texttt{v1.6.5} it is possible to associate a name to the pins that will be printed with the shape; that names are called \emph{pin labels}.
8528 Pin labels are counter-rotated by default if the shape is rotated, as in chip pin numbers~(see \ref{sec:chip-rotation}), but you can avoid it with the key \IndexKey{rotated numbers} (the default is \IndexKey{straight numbers}).
8529 Additionally, you can set also \emph{border labels} on the four borders (more or less, see later); that are normally not counter-rotated \emph{unless} the result would be upside-down (or if you use \texttt{straight numbers}, of course), and clock and negation symbols.
8530
8531 All of these labels and symbols are added by specifying them in a \IndexKey[muxdemux label]{muxdemux label=\{\dots\}} clause. Notice that the key specified there are not checked for validity; if you misspell any of that, it will be simply ignored.
8532
8533 \paragraph{Inner pin labels} will be printed in the inside of the shape, with the font specified in the \verb|\ctikzset| key \IndexKey{muxdemux/inner label font} (default is \verb|\tiny| in \LaTeX, other engine can have it different --- better set it in case of doubt) and with a padding setting with the keys \IndexKey{muxdemux/inner label xsep} and \IndexKey{muxdemux/inner label ysep} (respectively for horizontal and vertical shifts; default for both \texttt{2pt}). You can also use the key \IndexKey{muxdemux/inner label sep} to set both at the same time.
8534 \label{par:inner-pin-labels}
8535
8536 \begin{ctikzExample}
8537 \begin{circuitikz}
8538 \tikzset{myICwl/.style={muxdemux,
8539 muxdemux def={Lh=4, Rh=4, w=4,
8540 NR=1, NL=2, NB=2, NT=2,},
8541 muxdemux label={L1=left1, L2=left2,
8542 R1=r1, B2=b2, T1=t1, T2=t2},
8543 }
8544 }
8545 \draw (0, 0) node[myICwl]{chip} ++(3,0)
8546 node[myICwl, rotate=-90]{chip};
8547 \draw (0, -3) node[myICwl]{chip} ++(3,0)
8548 node[myICwl, rotate=-90,
8549 rotated numbers]{chip};
8550 \end{circuitikz}
8551 \end{ctikzExample}
8552
8553 As you can see, the syntax is to add a \texttt{muxdemux label} to the specification; the labels are set using one of the letter \texttt{L}, \texttt{R}, \texttt{B}, and \texttt{T} for respectively left, right, bottom and top labels. You can define all the labels, none (which will give the default behavior of no-labels as it was before \texttt{v1.6.5}), or any number you wish.
8554 If you want some specific label rotated in a different way, you have to do it manually, as shown in the following example.
8555
8556 \begin{ctikzExample}
8557 \begin{circuitikz}
8558 \tikzset{mux 4by2 wl/.style={muxdemux,
8559 muxdemux def={Lh=6, NL=6, Rh=3, NB=2, w=3, NT=1},
8560 draw only left pins={2-5},
8561 muxdemux label={B1=$A_1$, B2=$A_0$, R1=OUT,
8562 L2=$D_{00}$, L3=$D_{01}$, L4=$D_{10}$, L5=$D_{11}$,
8563 T1=\rotatebox{90}{\texttt{Enable}}},
8564 circuitikz/muxdemux/inner label ysep=4pt}}
8565 \node [mux 4by2 wl]{};
8566 \end{circuitikz}
8567 \end{ctikzExample}
8568
8569 \paragraph{Outer pin labels} will be printed on the outside of the pin position --- in the case of left and right pins, either above (``up'', identified by \texttt{LU} and \texttt{RU} labels), or below (``down'', \texttt{LD} and \texttt{RD} labels); in the case of top and bottom pin, either at the left (\texttt{TL} and \texttt{BL}) or at the right (\texttt{TR} and \texttt{BR}). The font is specified in the key \IndexKey{muxdemux/outer label font} (default \verb|\tiny|) and the padding with the corresponding \IndexKey{muxdemux/outer label xsep} and \IndexKey{muxdemux/outer label ysep} (default for both \texttt{2pt}), or \IndexKey{muxdemux/outer label sep} to set both at the same time.
8570 \label{par:outer-pin-labels}
8571
8572 \begin{ctikzExample}
8573 \begin{circuitikz}
8574 \ctikzset{muxdemux/outer label
8575 font={\tiny\ttfamily\color{blue}}}
8576 \tikzset{myICwl/.style={muxdemux,
8577 muxdemux def={Lh=4, Rh=4, w=4,
8578 NR=1, NL=2, NB=2, NT=2,},
8579 muxdemux label={L1=left1, L2=left2,
8580 R1=r1, B2=b2, T1=t1, T2=t2,
8581 LU1=lu1, LU2=lu2, LD1=ld1, LD2=ld2,
8582 BR1=br1, BL1=bl1, BR2=br2, BL2=bl2,
8583 RU1=ru1, RD1=rd1,TR2=tr2, TL2=tl2,
8584 TR1=tr1, TL1=tl1},}
8585 }
8586 \draw (0, 0) node[myICwl]{chip} ++(3,0)
8587 node[myICwl, rotate=-90]{chip};
8588 \draw (0, -3) node[myICwl]{chip} ++(3,0)
8589 node[myICwl, rotate=-90,
8590 rotated numbers]{chip};
8591 \end{circuitikz}
8592 \end{ctikzExample}
8593
8594 \paragraph{Border labels} are drawn \emph{before} the other labels along the external border (to be exact: in north, south, east, and west position) of the component.
8595 \label{par:border-labels}
8596 You set them with the key \texttt{N}, \texttt{S}, \texttt{W}, and \texttt{E} for the outer position, and \texttt{Ni}, \texttt{Si}, \texttt{Wi}, and \texttt{Ei} for the inner ones.
8597 The font is specified in the key \IndexKey{muxdemux/border label font} (default \verb|\tiny|) and the padding with the corresponding \IndexKey{muxdemux/border label xsep} and \IndexKey{muxdemux/border label ysep} (default for both \texttt{2pt}), or \IndexKey{muxdemux/border label sep} to set both at the same time.
8598 \begin{ctikzExample}
8599 \begin{circuitikz}
8600 \ctikzset{muxdemux/outer label
8601 font={\tiny\ttfamily\color{blue}}}
8602 \tikzset{myICwl/.style={muxdemux,
8603 muxdemux def={Lh=4, Rh=4, w=4,
8604 NR=1, NL=2, NB=0, NT=0,},
8605 muxdemux label={L1=inA, L2=inB,
8606 R1=OUT, RU1=3, LU1=1, LU2=2,
8607 N=mychip},}
8608 }
8609 \draw (0, 0) node[myICwl]{} ++(3,0)
8610 node[myICwl, rotate=180]{};
8611 \draw (0, -3) node[myICwl,
8612 muxdemux label={N=another}]{};
8613 \end{circuitikz}
8614 \end{ctikzExample}
8615
8616 As you can see, you can locally change any label in a specific instance.
8617
8618 \paragraph{Clock and negation symbols} are not exactly labels, but they can be added with the same mechanism. There are four symbols available:
8619 \label{par:clock-and-negation}
8620 \begin{description}
8621 \item [clock wedge:] activated by the key \texttt{c} followed by the position (for example, \texttt{cL2} will set the clock wedge on the second left pin); its size can be changed with the key \IndexKey{muxdemux/clock wedge size} (default \texttt{0.2}, relative to \texttt{muxdemux/base len});
8622 \item [not ball:] activated by the key \texttt{n} followed by the position (for example, \texttt{nR1} will set the negation circle on the first right pin); the type and shape of the ball will depend on the logic port negation in use (basically it will use a \texttt{circleinv} shape unless you are using european ports with the small \texttt{ocirc} negation symbol);
8623 \item [wedge in:] a wedge negation \emph{entering} the component (with the point on the border), activated by the key \texttt{wi} followed by the position;
8624 \item [wedge out:] a wedge negation \emph{exiting} the component (with the base on the border), activated by the key \texttt{wo} followed by the position.
8625 \end{description}
8626 The value of the key should be \texttt{0} or \texttt{1} for clocks and not circles; zero means ``do not draw'' and is used to override a previously specified element. In the case of wedge-style not, the \texttt{-1} value flips the side of the triangle (see the following example).
8627
8628 \begin{ctikzExample}
8629 \begin{circuitikz} \ctikzset{muxdemux/outer label
8630 font={\tiny\ttfamily\color{blue}}}
8631 \ctikzset{logic ports=ieee, multipoles/external pins width=0.3}
8632 \tikzset{myICwl/.style={muxdemux,
8633 muxdemux def={Lh=4, Rh=4, w=4, NR=2, NL=2, NB=1, NT=0,},
8634 muxdemux label={L1=inA, L2=inB, R1=OUT, RU1=3, LU1=1, LU2=2,
8635 N=example, nL1=1, woR1=1, woR2=-1, wiB1=1, cL2=1},}
8636 }
8637 \draw (0, 0) node[myICwl]{};
8638 \draw (0, -3) node[myICwl,
8639 muxdemux label={N=another, LU1={1\strut},
8640 RU1={3\strut}, cL2=0}](A){};
8641 \draw[red, <-] (A-nL1.-135) -- ++(-135:0.3);
8642 \end{circuitikz}
8643 \end{ctikzExample}
8644
8645 As you can see, the label position is not affected (with the exception of the clock wedge, that displaces the inner label), so you have to manually take care of not having overruns; you can change the \texttt{xsep} or \texttt{ysep} or, as shown in the example, modify the heigh and depth of the affected labels.
8646
8647 You have also to take care of the effect shown for the flip-flops in section~\ref{sec:flip-flop-cust}, to avoid overrun the not circles when connecting wires. The ``not'' elements are named after the instance as \texttt{\textsl{<nodename>}-\textsl{<activating key>}} to give access to the border (show also in the example, although in bit of forced way\dots look at the red arrow).
8648
8649 \subsubsection{Manually adding wedges or circular inversion markers}\label{sec:wedge-inversion}
8650
8651 If the standard ``internal'' negation symbols are not sufficiently configurable for your application, you can add them manually.
8652 To add the wedge symbol, the \texttt{wedgeinv} shape will nicely do. It'll scale with the \texttt{muxdemuxes} class, and the length and height can be changed with the keys \IndexKey{wedge inversion mark/width} (default \texttt{0.2}) and \texttt{height} (default \texttt{0.1}), with the same units that are used for the \texttt{external pins width} and similar keys.
8653
8654 Similarly, there is also a \texttt{circleinv} shape, which is basically the same as the \texttt{notcirc} (see~\ref{sec:ieeestdports}) one, but that scales with the \texttt{muxdemuxes} class and that has the default anchor at its left, similarly to \texttt{wedgeinv}. This one will be filled if the class says so, contrary to the wedge-like shapes that are always open.
8655
8656 \begin{ctikzExample}
8657 \begin{tikzpicture}[]
8658 \path (0,4) node[muxdemux, muxdemux def={NL=2,Lh=2,Rh=2,NB=1},
8659 external pins width = 0.5](mdemux){};
8660 \draw (mdemux.blpin 1) node[wedgeinv,anchor=apex]{};
8661 \draw (mdemux.brpin 1) node[wedgeinv]{};
8662 \draw (mdemux.bbpin 1) node[wedgeinv, anchor=apex,
8663 rotate=90]{};
8664 \ctikzset{wedge inversion mark/.cd, width=0.1}
8665 \ctikzset{muxdemuxes/.cd, fill=yellow, thickness=3, scale=0.8}
8666 \path (0,2) node[muxdemux, muxdemux def={NL=2,Lh=2,Rh=2,NB=0},
8667 external pins width = 0.5](mdemux){};
8668 \draw (mdemux.blpin 1) node[wedgeinv,anchor=apex]{};
8669 \draw (mdemux.brpin 1) node[wedgeinv]{};
8670 \path (0,0) node[muxdemux, muxdemux def={NL=2,Lh=2,Rh=2,NB=0},
8671 external pins width = 0.5](mdemux){};
8672 \draw (mdemux.blpin 1) node[circleinv,anchor=apex]{};
8673 \draw (mdemux.brpin 1) node[circleinv]{};
8674 \end{tikzpicture}
8675 \end{ctikzExample}
8676
8677 \subsubsection{Adding a background drawing to the muxdemux}
8678 \label{sec:adding-a-background}
8679
8680 In a similar way to the oscilloscope waveform, you can add a drawing to the \texttt{muxdemux} component, provided you use basic-level \texttt{pgf} commands. You have to define a \texttt{.code} key named \IndexKey[muxdemux bgpicture]{bgpicture} in the \texttt{muxdemux def} definitions, as in the following example. The coordinate system is changed so that the horizontal axis of the shape is mapped between \SI{-1}{\cm} and \SI{+1}{\cm} and the origin at the center; the vertical extent will then depend on the form factor of the \texttt{muxdemux}: for example, the vertical coordinate of the top left border will be $\SI{1}{\cm}\cdot{\mathtt{Lh}/\mathtt{w}}$.
8681
8682 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily, keepspaces=true]
8683 \begin{circuitikz}
8684 \ctikzset{muxdemux/outer label font={\tiny\ttfamily\color{blue}}}
8685 \tikzset{myICwl/.style={muxdemux,
8686 muxdemux def={Lh=4, Rh=4, w=3, NR=1, NL=2, NB=0, NT=0,
8687 bgpicture/.code={%
8688 \pgfsetcolor{gray!50}\pgfsetlinewidth{1mm}
8689 \pgfpathmoveto{\pgfpoint{-1cm}{1cm*4/3}} \pgfpathlineto{\pgfpointorigin}
8690 \pgfpathmoveto{\pgfpoint{-1cm}{-1cm*4/3}}\pgfpathlineto{\pgfpointorigin}
8691 \pgfpathmoveto{\pgfpoint{1cm}{0cm}} \pgfpathlineto{\pgfpointorigin}
8692 \pgfpathcircle{\pgfpointorigin}{0.5cm}
8693 \pgfusepath{draw}
8694 },
8695 },
8696 muxdemux label={RU1=3, LU1=1, LU2=2, N=flux, Ni=converter},}
8697 }
8698 \draw (0, 0) node[myICwl]{}{};
8699 \end{circuitikz}
8700 \end{ctikzExample}
8701
8702 You can even embed images:
8703
8704 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily]
8705 \begin{circuitikz}
8706 \ctikzset{muxdemux/outer label font={\tiny\ttfamily\color{blue}}}
8707 \tikzset{myICwl/.style={muxdemux,
8708 muxdemux def={Lh=4, Rh=4, w=3, NR=1, NL=2, NB=0, NT=0,
8709 bgpicture/.code={%
8710 \pgfdeclareimage[width=1.5cm]{myimg}{example-image-a}
8711 \pgftext{\pgfuseimage{myimg}}
8712 },
8713 },
8714 muxdemux label={RU1=3, LU1=1, LU2=2, N=embedding, Ni=images},}
8715 }
8716 \draw (0, 0) node[myICwl]{}{};
8717 \end{circuitikz}
8718 \end{ctikzExample}
8719
8720
8721 For more complex things, consider using a normal macro that draws on the background layer and that use the geographical coordinates of the node to locate it.
8722
8723
8724 \subsubsection{Mux-Demux special usage}
8725 \label{sec:mux-demux-special}
8726
8727 You can use these shapes to draw a lot of symbols that are unavailable; using a bit of \LaTeX{} command trickery you can use them quite naturally too\dots. Examples with personalized amplifier shapes are listed in section~\ref{sec:muxdemux-amplis}.
8728
8729 As an additional example, this was used before the introduction of the \texttt{double tgate} symbol in \texttt{1.2.4} (see ~\ref{sec:passgate}):
8730
8731 \begin{ctikzExample}
8732 \def\tgate#1{
8733 node[simple triangle, anchor=left, no input leads](#1-LR){}
8734 (#1-LR.right) node[simple triangle, xscale=-1,
8735 anchor=left](#1-RL){}
8736 ([yshift=.5ex]#1-RL.btpin 1) node[ocirc]{}}
8737 \begin{circuitikz}[
8738 simple triangle/.style={muxdemux, muxdemux def={
8739 NL=1, NR=1, NB=1, NT=1, w=2, Lh=2, Rh=0,
8740 }}]
8741 \draw (0,0) \tgate{A} (0,-2) \tgate{B};
8742 \draw (A-RL.bpin 1) -- (B-RL.tpin 1);
8743 \end{circuitikz}
8744 \end{ctikzExample}
8745
8746 Finally, you can play with them to create chips that have generic numbers of pins on the four sides, as in the following example (asked on \href{https://tex.stackexchange.com/q/596320/38080}{TeX.Stackexchange}; notice however that this example has been made \emph{before} the option for labels existed; it could be quite streamlined now, as shown later):
8747
8748 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily]
8749 \begin{tikzpicture}[scale=0.7, transform shape]
8750 \tikzset{ic555/.style={muxdemux,
8751 muxdemux def={Lh=10, NL=5, Rh=10, NR=5, NB=2, w=6, NT=2,
8752 square pins=1},
8753 no input leads, external pins width=0.4,
8754 circuitikz/muxdemuxes/fill=blue!10}
8755 }
8756 \node [ic555, font=\small\ttfamily,align=center](A) at (0,0) {555\\Astable};
8757 % left pins
8758 \foreach \rawpin/\npin/\label in {2/7/Discharge, 4/2/Trigger, 5/6/Threshold}{
8759 \draw (A.lpin \rawpin) -- (A.blpin \rawpin)
8760 node[midway, blue, font=\small, above]{\npin}
8761 node[right, font=\small]{\label};
8762 }
8763 % top pins
8764 \foreach \rawpin/\npin in {1/8, 2/4} {
8765 \draw (A.tpin \rawpin) -- (A.btpin \rawpin)
8766 node[midway, blue, font=\small, left]{\npin};
8767 }
8768 % bottom pins
8769 \foreach \rawpin/\npin in {1/5, 2/1} {
8770 \draw (A.bpin \rawpin) -- (A.bbpin \rawpin)
8771 node[midway, blue, font=\small, left]{\npin};
8772 }
8773 % finally, right
8774 \draw (A.rpin 3) -- (A.brpin 3)
8775 node[midway, blue, font=\small, above]{3};
8776 \end{tikzpicture}
8777 \end{ctikzExample}
8778
8779 In a version of \Circuitikz{} better or equal to \texttt{v1.6.5}, you can do this:
8780
8781 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily]
8782 \begin{tikzpicture}[scale=0.7, transform shape]
8783 \ctikzset{muxdemux/inner label font=\small}
8784 \ctikzset{muxdemux/outer label font={\small\color{blue}}}
8785 \tikzset{ic555/.style={muxdemux,
8786 muxdemux def={Lh=10, NL=5, Rh=10, NR=1, NB=2, w=6, NT=2},
8787 muxdemux label={L2=Discharge, L4=Trigger, L5=Threshold,
8788 T1=VCC, B2=GND,
8789 LU2=7, LU4=2, LU5=6, TL1=8, TL2=4, RU1=3, BL1=5, BL2=1},
8790 external pins width=0.4,
8791 draw only left pins={2,4,5},
8792 circuitikz/muxdemuxes/fill=blue!10}
8793 }
8794 \node [ic555, font=\small\ttfamily,align=center](A)
8795 at (0,0) {555\\Astable};
8796 \end{tikzpicture}
8797 \end{ctikzExample}
8798
8799
8800 \subsection{Chips (integrated circuits)}\label{sec:chips}
8801
8802 \texttt{CircuiTikZ} supports two types of variable-pin chips: DIP (Dual-in-Line Package) and QFP (Quad-Flat Package).
8803 \begin{groupdesc}
8804 \circuitdesc*{dipchip}{Dual-in-Line Package chip}{}
8805 \circuitdesc*{qfpchip}{Quad-Flat Package chip}{}
8806 \end{groupdesc}
8807
8808 \subsubsection{DIP and QFP chips customization}
8809 \label{sec:dip-and-qfp}
8810
8811 You can scale chips with the key \IndexKey{chips/scale}. As ever, that will \textbf{not} scale text size of the labels, when they are printed.
8812
8813 The line thickness of the main shape is controlled by \IndexKey{multipoles/thickness} (default 2) and the one of the external pins/pads with \IndexKey{multipoles/external pins thickness} (default 1).
8814
8815 You can customize the DIP chip with the key \IndexKey{multipoles/dipchip/width} (with a default of \texttt{1.2}) and the key \texttt{multipoles/dipchip/pin spacing} (default \texttt{0.4}) that are expressed in fraction of basic lengths (see section~\ref{sec:components-size}).
8816 The height of the chip will be equal to half the numbers of pins multiplied by the spacing, plus one spacing for the borders.
8817
8818 For the QFP chips, you can only chose the pin spacing with \IndexKey{multipoles/qfpchip/pin spacing} key.
8819
8820 The number of pins is settable with the key \IndexKey{num pins}.
8821 \textbf{Please notice} that the number of pins \textbf{must} be \emph{even} for \texttt{dipchip}s and \emph{multiple of 4} for \texttt{qfpchip}s, otherwise havoc will ensue.
8822
8823 The pins of the chip can be ``hidden'' (that is, just a spot in the border, optionally marked with a number) or ``stick out'' with a thin lead by setting \IndexKey{multipoles/external pins width} greater than 0 (default value is \texttt{0.2}, so you'll have leads as shown above).
8824 Moreover, you can transform the thin lead into a pad by setting the key \IndexKey{multipoles/external pad fraction} to something different form 0 (default is \texttt{0}); the value expresses the fraction of the pin spacing space that the pad will use on both sides of the pin.
8825
8826 You can, if you want, avoid printing the numbers of the pin with \IndexKey{hide numbers} (default \IndexKey{show numbers}) if you prefer positioning them yourself (see the next section for the anchors you can use).
8827
8828 \begin{ctikzExample}
8829 \begin{circuitikz}
8830 \ctikzset{multipoles/thickness=4}
8831 \ctikzset{multipoles/external pins thickness=2}
8832 \draw (0,0) node[dipchip,
8833 num pins=12,
8834 hide numbers,
8835 external pins width=0.3,
8836 external pad fraction=4 ](C){IC1};
8837 \draw (C.pin 1) -- ++(-0.5,0) to[R]
8838 ++(0,-3) node[ground]{};
8839 \node [right, font=\tiny]
8840 at (C.bpin 1) {RST};
8841 \end{circuitikz}
8842 \end{ctikzExample}
8843
8844
8845 Also, you can suppress the drawing of the pins, by using the style \IndexKey{no input leads} (that can be reverted with \IndexKey{input leads}). The main difference between setting \texttt{external pins width} to \texttt{0} or using \texttt{no input lead} is that in the first case the normal pin anchors and the border anchors will coincide, and in the second case they will not move and stay where they should have been if the leads were drawn.
8846
8847 For special use you can suppress the orientation mark with the key \IndexKey{no topmark} (default \IndexKey{topmark}).
8848
8849 \begin{ctikzExample}
8850 \begin{circuitikz}
8851 \draw (0,0) node[dipchip,
8852 num pins=8, no topmark,
8853 external pins width=0.0](C){IC1};
8854 \draw (C.pin 1) -- ++(-0.5,0) to[R]
8855 ++(0,-1.5) node[ground]{};
8856 \end{circuitikz}
8857 \end{ctikzExample}
8858
8859 The font used for the pins is adjustable with the key \IndexKey{multipoles/font} (default \verb|\tiny|)
8860
8861 \begin{ctikzExample}
8862 \begin{circuitikz}
8863 \ctikzset{multipoles/font={\color{red}\tiny}}
8864 \draw (0,0) node[qfpchip,
8865 num pins=16,
8866 external pad fraction=6](C){IC1};
8867 \draw (C.pin 1) -- ++(-0.5,0) to[R]
8868 ++(0,-2) node[ground]{};
8869 \end{circuitikz}
8870 \end{ctikzExample}
8871
8872 You can draw only selected pins and leave out the rest by setting
8873 \IndexKey{multipoles/draw only pins}\footnote{Added by
8874 \href{https://github.com/circuitikz/circuitikz/pull/550}{Jonathan P. Spratte in \texttt{v1.3.8}}}.
8875 This key accepts a comma-separated list of
8876 pin numbers or ranges of pin numbers (a range is given as
8877 \texttt{$\langle$start$\rangle$ - $\langle$end$\rangle$}, ends are inclusive).
8878 The numbers will not be expanded in any way, except those given as ends of
8879 ranges. A special value (and the initial one) is \texttt{all}, in which case all
8880 pins are drawn. The anchors will be adjusted, such that each \texttt{pin
8881 \textit{n}} will be placed at the end of the pins which are drawn, and coincide
8882 with the \texttt{bpin \textit{n}} anchors for the suppressed pins.
8883
8884
8885 \begin{ctikzExample}
8886 \begin{circuitikz}
8887 \draw (0,3) node[dipchip,
8888 num pins=8,
8889 draw only pins={1, 3, 5-8}](C){IC1};
8890 \draw (C.pin 1) -- ++(-0.5,0) to[R]
8891 ++(0,-1.5) node[ground]{};
8892 \foreach \x in {1,...,8} {
8893 \draw[red] (C.pin \x) circle[radius=2pt];
8894 \draw[blue] (C.bpin \x) circle[radius=1pt];
8895 }
8896 \draw (0, 0) node[qfpchip, draw only pins={1-2, 6, 8, 4},
8897 external pad fraction=4, num pins=12](Q){};
8898 \foreach \x in {1,...,12} {
8899 \draw[red] (Q.pin \x) circle[radius=2pt];
8900 \draw[blue] (Q.bpin \x) circle[radius=1pt];
8901 }
8902 \end{circuitikz}
8903 \end{ctikzExample}
8904
8905 \subsubsection{Chip anchors}
8906 \label{sec:chip-anchors}
8907
8908 Chips have anchors on pins and global anchors for the main shape.
8909 The pin anchors to be used to connect wires to the chip are called \texttt{pin 1}, \texttt{pin 2} , \dots, with just one space between \texttt{pin} and the number.
8910 Border pin anchors (\texttt{bpin 1}\dots) are always on the box border, and can be used to add numbers or whatever markings are needed.
8911 Obviously, in case of \texttt{multipoles/external pins width} equal to zero, border and normal pin anchors will coincide.
8912
8913 Additionally, you have geometrical anchors on the chip ``box'', see the following figure. The nodes are available with the full name (like \texttt{north}) and with the short abbreviations \texttt{n}, \texttt{nw}, \texttt{w}\dots. The \texttt{dot} anchor is useful to add a personalized marker if you use the \texttt{no topmark} key.
8914
8915 \begin{quote}
8916 \bigskip
8917 \def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=0.2cm, fill=white, fill opacity=0.5, text opacity=1, pin edge={red, overlay,}]75:#1}](#1){}}
8918 \def\coordd(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=0.2cm, fill=white, fill opacity=0.5, text opacity=1,pin edge={red, overlay,}]-45:#1}](#1){}}
8919 \begin{circuitikz}[american, ]
8920 \ctikzset{multipoles/dipchip/pin spacing=0.7}
8921 \draw (0,0) node[dipchip,
8922 external pins width=0.4,
8923 external pad fraction=4](C){IC1};
8924 \foreach \p in {1,...,8}
8925 \path (C.pin \p) \coord(pin \p)
8926 (C.bpin \p) \coordd(bpin \p);
8927 % second chip
8928 \draw (C.pin 7) to[R] ++(3,0)
8929 node[dipchip,anchor=pin 2](D){IC2};
8930 \foreach \p in {center, nw, ne, se, sw, north, south, west, east}
8931 \path (D.\p) \coord(\p);
8932 \path (D.text) \coordd(text);
8933 % third chip
8934 \draw (D.pin 7) ++(2,0)
8935 node[dipchip,anchor=pin 2, no topmark](E){};
8936 \foreach \p in {center, n, w, e, s, dot}
8937 \path (E.\p) \coord(\p);
8938 \end{circuitikz}
8939 \end{quote}
8940
8941 \subsubsection{Chip rotation}\label{sec:chip-rotation}
8942
8943 You can rotate chips, and normally the pin numbers are kept straight (option \IndexKey{straight numbers}, which is the default), but you can rotate them if you like with \IndexKey{rotated numbers}.
8944 Notice that the main label has to be (counter-) rotated manually in this case.
8945
8946 \begin{ctikzExample}
8947 \begin{circuitikz}
8948 \draw (0,0) node[dipchip,
8949 rotate=90]{%
8950 \rotatebox{-90}{IC2}};
8951 \draw (3,0) node[qfpchip,
8952 rotated numbers,
8953 rotate=45]{IC3};
8954 \end{circuitikz}
8955 \end{ctikzExample}
8956
8957 \subsubsection{Chip special usage}
8958 \label{sec:chip-special-usage}
8959
8960 You can use chips to have special, personalized blocks.
8961 Look at the following example, which is easily put into a macro.
8962
8963 \begin{ctikzExample}
8964 \begin{circuitikz}
8965 \ctikzset{multipoles/thickness=3}
8966 \ctikzset{multipoles/dipchip/width=2}
8967 \draw (0,0) node[dipchip,
8968 num pins=10, hide numbers, no topmark,
8969 external pins width=0](C){Block};
8970 \node [right, font=\tiny] at (C.bpin 1) {RST};
8971 \node [right, font=\tiny] at (C.bpin 2) {IN1};
8972 \node [right, font=\tiny] at (C.bpin 4) {/IN2};
8973 \node [left, font=\tiny] at (C.bpin 8) {OUT};
8974 \draw (C.bpin 2) -- ++(-0.5,0) coordinate(extpin);
8975 \node [ocirc, anchor=0](notin2) at (C.bpin 4) {};
8976 \draw (notin2.180) -- (C.bpin 4 -| extpin);
8977 \draw (C.bpin 8) to[short,-o] ++(0.5,0);
8978 \draw (C.bpin 5) ++(0,0.1) -- ++(0.1,-0.1)
8979 node[right, font=\tiny]{CLK} -- ++(-0.1,-0.1);
8980 \draw (C.n) -- ++(0,1) node[vcc]{};
8981 \draw (C.s) -- ++(0,-1) node[ground]{};
8982 \end{circuitikz}
8983 \end{ctikzExample}
8984
8985 \subsection{Seven segment displays}
8986 \label{sec:seven-segment-displays}
8987
8988 \begin{groupdesc}
8989 \circuitdesc*{bare7seg}{Seven segment display}{}
8990 \end{groupdesc}
8991
8992 The seven-segment display\IndexKey[seven-segment display]{}\IndexKey[7-segment display]{} lets you show values as if they were displayed in a classical seven-segment display.\footnote{This component has been loosely inspired by the package \texttt{SevenSeg} by Germain Gondor, 2009, see \href{http://www.texample.net/tikz/examples/seven-segment-display/}{\TeX{}example.net}.}
8993
8994 The main ``bare'' component is the one shown above, but for simplicity a couple of style interfaces are defined:
8995
8996 \begin{ctikzExample}
8997 \begin{circuitikz}
8998 \draw (0,0) node[seven segment val=A dot off box on]{};
8999 \draw (1,0) node[seven segment val=- dot none box on]{};
9000 \draw (0,-2) node[seven segment bits=1001001 dot empty box on]{};
9001 \draw (1,-2) node[seven segment bits=0011101 dot none box off]{};
9002 \end{circuitikz}
9003 \end{ctikzExample}
9004
9005 There are two main configuration methods. The first one is \IndexKey{seven segment val}, which will take an hexadecimal number or value and display it: the possible values are \texttt{0,...,15}, plus \texttt{A, B, C, D, E, F} (or lowercase) and the symbol \texttt{-} (minus).
9006
9007
9008 The other interface is \IndexKey{seven segment bits}, where you specify seven bits saying which segment must be on (please never specify a different number of bits, it will throw a very obscure error); you can see in the anchors the name of each segment.
9009
9010 The option \texttt{dot} specifies if you want a decimal dot or not. The key \texttt{none} will remove the dot and the space it would take; \texttt{empty} will not show the dot at all but reserve the space, and \texttt{on} or \texttt{off} will show the dot in the corresponding state.
9011
9012 The option \texttt{box} (can be \texttt{on} or \texttt{off}) simply toggles the drawing of the external box. You can separate it from the display with the key \IndexKey{seven seg/box sep} (default \texttt{1pt}), and it will use the thickness specified in \texttt{multipoles/thickness} (The same as the chips).
9013
9014 You can use these option with the ``bare'' object \texttt{bare7seg} and the keys \IndexKey{seven seg/bits} (default \texttt{0000000}), \IndexKey{seven seg/dot} (default \texttt{none}) and \IndexKey{seven seg/box} (default \texttt{off}); there is no option equivalent to the \texttt{val} interface.
9015
9016 \subsubsection{Seven segments anchors}
9017 \label{sec:seven-segments-anchors}
9018
9019 These are the anchors for the seven-segment displays; notice that when the \texttt{dot} parameter is not \texttt{none}, the cell is a bit wider at the right side.
9020
9021 \begingroup
9022 \ctikzset{seven seg/color off=gray, multipoles/thickness=1}
9023 \showanchors{bare7seg}{}(north/90/0.4, north east/45/0.4, east/0/0.4,
9024 south east/-45/0.4, south/-90/0.4, south west/-135/0.4, west/180/0.4,
9025 north west/135/0.4, center/-140/0.5)
9026 \ctikzset{seven seg/dot=off}
9027 \ctikzset{seven seg/box=on}
9028 \showanchors{bare7seg}{}(north/90/0.4, north east/45/0.4, east/0/0.4,
9029 south east/-45/0.4, south/-90/0.4, center/-140/0.5)
9030 \ctikzset{seven seg/box=off}
9031 \showanchors{bare7seg}{}(a/90/0.4, b/45/0.4, c/0/0.4, d/-90/0.4,
9032 e/-129/0.4, f/145/0.4, g/190/0.4, dot/-45/0.2)
9033 \endgroup
9034
9035 \subsubsection{Seven segments customization}
9036 \label{sec:seven-segments-customization}
9037
9038 You can scale the seven segment display with the key \IndexKey{displays/scale}. This will scale the size of the digit, but not the absolute sizes shown below --- if you want them to scale, yo have to do it manually.
9039
9040 You can change several parameters to adjust the displays:
9041 \begin{lstlisting}[basicstyle=\small\ttfamily]
9042 \ctikzset{seven seg/width/.initial=0.4}% relative to \pgf@circ@Rlen (scalable)
9043 \ctikzset{seven seg/thickness/.initial=4pt}% segment thickness (not scaled)
9044 \ctikzset{seven seg/segment sep/.initial=0.2pt}% gap between segments (not scaled)
9045 \ctikzset{seven seg/box sep/.initial=1pt}% external box gap (not scaled)
9046 \ctikzset{seven seg/color on/.initial=red}% color for segment "on"
9047 \ctikzset{seven seg/color off/.initial=gray!20!white} % ...and "off"
9048 \end{lstlisting}
9049
9050 A couple of examples are shown below.
9051
9052 \begin{ctikzExample}[varwidth=true, pos=b]
9053 \begin{circuitikz}[scale=0.5]
9054 \ctikzset{seven seg/width=0.2, seven seg/thickness=2pt}
9055 \foreach \i in {0,...,15} \path (\i,0)
9056 node[seven segment val=\i dot on box off]{};
9057 \ctikzset{seven seg/color on=black}
9058 \foreach \i in {0,...,15} \path (\i,-1.5)
9059 node[seven segment val=\i dot off box off, fill=gray!30!white]{};
9060 \ctikzset{seven seg/color on=green, seven seg/color off=yellow!30}
9061 \foreach \i in {0,...,15} \path[color=red] (\i,-3)
9062 node[seven segment val=\i dot none box on, xslant=0.2]{};
9063 \end{circuitikz}
9064 \end{ctikzExample}
9065
9066
9067
9068 \section{Labels, voltages and currents}
9069 \label{sec:labels-voltages-and}
9070
9071 You can add ``decorations'' to the path-style components; there are basically five types of them: labels, annotations, voltages, currents, and flows. Let's see an example of all of them\dots
9072
9073 \begin{ctikzExample}
9074 \begin{circuitikz}
9075 \draw (0,0) to[R, l=$R_1$, f=$i_1$] (2,0);
9076 \end{circuitikz}
9077 \end{ctikzExample}
9078
9079 \begin{ctikzExample}
9080 \begin{circuitikz}
9081 \draw (0,0) to[R=$R_1$, a=\SI{1}{\kohm}] (2,0);
9082 \end{circuitikz}
9083 \end{ctikzExample}
9084
9085
9086 \begin{ctikzExample}
9087 \begin{circuitikz}
9088 \draw (0,0) to[R, i=$i_1$] (2,0);
9089 \end{circuitikz}
9090 \end{ctikzExample}
9091
9092 \begin{ctikzExample}
9093 \begin{circuitikz}
9094 \draw (0,0) to[R, v=$v_1$] (2,0);
9095 \end{circuitikz}
9096 \end{ctikzExample}
9097
9098 \begin{ctikzExample}
9099 \begin{circuitikz}
9100 \draw (0,0) to[R=$R_1$, i=$i_1$, v=$v_1$] (2,0);
9101 \end{circuitikz}
9102 \end{ctikzExample}
9103
9104 \begin{ctikzExample}
9105 \begin{circuitikz}
9106 \draw (0,0) to[R=$R_1$, i=$i_1$, v=$v_1$] (2,0);
9107 \end{circuitikz}
9108 \end{ctikzExample}
9109
9110 Long names/styles for the bipoles can be used, of course, and there is a special syntax (that works only in simple cases, and only with \LaTeX{} --- use it with caution!) if you load the package with the \IndexKey{siunitx} options:
9111
9112 \begin{ctikzExample}
9113 \begin{circuitikz}\draw
9114 (0,0) to[resistor=1<\kilo\ohm>] (2,0);
9115 \end{circuitikz}
9116 \end{ctikzExample}
9117
9118 \subsection{Labels and Annotations}
9119 \label{sec:labels-and-annotations}
9120 Since Version 0.7, beside the original label (\IndexKey[l (label)]{l}) option, there is a new option to place a second label, called annotation (\IndexKey[a (annotation]{a}) at each bipole.
9121
9122 \subsubsection{Label and annotation position}
9123 \label{sec:label-and-annotation}
9124 When drawing a component left-to-right, the label \texttt{l} is by default above the component, and the annotation \texttt{a} is by default below it. The position of annotations and labels can be adjusted adding the characters \verb|_| or \verb|^| to the key.
9125
9126 \begin{ctikzExample}
9127 \begin{circuitikz}
9128 \draw (0,0) to[R, l=$R_1$,a=1<\kilo\ohm>] (2,0);
9129 \end{circuitikz}
9130 \end{ctikzExample}
9131
9132 \begin{ctikzExample}
9133 \begin{circuitikz}
9134 \draw (0,0) to[R, l_=$R_1$,a^=1<\kilo\ohm>] (2,0);
9135 \end{circuitikz}
9136 \end{ctikzExample}
9137
9138 For passive components, you can use \texttt{\emph{component type}=text} as a shortcut for \texttt{\emph{component type}, l=text}:
9139
9140 \begin{ctikzExample}
9141 \begin{circuitikz}
9142 \draw (0,0) to[R=$R_1$,a=1<\kilo\ohm>] (2,0);
9143 \end{circuitikz}
9144 \end{ctikzExample}
9145
9146 Notice though that in active component (sources of either voltage or current) the shortcut will set the voltage (\IndexKey[v (voltage)]{v}) or current (\IndexKey[i (current)]{i}) property.
9147
9148 \paragraph{Adjust label and annotation position.}\label{sec:adjust-label-position}
9149 Normally the package will guess a good position for the label or annotation; if you do not like it,
9150 you can add\footnote{Since version \texttt{1.3.3}} (or remove, with negative values) distance using the \verb|\ctikzset| keys \IndexKey{label distance} and \IndexKey{annotation distance}.
9151
9152 \begin{ctikzExample}
9153 \begin{circuitikz}
9154 \draw (0,0) to[sR, l=$R$, label distance=-4pt] (2,0)
9155 to [sR, l=$R$] (4,0);
9156 \end{circuitikz}
9157 \end{ctikzExample}
9158
9159 \begin{ctikzExample}
9160 \begin{circuitikz}[american]
9161 \ctikzset{bipoles/inductors/core distance=4pt}
9162 \draw (0,1) to[L=$L$, name=myL] ++(2,0);
9163 \draw[thick, double] (myL.core west) -- (myL.core east);
9164 \draw (0,0) to[L=$L$, name=myL, label distance=2pt] ++(2,0);
9165 \draw[thick, double] (myL.core west) -- (myL.core east);
9166 \end{circuitikz}
9167 \end{ctikzExample}
9168
9169 \subsubsection{Special symbols in labels and annotations.}\label{sec:bracing-of-labels}
9170 When \TikZ{} processes the options, there will be problems if the label (or annotation, voltage, or current) contains one of the characters $=$ (equal) or $,$ (comma) --- because the parser search for those two characters to delimit the arguments, giving unexpected errors and wrong output.
9171 These two characters can be protected from the option parser using an extra set of braces.
9172
9173 \begin{ctikzExample}
9174 \begin{circuitikz}
9175 % the following will fail:
9176 % \draw (0,0) to[R, l=$R=3$]
9177 \draw (0,0) to[R, l={$R=3$}] (3,0);
9178 \draw (0,0) to[R={$R=3$}] (0,3);
9179 \draw (3,3) to[R={$R,3$}] (3,0);
9180 % this works, but it has wrong spacing
9181 \draw (0,3) to[R, l=$R{=}3$] (3,3);
9182 \end{circuitikz}
9183 \end{ctikzExample}
9184
9185 \textbf{Caveat:} up to version \texttt{1.2.7}, due to the way in which \Circuitikz{} used to processes the options, even that was not sufficient, so you must protect that tokens even more, for example using an \verb|\mbox| command, or redefining the characters with a \TeX\ \verb|\def|:
9186
9187 \begin{ctikzExample}
9188 \begin{circuitikz}
9189 \def\eq{=}
9190 % the following will fail up to 1.2.7:
9191 % \draw (0,0) to[R, l={$R=3$}] (3,0);
9192 \draw (0,0) to[R, l=\mbox{$R=3$}] (3,0);
9193 \draw (0,0) to[R, l=$R\eq3$] (0,3);
9194 \draw (3,3) to[R, l=\mbox{$R,3$}] (3,0);
9195 % this works, but it has wrong spacing
9196 \draw (0,3) to[R, l=$R{=}3$] (3,3);
9197 \end{circuitikz}
9198 \end{ctikzExample}
9199
9200
9201 \subsubsection{Labels and annotation orientation.}
9202 \label{sec:labels-and-annotation}
9203 The default orientation of labels is controlled by the options \IndexKey{smartlabels}, \IndexKey{rotatelabels} and \IndexKey{straightlabels} (or the corresponding \IndexKey{label/align} keys). Here are examples to see the differences:
9204 \begin{ctikzExample}
9205 \begin{circuitikz}
9206 \ctikzset{label/align = straight}
9207 \def\DIR{0,45,90,135,180,-90,-45,-135}
9208 \foreach \i in \DIR {
9209 \draw (0,0) to[R=\i, *-o] (\i:2.5);
9210 }
9211 \end{circuitikz}
9212 \end{ctikzExample}
9213 \begin{ctikzExample}
9214 \begin{circuitikz}
9215 \ctikzset{label/align = rotate}
9216 \def\DIR{0,45,90,135,180,-90,-45,-135}
9217 \foreach \i in \DIR {
9218 \draw (0,0) to[R=\i, *-o] (\i:2.5);
9219 }
9220 \end{circuitikz}
9221 \end{ctikzExample}
9222 \begin{ctikzExample}
9223 \begin{circuitikz}
9224 \ctikzset{label/align = smart}
9225 \def\DIR{0,45,90,135,180,-90,-45,-135}
9226 \foreach \i in \DIR {
9227 \draw (0,0) to[R=\i, *-o] (\i:2.5);
9228 }
9229 \end{circuitikz}
9230 \end{ctikzExample}
9231
9232 \subsubsection{Stacked (two lines) labels.}
9233 \label{sec:stacked-two-lines}
9234
9235 When using \texttt{circuitikz} in LaTeX, you can use stacked (two lines) labels. The example should be self-explanatory: the two lines are specified as \IndexKey{l2=}\emph{line1}\texttt{ and }\emph{line2}. You can use the keys \IndexKey{l2 halign} to control horizontal position (\texttt{l}eft, \texttt{c}enter, \texttt{r}ight) and \IndexKey{l2 valign} to control the vertical one (\texttt{b}ottom, \texttt{c}enter, \texttt{t}op). The default values for alignments are thought for vertical components (where the stacke labels are more natural), in other positions you have to force them.
9236
9237 Notice that you \textbf{can't use} the compact \texttt{<...>} notation for \texttt{siunitx} with stacked labels. Before \texttt{v1.3.6} the label was ignored, but that has been converted into an error.
9238
9239 Since \texttt{v1.3.6} you have the same possibility with the \texttt{annotation} (just use \IndexKey{a2=...}, \verb|a2_=...|, \IndexKey{a2 valign} and so on. Notice that the default position for stacked annotation is \IndexKey[a2 halign]{a2 halign=l}.
9240
9241 The \texttt{l2} and \texttt{a2} will only work in LaTeX because they use a \texttt{tabular} environment in their implementation. For plain TeX and \ConTeXt{} you have to use \texttt{l} and \texttt{a} and build the stack of labels externally.
9242
9243 %
9244 % This is hacky --- better not to publish it for now
9245 %
9246 % \begin{circuitikz}[]
9247 % \draw (0,2) to [R, l2= {A=B} and X, l2 valign=b, l2 halign=c] ++(2,0) to[L, l2=A and X \\ {C=Z}] ++(0,-2);
9248 % \end{circuitikz}
9249
9250 \begin{ctikzExample}[varwidth=true, pos=t, keepspaces, basicstyle=\footnotesize\ttfamily]
9251 \begin{circuitikz}[american]
9252 %
9253 % default for l2 is: l2 halign=l, l2 valign=c. DO NOT USE the <...> notation
9254 %
9255 \draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, , l2 valign=t] ++(2,0);
9256 \draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, , ] ++(0,2);
9257 \draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=b] ++(-2,0);
9258 \draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=r, l2 valign=c] ++(0,-2);
9259 \draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=b] ++(2,0);
9260 \draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, ] ++(0,2);
9261 \draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, , l2 valign=t] ++(-2,0);
9262 \draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=t] ++(0,-2);
9263 \draw (10,2) to[R, l2={A=B} and X, a2={C=D} and Y] ++(0,-4);
9264 \end{circuitikz}
9265 \end{ctikzExample}
9266
9267 For extra options about labels and annotations, please refer to section~\ref{sec:ornament-style}
9268
9269
9270 \subsection{Currents and voltages}\label{curr-and-volt}
9271
9272 The default direction/sign for currents and voltages in the components is, unfortunately, not standard, and can change across country and sometime across different authors.
9273 This unfortunate situation created a bit of confusion in \texttt{circuitikz} across the versions, with several incompatible changes starting from version 0.5.
9274 From version 0.9.0 onward, the maintainers agreed a new policy for the directions of bipoles' voltages and currents, depending on 4 different possible options:
9275 \begin{itemize}
9276 \item \IndexKey{oldvoltagedirection}, or the key style \IndexKey[voltage dir]{voltage dir=old}: Use old way of voltage direction having a difference between european and american direction, with wrong default labeling for batteries (it was the default before version 0.5);
9277 \item \IndexKey{nooldvoltagedirection}, or the key style \texttt{voltage dir=noold}: The standard from version 0.5 onward, utilize the (German?) standard of voltage arrows in the direction of electric fields (without fixing batteries);
9278 \item \IndexKey{RPvoltages} (meaning Rising Potential voltages), or the key style \texttt{voltage dir=RP}: the arrow is in direction of rising potential, like in \texttt{oldvoltagedirection}, but batteries and current sources are fixed so that they follow the passive/active standard: the default direction of \texttt{v} and \texttt{i} are chosen so that, when both values are positive:
9279 \begin{itemize}
9280 \item in passive component, the element is \emph{dissipating power};
9281 \item in active components (generators), the element is \emph{generating power}.
9282 \end{itemize}
9283 \item \IndexKey{EFvoltages} (meaning Electric Field voltages), or the key style \texttt{voltage dir=EF}: the arrow is in the direction of the electric field, like in \texttt{nooldvoltagedirection}, but batteries are fixed;
9284 \end{itemize}
9285 Notice that the four styles are designed to be used at the environment level: that is, you should use them at the start of your environment as in \verb|\begin{circuitikz}[voltage dir=old] ...| and not as a key for single components, in which case the behavior is not guaranteed.
9286
9287 The standard direction of currents, flows and voltages are changed by these options; notice that the default drops in case of passive and active elements is normally different. Take care that in the case of \texttt{noold} and \texttt{EFvoltages} also the currents can switch directions. It is much easier to understand the several behaviors by looking at the following examples, that have been generated by the code:
9288
9289 \begin{ctikzExample}[exec outside]
9290 \foreach\element in {R, C, D, battery2, V, I, sV, cV, cI}{%
9291 \noindent\ttfamily
9292 \begin{tabular}{p{2cm}}
9293 \element \\ american \\[15pt]
9294 \element \\ european \\
9295 \end{tabular}
9296 \foreach\mode in {old, noold, RP, EF} {
9297 \begin{tabular}{@{}l@{}}
9298 \multicolumn{1}{c}{voltage dir} \\
9299 \multicolumn{1}{c}{dir=\mode} \\[4pt]
9300 \begin{tikzpicture}[
9301 american, voltage dir=\mode,
9302 ]
9303 \draw (0,0) to[\element, *-o, v=$v_1$, i=$i_1$, ] (2.5,0);
9304 \end{tikzpicture}\\
9305 \begin{tikzpicture}[
9306 european, voltage dir=\mode,
9307 ]
9308 \draw (0,0) to[\element, *-o, v=$v_1$, i=$i_1$, ] (2.5,0);
9309 \end{tikzpicture}
9310 \end{tabular}
9311 \medskip
9312 }
9313 \par
9314 }
9315 \end{ctikzExample}
9316
9317
9318 Obviously, you normally use just one between current and flows, but anyway you can
9319 change the direction of the voltages,
9320 currents and flows using the complete keys \verb|i_>|, \verb|i^<|, \verb|i>_|, \verb|i>^|,
9321 as shown in the following examples.
9322
9323 This manual has been typeset with the option \texttt{\chosenvoltoption}.
9324
9325 \subsubsection{Common properties of voltages and currents}
9326 \label{sec:common-vif-pos}
9327
9328 Currents, voltages and flows (see later) are positioned along, or across, the part of the wires that connect the inner component to the rest of the circuit. So, changing the length of the connection (the coordinates that embrace the \texttt{to[...]} command) will change the position of the components.
9329
9330 \begin{ctikzExample}
9331 \begin{circuitikz}
9332 \draw (-1,1) to[R, v=$v$, i=$i$, f>^=$f$] (1,1);
9333 \draw (-2,0) to[R, v=$v$, i=$i$, f>^=$f$] (2,0);
9334 \end{circuitikz}
9335 \end{ctikzExample}
9336
9337 However, you can override the properties \IndexKey{voltage/distance from node} (default \texttt{0.5}: how distant from the initial and final points of the path the arrow starts and ends or the plus and minus symbols are drawn) and \IndexKey{voltage/bump b} (how high the bump of the arrow is --- how curved it is, default \texttt{1.5}), and also \IndexKey{voltage/european label distance} (how distant from the normal position the voltage label will be, default \texttt{1.4}) on a per-component basis, in order to fine-tune the voltages:
9338
9339 \begin{ctikzExample}[varwidth=true]
9340 \tikz \draw (0,0) to[R, v=1<\volt>] (2,0); \par
9341 \ctikzset{voltage/distance from node=.1}
9342 \ctikzset{voltage/bump b=2.5}
9343 \tikz \draw (0,0) to[R, v=1<\volt>] (2,0);
9344 \end{ctikzExample}
9345
9346 You can also use a global \texttt{ctikzset} on the key \texttt{voltage/distance from node} (and similar) that will act as a default value. Notice however that the specific component value \textbf{overrides} the global one, and several components have pre-defined overrides, so they will ignore the default value. The components that have out of the box predefined overrides for \IndexKey[distance from node, override]{distance from node} are \texttt{generic}, \texttt{ageneric}, \texttt{fullgeneric} and \texttt{memristor} (set to \texttt{0.4}), and the ones that have it for \texttt{bump b} are
9347 \texttt{generic}, \texttt{ageneric}, \texttt{fullgeneric}, \texttt{memristor}, \texttt{tline}, \texttt{varistor}, \texttt{photoresistor}, \texttt{thermistor}, \texttt{thermistorntc}, \texttt{thermistorptc}, \texttt{ccapacitor}, \texttt{emptyzzdiode}, \texttt{fullzzdiode}, \texttt{emptythyristor}, \texttt{fullthyristor}, \texttt{emptytriac} and \texttt{fulltriac},, with several values (you can look at them in the file \texttt{pgfcirc.defines.tex}).\footnote{To achieve consistent results of \texttt{voltage/distance from node=0} refer to this solution by Jakob Leide on \href{https://tex.stackexchange.com/questions/757418/circuitikz-inconsistent-behaviour-of-voltage-distance-from-node}{tex.stackexchange.com}.}
9348
9349
9350 Notice also that normally \texttt{distance from node} is a relative displacement, computed on the node-component wire. So that this will put the start and stop point $1/4$ of the way between node and component:
9351
9352 \begin{ctikzExample}
9353 \begin{circuitikz}
9354 \ctikzset{voltage/distance from node=0.25}
9355 \draw (0, 2) to[D, v=$v_1$] ++(4,0);
9356 \draw (0, 1) to[D, v=$v_1$] ++(3,0);
9357 \draw (0, 0) to[D, v=$v_1$] ++(2,0);
9358 \end{circuitikz}
9359 \end{ctikzExample}
9360
9361 The value of \texttt{distance from node} can also be an absolute distance; in that case is measured from the start of the connection toward the component on the left (and symmetrically on the right), so this will put the start and end point to \SI{0.25}{\cm} from the start of the node:
9362
9363 \begin{ctikzExample}
9364 \begin{circuitikz}
9365 \ctikzset{voltage/distance from node=0.25cm}
9366 \draw (0, 2) to[D, v=$v_1$] ++(4,0);
9367 \draw (0, 1) to[D, v=$v_1$] ++(3,0);
9368 \draw (0, 0) to[D, v=$v_1$] ++(2,0);
9369 \end{circuitikz}
9370 \end{ctikzExample}
9371
9372 There is currently no way to specify the position at a fixed distance from the component (as opposed as from the node).
9373
9374 The same concept as \texttt{distance from node} applies to the key \IndexKey{current/distance} for the position of the current's arrow (and to \IndexKey{flow/distance} for the flow arrow position):
9375
9376 \begin{ctikzExample}[varwidth=true]
9377 \tikz \draw (0,0) to[C, i=$\imath$] (2,0); \par
9378 \ctikzset{current/distance = .2}
9379 \tikz \draw (0,0) to[C, i=$\imath$] (2,0);
9380 \end{ctikzExample}
9381
9382 If you want to change those parameters by defining a component-specific key you have to use the internal name of the component (in the component list, is the \texttt{nodename} without the terminal ``\texttt{shape}'' part):
9383
9384 \begin{ctikzExample}[varwidth=true]
9385 \tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0)
9386 to[C, v=2<\volt>] (3,0); \par
9387 \ctikzset{bipoles/capacitor/voltage/distance from node/.initial=.7}
9388 \tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0)
9389 to[C, v=2<\volt>] (3,0); \par
9390 \end{ctikzExample}
9391
9392 Note the \texttt{.initial}; you have to create such key the first time you use it. These kinds of adjustments are not guaranteed to work in future upgrades, though; if you have to create a key you are somehow touching the internal structure of the package; it's much safer to create a style.
9393
9394 One common request is to change the style of the arrows (both head and line) of these elements. Voltages, currents and flows are part of the same path of the component, so this is not possible in simple way; you have to draw your own with \TikZ{} commands using the facilities explained in section~\ref{sec:vif-anchors}.
9395
9396 \subsubsection{Special treatment for generators}\label{sec:source-vif}
9397
9398 The ``active'' elements (sources and batteries, mainly) are treated differently from passive elements, in the sense that the default current and voltage direction and position could be different\footnote{This, in hindsight, has been a bad feature --- and I'm partly responsible for it. But removing it would create \emph{too small} variations in circuits, easily to go unnoticed, so it stays: nobody wants \emph{wrong} circuits just by recompiling.} following the chosen global voltage direction strategy (see section~\ref{curr-and-volt}). If they change or not depend on both the element and the chosen \texttt{voltage dir} option.
9399
9400 \begin{ctikzExample}
9401 \begin{tikzpicture}[]
9402 \draw (0,0) to[sV, v=$V_s$] ++(2,0)
9403 to[battery, v=$V_B$] ++(2,0)
9404 to[R, v=$V_R$] ++(2,0);
9405 \end{tikzpicture}
9406 \end{ctikzExample}
9407
9408 The consistency between symbols drawings and the default voltage and current directions are designed to work well \emph{when this default is enabled}. If you want, though, you can override this behavior by ``switching off'' the source status of the component by setting the property \IndexKey{bipole/is voltage} to \texttt{false}:
9409
9410 \begin{ctikzExample}
9411 \begin{tikzpicture}[]
9412 \draw (0,0) to[sV, bipole/is voltage=false,
9413 v=$V_s$] ++(2,0)
9414 to[battery, bipole/is voltage=false,
9415 v=$V_B$] ++(2,0)
9416 to[R, v=$V_R$] ++(2,0);
9417 \end{tikzpicture}
9418 \end{ctikzExample}
9419
9420 When you do this, \textbf{be careful} that (as you can see) the direction of the plain \texttt{v=...} option will change (please notice that this does not mean that it is incorrect, given that the voltage and current direction are arbitrary; in the case above, if the battery is a \SI{3}{V} one, $V_B=\SI{-3}{V}$ with the \texttt{RPvoltages} conventions).
9421
9422 Also, notice that there is an ordering problem in the \texttt{to[...]} options: you have to switch the \texttt{is voltage} property off \textbf{before} setting the voltage, otherwise you will have a mix of the source-type and passive positioning:
9423
9424 \begin{ctikzExample}
9425 \begin{tikzpicture}[]
9426 % correct way
9427 \draw (0,0) to[sV, bipole/is voltage=false, v=$V_s$] ++(2,0)
9428 % wrong way, setting voltage before changing type
9429 to[sV=$V_B$ , bipole/is voltage=false, ] ++(2,0);
9430 \end{tikzpicture}
9431 \end{ctikzExample}
9432
9433 In the first \texttt{to[]} command, the voltage is set before changing the type (assigning a value to the name of the element is understood as a \texttt{v=...} command for voltage sources).
9434
9435 A similar switch is present for current generators, called \IndexKey{bipoles/is current}, acting in a very similar way.
9436
9437 If you would prefer to switch to the \texttt{is voltage=false, is current=false} behavior by default, you can (since \texttt{v1.4.4}\footnote{Suggested by user \href{https://github.com/circuitikz/circuitikz/issues/590}{\texttt{@judober} on GitHub}.}) by setting the option \IndexKey{bipole/override source vif} to \texttt{true}. This is \emph{highly} experimental, so use with care.
9438
9439 \begin{ctikzExample}
9440 \begin{tikzpicture}[]
9441 \draw (0,0) to [battery=vb] ++(2,0)
9442 to[sV=sV] ++(2,0) to[R, v=vR] ++(2,0);
9443 \ctikzset{bipole/override source vif=true}
9444 \draw (0,-2) to [battery=vb] ++(2,0)
9445 to[sV=sV] ++(2,0) to[R, v=vR] ++(2,0);
9446 \end{tikzpicture}
9447 \end{ctikzExample}
9448
9449 Notice that the option \texttt{override source vif} is ``stronger'' than the normal \texttt{is voltage}; so to locally re-set the behavior for just one source, you need to disable that \emph{before} using a voltage designator.
9450
9451 \begin{ctikzExample}
9452 \begin{tikzpicture}[american]
9453 % dangerous option ahead: USE WITH CARE
9454 \ctikzset{bipole/override source vif=true}
9455 % ugly output, you should really use V>=va
9456 \draw (0,6) to [V=va] ++(2,0);
9457 % not working!
9458 \draw (0,4) to [V=va, bipole/override source vif=false] ++(2,0);
9459 % ok, this one is working --- you need both settings!
9460 \draw (0,2) to [V,
9461 bipole/override source vif=false,
9462 bipole/is voltage=true,
9463 v=va] ++(2,0);
9464 \end{tikzpicture}
9465 \end{ctikzExample}
9466
9467 Clearly, if you find yourself using the last component often, it is better to define a style, which will save you a lot of typing and help readability:
9468
9469 \begin{ctikzExample}
9470 \tikzset{myV/.style={V, bipole/override source vif=false,
9471 bipole/is voltage=true, v={#1}}}%
9472 \begin{tikzpicture}[american]
9473 % dangerous option ahead: USE WITH CARE
9474 \ctikzset{bipole/override source vif=true}
9475 \draw (0,0) to [V>=va] ++(2,0);
9476 \draw (0,-2) to[myV=vb] ++(2,0);
9477 \end{tikzpicture}
9478 \end{ctikzExample}
9479
9480 On the other way around, you could use styles to set \texttt{is voltage=false} only on the components you use and without using the global switch --- which is the recommended way of doing it.
9481
9482 \subsection{Currents}\label{sec:currents}
9483
9484 Inline (along the wire) currents are selected with \IndexKey[i (current)]{}\verb|i_>|, \verb|i^<|, \verb|i>_|, \verb|i>^|, and various combinations; the default position and direction is obtained with the simple key \verb|i=...|.
9485
9486 Basically, \verb|^| and \verb|_| control if the label is above or below the line (above and below \textbf{do} depend on the direction of the component path), and \verb|<| and \verb|>| the direction of the arrow; swapping them (from for example from \verb|i^>| to \verb|i>^|) will switch the side of the component where the symbol is drawn. See the following examples:
9487
9488
9489 \begin{ctikzExample}
9490 \begin{circuitikz}
9491 \draw (0,0) to[R, i^>=$i_1$] (2,0);
9492 \end{circuitikz}
9493 \end{ctikzExample}
9494
9495 \begin{ctikzExample}
9496 \begin{circuitikz}
9497 \draw (0,0) to[R, i_>=$i_1$] (2,0);
9498 \end{circuitikz}
9499 \end{ctikzExample}
9500
9501 \begin{ctikzExample}
9502 \begin{circuitikz}
9503 \draw (0,0) to[R, i^<=$i_1$] (2,0);
9504 \end{circuitikz}
9505 \end{ctikzExample}
9506
9507 \begin{ctikzExample}
9508 \begin{circuitikz}
9509 \draw (0,0) to[R, i_<=$i_1$] (2,0);
9510 \end{circuitikz}
9511 \end{ctikzExample}
9512
9513 \begin{ctikzExample}
9514 \begin{circuitikz}
9515 \draw (0,0) to[R, i>^=$i_1$] (2,0);
9516 \end{circuitikz}
9517 \end{ctikzExample}
9518
9519 \begin{ctikzExample}
9520 \begin{circuitikz}
9521 \draw (0,0) to[R, i>_=$i_1$] (2,0);
9522 \end{circuitikz}
9523 \end{ctikzExample}
9524
9525 \begin{ctikzExample}
9526 \begin{circuitikz}
9527 \draw (0,0) to[R, i<^=$i_1$] (2,0);
9528 \end{circuitikz}
9529 \end{ctikzExample}
9530
9531 \begin{ctikzExample}
9532 \begin{circuitikz}
9533 \draw (0,0) to[R, i<_=$i_1$] (2,0);
9534 \end{circuitikz}
9535 \end{ctikzExample}
9536
9537 Also notice that the direction of the path is important:
9538
9539 \begin{ctikzExample}
9540 \begin{circuitikz}
9541 \draw (2,1) to[R, i<=$i_1$] (0,1);
9542 \draw (0,0) to[R, i<=$i_1$] (2,0);
9543 \end{circuitikz}
9544 \end{ctikzExample}
9545
9546 Default directions can change if the component is active or passive,\footnote{This is better explained in section~\ref{sec:source-vif}} following the chosen global voltage direction strategy (see section~\ref{curr-and-volt}).
9547
9548 \begin{ctikzExample}
9549 \begin{circuitikz}
9550 \draw (0,0) to[V=10V, i_=$i_1$] (2,0);
9551 \end{circuitikz}
9552 \end{ctikzExample}
9553
9554 \begin{ctikzExample}
9555 \begin{circuitikz}[voltage dir=EF]
9556 \draw (0,0) to[V=10V, i_=$i_1$] (2,0);
9557 \end{circuitikz}
9558 \end{ctikzExample}
9559
9560 \begin{ctikzExample}
9561 \begin{circuitikz}[american]
9562 \draw (0,0) to[V=10V, i_=$i_1$] (2,0);
9563 \end{circuitikz}
9564 \end{ctikzExample}
9565
9566 \begin{ctikzExample}
9567 \begin{circuitikz}[american]
9568 \draw (0,0) to[V=10V,invert, i_=$i_1$] (2,0);
9569 \end{circuitikz}
9570 \end{ctikzExample}
9571
9572 Current generators with the direct label (the one obtained by, for example, \texttt{I = something}) will treat it as a current:
9573
9574 \begin{ctikzExample}
9575 \begin{circuitikz}
9576 \draw (0,0) to[I=$a_1$] (2,0);
9577 \end{circuitikz}
9578 \end{ctikzExample}
9579
9580 If you use the option \IndexKey{americancurrent} or using the style \IndexKey{american currents}
9581 you can change the style of current generators.
9582
9583 \begin{ctikzExample}
9584 \begin{circuitikz}[american currents]
9585 \draw (0,0) to[I=$a_1$] (2,0);
9586 \end{circuitikz}
9587 \end{ctikzExample}
9588
9589
9590 \subsection{Flows}\label{flows}
9591
9592 As an alternative for the current arrows, you can also use the following ``flows\IndexKey[f (flow, current)]{}''. They can also be used to indicate thermal or power flows. The syntax is pretty the same as for currents.
9593
9594 \begin{ctikzExample}
9595 \begin{circuitikz}
9596 \draw (0,0) to[R, f=$i_1$] (3,0);
9597 \end{circuitikz}
9598 \end{ctikzExample}
9599
9600 \begin{ctikzExample}
9601 \begin{circuitikz}
9602 \draw (0,0) to[R, f<=$i_1$] (3,0);
9603 \end{circuitikz}
9604 \end{ctikzExample}
9605
9606 \begin{ctikzExample}
9607 \begin{circuitikz}
9608 \draw (0,0) to[R, f_=$i_1$] (3,0);
9609 \end{circuitikz}
9610 \end{ctikzExample}
9611
9612 \begin{ctikzExample}
9613 \begin{circuitikz}
9614 \draw (0,0) to[R, f_>=$i_1$] (3,0);
9615 \end{circuitikz}
9616 \end{ctikzExample}
9617
9618 \begin{ctikzExample}
9619 \begin{circuitikz}
9620 \draw (0,0) to[R, f<^=$i_1$] (3,0);
9621 \end{circuitikz}
9622 \end{ctikzExample}
9623
9624 \begin{ctikzExample}
9625 \begin{circuitikz}
9626 \draw (0,0) to[R, f<_=$i_1$] (3,0);
9627 \end{circuitikz}
9628 \end{ctikzExample}
9629
9630 \begin{ctikzExample}
9631 \begin{circuitikz}
9632 \draw (0,0) to[R, f>_=$i_1$] (3,0);
9633 \end{circuitikz}
9634 \end{ctikzExample}
9635
9636 \subsection{Voltages}
9637 \label{sec:voltages}
9638 See the introduction at Currents and Voltages (section~\ref{curr-and-volt}, page \pageref{curr-and-volt}) for the default direction of the voltage and currents.
9639
9640 Voltages come in four different styles: European (with curved or straight arrows) and American (with signs that can stay near the wire or raised at the label level).
9641
9642 Direction and position of the symbols are controlled in the same way as for the currents (see section~\ref{sec:currents}) with the \verb|_^<>| symbols.
9643
9644 \subsubsection{European style} The default, with curved arrows. Use option \IndexKey{europeanvoltage} or style \IndexKey{european voltages}, or setting (even locally) \IndexKey[voltage, european]{voltage=european}.
9645 \label{sec:european-style}
9646
9647 \begin{ctikzExample}
9648 \begin{circuitikz}[european voltages]
9649 \draw (0,0) to[R, v^>=$v_1$] (2,0);
9650 \end{circuitikz}
9651 \end{ctikzExample}
9652
9653 \begin{ctikzExample}
9654 \begin{circuitikz}[european voltages]
9655 \draw (0,0) to[R, v^<=$v_1$] (2,0);
9656 \end{circuitikz}
9657 \end{ctikzExample}
9658
9659 \begin{ctikzExample}
9660 \begin{circuitikz}[european voltages]
9661 \draw (0,0) to[R, v_>=$v_1$] (2,0);
9662 \end{circuitikz}
9663 \end{ctikzExample}
9664
9665 \begin{ctikzExample}
9666 \begin{circuitikz}[european voltages]
9667 \draw (0,0) to[R, v_<=$v_1$] (2,0);
9668 \end{circuitikz}
9669 \end{ctikzExample}
9670
9671 The default direction for active elements can change, depending on the global \texttt{voltage dir} setting, so be careful.
9672
9673 \begin{ctikzExample}
9674 \begin{circuitikz}
9675 \draw (0,0) to[I=1A, v_=$u_1$] (2,0);
9676 \end{circuitikz}
9677 \end{ctikzExample}
9678
9679 \begin{ctikzExample}
9680 \begin{circuitikz}
9681 \draw (0,0) to[I<=1A, v_=$u_1$] (2,0);
9682 \end{circuitikz}
9683 \end{ctikzExample}
9684
9685 \begin{ctikzExample}
9686 \begin{circuitikz}
9687 \draw (0,0) to[I=$~$,l=1A, v_=$u_1$] (2,0);
9688 \end{circuitikz}
9689 \end{ctikzExample}
9690
9691 \begin{ctikzExample}
9692 \begin{circuitikz}
9693 \draw (0,0) to[I,l=1A, v_=$u_1$] (2,0);
9694 \end{circuitikz}
9695 \end{ctikzExample}
9696
9697 Moreover, for historical reasons, voltage generators have differently looking arrows (they are straight even in curved European style).
9698 \begin{ctikzExample}
9699 \begin{circuitikz}
9700 \draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
9701 \end{circuitikz}
9702 \end{ctikzExample}
9703
9704 \begin{ctikzExample}
9705 \begin{circuitikz}
9706 \draw (0,0) to[V=10V, i_=$i_1$] (2,0);
9707 \end{circuitikz}
9708 \end{ctikzExample}
9709
9710 You can change this last thing by forcing ``off'' the status of ``voltage generator'' of the component; but now the normal (passive) rule will apply, so, again, be careful and read section~\ref{sec:source-vif}.
9711
9712 \begin{ctikzExample}
9713 \begin{circuitikz}
9714 \draw (0,0) to[battery, bipole/is voltage=false,
9715 v>=$u_1$,] (2,0);
9716 \end{circuitikz}
9717 \end{ctikzExample}
9718
9719 As for the currents, the direct label of voltage sources is passed as a voltage:
9720
9721 \begin{ctikzExample}
9722 \begin{circuitikz}
9723 \draw (0,0) to[cV=$k\cdot a_1$] (2,0);
9724 \end{circuitikz}
9725 \end{ctikzExample}
9726
9727 The following results from using the option \IndexKey{americanvoltage} or the style \IndexKey{american voltages}.
9728
9729 \begin{ctikzExample}
9730 \begin{circuitikz}[american voltages]
9731 \draw (0,0) to[V=$a_1$] (2,0);
9732 \end{circuitikz}
9733 \end{ctikzExample}
9734
9735 \subsubsection{Straight European style} Using straight arrows. Use option \IndexKey{straightvoltages} or style \IndexKey{straight voltages}, or setting (even locally) \IndexKey[voltage, straight]{voltage=straight}.
9736 \label{sec:straight-european-style}
9737
9738 \begin{ctikzExample}
9739 \begin{circuitikz}[straight voltages]
9740 \draw (0,0) to[R, v^>=$v_1$] (2,0);
9741 \end{circuitikz}
9742 \end{ctikzExample}
9743
9744 \begin{ctikzExample}
9745 \begin{circuitikz}[straight voltages]
9746 \draw (0,0) to[R, v^<=$v_1$] (2,0);
9747 \end{circuitikz}
9748 \end{ctikzExample}
9749
9750 \begin{ctikzExample}
9751 \begin{circuitikz}[straight voltages]
9752 \draw (0,0) to[R, v_>=$v_1$] (2,0);
9753 \end{circuitikz}
9754 \end{ctikzExample}
9755
9756 \begin{ctikzExample}
9757 \begin{circuitikz}[straight voltages]
9758 \draw (0,0) to[R, v_<=$v_1$] (2,0);
9759 \end{circuitikz}
9760 \end{ctikzExample}
9761
9762 Again, voltage generators are treated differently:
9763
9764 \begin{ctikzExample}
9765 \begin{circuitikz}[straight voltages]
9766 \draw (0,0) to[V=10V, i_=$i_1$] (3,0);
9767 \end{circuitikz}
9768 \end{ctikzExample}
9769
9770 \begin{ctikzExample}
9771 \begin{circuitikz}[straight voltages]
9772 \draw (0,0) to[I, v=10V, i_=$i_1$] (3,0);
9773 \end{circuitikz}
9774 \end{ctikzExample}
9775
9776 And you can override that with \texttt{bipole/is voltage} keeping into account that the default direction will be the one of passive components (see~\ref{sec:source-vif}):
9777
9778 \begin{ctikzExample}
9779 \begin{circuitikz}[straight voltages]
9780 \draw (0,0) to[V, bipole/is voltage=false,
9781 v=10V, i_=$i_1$] (3,0);
9782 \end{circuitikz}
9783 \end{ctikzExample}
9784
9785 \subsubsection{American style}
9786 \label{sec:american-style}
9787 Use option \IndexKey{americanvoltage} or set \IndexKey{american voltages} or use the option \IndexKey[voltage, american]{voltage=american}.
9788
9789 \begin{ctikzExample}
9790 \begin{circuitikz}[american voltages]
9791 \draw (0,0) to[R, v^>=$v_1$] (2,0);
9792 \end{circuitikz}
9793 \end{ctikzExample}
9794
9795 \begin{ctikzExample}
9796 \begin{circuitikz}[american voltages]
9797 \draw (0,0) to[R, v^<=$v_1$] (2,0);
9798 \end{circuitikz}
9799 \end{ctikzExample}
9800
9801 \begin{ctikzExample}
9802 \begin{circuitikz}[american voltages]
9803 \draw (0,0) to[R, v_>=$v_1$] (2,0);
9804 \end{circuitikz}
9805 \end{ctikzExample}
9806
9807 \begin{ctikzExample}
9808 \begin{circuitikz}[american voltages]
9809 \draw (0,0) to[R, v_<=$v_1$] (2,0);
9810 \end{circuitikz}
9811 \end{ctikzExample}
9812
9813 \begin{ctikzExample}
9814 \begin{circuitikz}[american]
9815 \draw (0,0) to[I=1A, v_=$u_1$] (2,0);
9816 \end{circuitikz}
9817 \end{ctikzExample}
9818
9819 \begin{ctikzExample}
9820 \begin{circuitikz}[american]
9821 \draw (0,0) to[I<=1A, v_=$i_1$] (2,0);
9822 \end{circuitikz}
9823 \end{ctikzExample}
9824
9825
9826 \subsubsection{Raised American style}
9827 \label{sec:raised-american-style}
9828
9829 Since version \texttt{1.2.1}, ``raised'' American voltages are available; to use them, set the style \IndexKey{raised voltages} or use the option \IndexKey[voltage, raised]{voltage=raised}.
9830 This is a version of the American-style voltage where the signs are raised to the level of the label.
9831 The label is centered between the two signs, and the position of the signs is calculated by supposing that the label itself will be pretty simple; if you have very big labels you will need to adjust the position with \IndexKey{voltage shift} and/or the \IndexKey{voltage/distance from node} properties (see section~\ref{sec:common-vif-pos}).
9832
9833 \begin{ctikzExample}
9834 \begin{circuitikz}[raised voltages]
9835 \draw (0,0) to[R, v^>=$v_1$] (2,0);
9836 \end{circuitikz}
9837 \end{ctikzExample}
9838
9839 \begin{ctikzExample}
9840 \begin{circuitikz}[raised voltages]
9841 \draw (0,0) to[R, v^<=$v_1$] (2,0);
9842 \end{circuitikz}
9843 \end{ctikzExample}
9844
9845 \begin{ctikzExample}
9846 \begin{circuitikz}[raised voltages]
9847 \draw (0,0) to[R, v_>=$v_1$] (2,0);
9848 \end{circuitikz}
9849 \end{ctikzExample}
9850
9851 \begin{ctikzExample}
9852 \begin{circuitikz}[raised voltages]
9853 \draw (0,0) to[R, v_<=$v_1$] (2,0);
9854 \end{circuitikz}
9855 \end{ctikzExample}
9856
9857 \begin{ctikzExample}
9858 \begin{circuitikz}[american]
9859 \ctikzset{voltage=raised}
9860 \draw (0,0) to[I=1A, v_=$u_1$] (2,0);
9861 \end{circuitikz}
9862 \end{ctikzExample}
9863
9864 \begin{ctikzExample}
9865 \begin{circuitikz}[raised voltages]
9866 \draw (0,0) to[I<=1A, v_=$i_1$] (2,0);
9867 \end{circuitikz}
9868 \end{ctikzExample}
9869
9870 \subsubsection{Voltage position}\label{sec:sub-voltage-position}
9871
9872 It is possible to move the arrows and the plus or minus signs away from the component with the key \IndexKey{voltages shift} (default value is \texttt{0}, which gives the standard position):
9873
9874 \begin{ctikzExample}
9875 \begin{circuitikz}[]
9876 \draw (0,0) to[R, v=$v_1$, i=$i_1$] (2,0);
9877 \draw (0,-1) to[R, v=$v_1$, i=$i_1$,
9878 voltage shift=0.5] (2,-1);
9879 \draw (0,-2) to[R, v=$v_1$, i=$i_1$,
9880 voltage shift=1.0] (2,-2);
9881 \end{circuitikz}
9882 \end{ctikzExample}
9883
9884 \begin{ctikzExample}
9885 \begin{circuitikz}[american voltages, voltage shift=0.5]
9886 \draw (0,0) to[R, v=$v_1$, i=$i_1$] (2,0);
9887 \end{circuitikz}
9888 \end{ctikzExample}
9889
9890 Negative values do work as expected:
9891
9892 \begin{ctikzExample}
9893 \begin{circuitikz}[raised voltages]
9894 \draw (0,1.5) to[R, v^=$v_1$, i=$i_1$] ++(2,0);
9895 \draw (0,0) to[R, v^=$v_1$, i_=$i_1$,
9896 voltage shift=-1.0] ++(2,0);
9897 \end{circuitikz}
9898 \end{ctikzExample}
9899
9900 Unfortunately\footnote{see \href{https://github.com/circuitikz/circuitikz/issues/747}{this bug report}.} the amount of shift given by \texttt{voltage shift} is not always the same between sources and passive bipoles, especially if the sizes of the component is very different from the default. Although this qualifies as a bug, and should be fixed in a more comprehensive way, a workaround is available with the key \IndexKey{voltage shift sources adjust} (default: \texttt{\ctikzvalof{voltage shift sources adjust}}). A smaller value is better for smaller components, as you can see in the example below.
9901
9902 \begin{ctikzExample}
9903 \newcommand{\example}[2][]{\draw[#1] (#2)
9904 to [V_=$U$] ++(0, -1) (#2) ++(2,0)
9905 to [R,v=$U_R$] ++(0,-1);
9906 }
9907 \ctikzset{resistors/scale=0.55,inductors/scale=0.55,
9908 capacitors/scale=0.6,sources/scale=.8}
9909 \begin{circuitikz}[circuitikz/voltage=straight,
9910 voltage dir=EF]
9911 \example{0,4}
9912 \ctikzset{voltage shift=2}
9913 \example[color=red]{0,2}
9914 \ctikzset{voltage shift sources adjust=0.2}
9915 \example[color=blue]{0,0}
9916 \end{circuitikz}
9917 \end{ctikzExample}
9918
9919 You can fine-tune the position of the \texttt{+} and \texttt{-} symbols and the label in independent way using \IndexKey{voltage/shift} (default \texttt{0.0} for the former and \IndexKey{voltage/american label distance} (the distance of the label from the lines of the symbols, default \texttt{1.4}) for the latter.
9920
9921 \begin{ctikzExample}
9922 \begin{circuitikz}[american voltages]
9923 \draw (0,1) to[R, v=$v_1$, i=$i_1$] ++(2,0);
9924 % normally 1.4, make it tighter
9925 \ctikzset{voltage/american label distance=0.5}
9926 \draw (0,0) to[R, v=$v_1$, i=$i_1$] ++(2,0);
9927 \end{circuitikz}
9928 \end{ctikzExample}
9929
9930 Notes that \texttt{american voltage} also affects batteries.
9931
9932 \begin{ctikzExample}
9933 \begin{circuitikz}[voltage shift=0.5]
9934 \draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
9935 \end{circuitikz}
9936 \end{ctikzExample}
9937
9938 \begin{ctikzExample}
9939 \begin{circuitikz}[american voltages, voltage shift=0.5]
9940 \draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
9941 \end{circuitikz}
9942 \end{ctikzExample}
9943
9944 Additionally, the \IndexKey{open} component is treated differently; the voltage is placed in the middle of the open space\footnote{Since \texttt{v1.1.2}, thank to an \href{https://github.com/circuitikz/circuitikz/issues/374}{issue opened by user \texttt{rhandley} on GitHub}.}:
9945
9946 \begin{ctikzExample}
9947 \begin{circuitikz}[american voltages]
9948 \draw (0,1.5) -- ++(0.5,0)
9949 to[open, v=$v_o$, o-o] ++(2,0) -- ++(0.5,0);
9950 \draw (0,0) -- ++(0.5,0)
9951 to[open, v=$v_o$, voltage=straight, *-*] ++(2,0)
9952 -- ++(0.5,0);
9953 \end{circuitikz}
9954 \end{ctikzExample}
9955
9956 If you want or need to maintain the old behavior for \texttt{open} voltage, you can set the key \IndexKey{open voltage position} to \texttt{legacy} (the default is the new behavior, which corresponds to the value \texttt{center}).
9957
9958 \subsubsection{American voltages customization}\label{sec:american-voltage-custom}
9959
9960 Since 0.9.0, you can change the font\footnote{There was a bug before, noticed by the user \texttt{dzereb} on \href{https://tex.stackexchange.com/questions/487683/odd-minus-style-when-drawing-american-voltage}{tex.stackexchange.com} which made the symbols using different fonts in a basically random way. In the same page, user \texttt{campa} found the problem. Thanks!} used by the \texttt{american voltages} style, by setting to something different from nothing the key \IndexKey{voltage/american font} (default: nothing, using the current font) style:
9961
9962 \begin{ctikzExample}
9963 \begin{circuitikz}[american]
9964 \begin{scope}
9965 \ctikzset{voltage/american font=\tiny\boldmath}
9966 \draw (0,0) to[R,v=$V_S$] ++(2,0);
9967 \end{scope}
9968 \draw (0,-2) to[R,v=$V_S$] ++(2,0);
9969 \end{circuitikz}
9970 \end{ctikzExample}
9971
9972 Also, if you want to change the symbols (sometimes just the $+$ sign is drawn, for example, or for highlighting something),
9973 using the keys \IndexKey{voltage/american plus} and \IndexKey{voltage/american minus} (default \verb|$+$| and \verb|$\vphantom{+}-$|).
9974
9975 Notice that the definition of the minus sign is not simply \verb|$-$| because in most font (but not Computer Modern!) the size of the bounding box for the mathematical plus or minus are different. The \verb|\vphantom| forces the vertical size of the minus sign to be the same as the plus sign.\footnote{Changed in v1.6.3, you can look at \href{https://github.com/circuitikz/circuitikz/issues/721}{this issue on GitHub} for more details.}
9976
9977 \begin{ctikzExample}
9978 \begin{circuitikz}[american]
9979 \ctikzset{voltage/american font=\scriptsize\boldmath}
9980 \ctikzset{voltage/american plus=\textcolor{red}{$\oplus$}}
9981 \ctikzset{voltage/american minus=\textcolor{blue}{$\ominus$}}
9982 \draw (0,0) to[R,v_>=$V_S$] ++(2,0);
9983 \draw (0,-2) to[R,v_<=$V_S$] ++(2,0);
9984 \end{circuitikz}
9985 \end{ctikzExample}
9986
9987 This could be especially useful if you define a style, to use like this:
9988
9989 \begin{ctikzExample}
9990 \tikzset{red plus/.style={
9991 circuitikz/voltage/american plus=\textcolor{red}{$+$},
9992 }}
9993 \begin{circuitikz}[american]
9994 \draw (0,0) to[R,v_>=$V_S$, red plus] ++(2,0);
9995 \draw (0,-2) to[R,v_<=$V_S$] ++(2,0);
9996 \end{circuitikz}
9997 \end{ctikzExample}
9998
9999 \subsubsection{Combining different styles}\label{sec:mixing-voltage-styles}
10000
10001 Due to an historical hiccup, you need to be careful if you want to mix styles, like for example having \texttt{american} styled components and straight voltages (which are basically \texttt{european} style, at least in \Circuitikz{}). The problem is that the order of style parameters can change the output\footnote{%
10002 thanks to Stack Exchange user \href{https://tex.stackexchange.com/q/665466/38080}{Mads P Olesen} for noticing.} as you can see in the following example, where in the red case the voltage generator shape reverted to the \texttt{european} one.
10003
10004 \begin{ctikzExample}
10005 \begin{circuitikz}[straight voltages, american]
10006 \draw (0,0) to [V, v=$V_P$] ++(0,3);
10007 \draw (1,0) to [R, v=$V_P$] ++(0,3);
10008 \end{circuitikz}\color{red}%
10009 \begin{circuitikz}[american, straight voltages]
10010 \draw (0,0) to [V, v=$V_P$] ++(0,3);
10011 \draw (1,0) to [R, v=$V_P$] ++(0,3);
10012 \end{circuitikz}
10013 \end{ctikzExample}
10014
10015 This is arguably a bug, but fixing it (separating the voltage generator shapes from the voltage style) would break havoc with older circuits, so this will not be fixed for now.
10016
10017
10018
10019 \subsection{Changing the style of labels, voltages, and other text ornaments}\label{sec:ornament-style}
10020
10021 Since version \texttt{0.9.5}, it is possible to change the style of bipole text ornaments (labels, annotations, voltages etc) by using the appropriate styles or keys.
10022 The basic style applied to the text is defined in the \texttt{/tikz/circuitikz} key directory and applied to every node that contains the text; you can also change them locally by using the \texttt{tikz} direct keys in local scopes.
10023
10024 For example, you can make all annotations small by using:
10025
10026 \begin{lstlisting}[numbers=none]
10027 \ctikzset{bipole annotation style/.style={font=\small}}
10028 \end{lstlisting}
10029
10030 And/or change (override) the setting in one specific bipole using:
10031
10032 \begin{lstlisting}[numbers=none]
10033 ...to[bipole annotation style={color=red}, R, a={Red note}]...
10034 \end{lstlisting}
10035
10036 where the annotation will be in normal font (it has been reset!) and red, or append to the style:
10037
10038 \begin{lstlisting}[numbers=none]
10039 ...to[bipole annotation append style={color=red}, R, a={Red small note}]...
10040 \end{lstlisting}
10041
10042 \textbf{Caveat:} you have to put the style changing key at the start of the \texttt{to} arguments to have any effect\footnote{No, I do not know why. Hints and fixes are welcome.}.
10043
10044 The available styles and commands are \IndexKey{bipole label style}, \IndexKey{bipole annotation style}, \IndexKey{bipole voltage style}, \IndexKey{bipole current style}, and \IndexKey{bipole flow style}. The following example shows a bit of everything.
10045
10046
10047 \begin{ctikzExample}[pos=t ]
10048 \begin{circuitikz}[american]
10049 \ctikzset{bipole annotation style/.style={font=\tiny}}
10050 \ctikzset{bipole current style/.style={font=\small\sffamily}}
10051 \draw (0,0) to [bipole annotation append style={fill=yellow}, R=L1, a=A1] ++(3,0)
10052 to [bipole label style={fill=cyan}, R, l2_=L2 and 2L, a^=A2] ++(3,0);
10053 \draw (7,0) to [bipole voltage style={color=blue},
10054 bipole flow style={fill=green, outer sep=5pt},
10055 R=R1, v=V1, i=I1, f>^=F1] ++(3,0)
10056 to [bipole current append style={color=red}, R, v<=V2, i^=I2, f>^=F2] ++(3,0);
10057 \end{circuitikz}
10058 \end{ctikzExample}
10059
10060 \subsection{Accessing labels text nodes}
10061 \label{sec:accessing-labels-text}
10062
10063 Since 0.9.5, you can access all the labels nodes\footnote{The access to \texttt{label}s and \texttt{annotation}s was present before, but not documented.} using special node names. So, if you use \texttt{name} to give a name to the bipole node, you can also access the following nodes: \texttt{namelabel} (notice: no space nor any other symbol between \texttt{name} and \texttt{label}!), \texttt{nameannotation}, \texttt{namevoltage}, \texttt{namecurrent} and \texttt{nameflow}. Notice that the node names are available only if the bipole has an anchor or an annotation, of course.
10064
10065 \begin{ctikzExample}[varwidth=true, pos=t]
10066 \newcommand{\marknode}[2][45]{%
10067 \node[circle, draw, red, inner sep=1pt,
10068 pin={[red, font=\tiny]#1:#2}] at (#2.center) {};
10069 }
10070 \begin{circuitikz}[ american]
10071 \draw (0,0) to [R=L1, a=A1, name=L1] ++(3,0)
10072 to [R, l2_=L2 and 2L, a^=A2, name=L2] ++(3,0);
10073 \marknode{L1} \marknode{L1label} \marknode[0]{L1annotation}
10074 \marknode{L2} \marknode[0]{L2label} \marknode{L2annotation}
10075 \draw[blue] (L2label.south west) rectangle (L2label.north east);
10076 \draw (6.1,0) to [R=R1, v=V1, i=I1, f>^=F1, name=R1] ++(3,0)
10077 to [R, v<=V2, i^=I2, f>^=F2, name=R2] ++(3,0);
10078 \marknode[0]{R1voltage} \marknode[0]{R2voltage} \marknode[90]{R1current}
10079 \marknode[90]{R2current} \marknode{R1flow} \marknode{R2flow}
10080 \end{circuitikz}
10081 \end{ctikzExample}
10082
10083
10084 If you want to have more access to the label positioning algorithm, since \texttt{1.2.5} you can access the label rotation using the command \ \IndexKey[ctikzgetdirection]{}\texttt{\textbackslash ctikzgetdirection\{\emph{nodename}\}} (where node name is for example \texttt{L1label} or \texttt{L2annotation}), and the anchor used for positioning the node as \texttt{\textbackslash ctikzgetanchor\{\emph{component label}\}\{\emph{type}\}}, where \emph{component label} is, for example, \texttt{L1} and type is either \texttt{label} or \texttt{annotation} (notice that the syntax is slightly different, for implementation reasons).
10085 Those values are available only if the dipole declares a \texttt{l} or \texttt{a} keys; if you want them without any label you need to declare a blank one (like for example \texttt{l=\textasciitilde}).
10086 The following example gives an idea of the values of those macros for the three types of label positioning strategies.
10087
10088 \begin{ctikzExample}[varwidth=true, pos=t]
10089 \newcommand{\marklabann}[3][45]{% [angle] {node label} {type: label or annotation}
10090 \node[circle, draw, blue, inner sep=1pt,
10091 pin={[draw, blue, font=\tiny, align=left]#1:{#2 \\ dir: \ctikzgetdirection{#2#3} \\
10092 anchor: \ctikzgetanchor{#2}{#3}}}] at (#2#3.\ctikzgetanchor{#2}{#3}) {};}
10093 \begin{tikzpicture}[scale=0.95, transform shape]
10094 \foreach \style/\xdelta in {straight/0, smart/5, rotate/10} {
10095 \begin{scope}[xshift=\xdelta cm]
10096 \ctikzset{label/align = \style}
10097 \draw (0,0) node[above right, rotate=45]{\style}
10098 to[L, o-, l=$L_{ab}$, v, name=L1, a=a] ++(3,3)
10099 to[ceV, -*, v, name=V1, l2_=L1 and L2, a^=A] ++(0,-3);
10100 \marklabann[135]{L1}{label}
10101 \marklabann[-90]{L1}{annotation}
10102 \marklabann[90]{V1}{label}
10103 \marklabann[-90]{V1}{annotation}
10104 \end{scope}}
10105 \end{tikzpicture}
10106 \end{ctikzExample}
10107
10108 \subsection{Advanced voltages, currents and flows}\label{sec:vif-anchors}
10109
10110 Since version \texttt{1.2.1}\footnote{some options have been added in \texttt{v1.4.1}}, it is possible to access the anchors of the ``ornaments'' --- voltage, current and flows, together with some additional information that makes it possible to personalize them.
10111 Normally, voltages and flow and currents are drawn into the path of the bipoles, so that it is not possible, for example, to change the line type or color of the arrows, or the type of arrows\footnote{in regular voltages, the arrows are not real \TikZ{} arrows, but the auxiliary arrow shapes of \Circuitikz{}}. Access to the anchors allows you to do all these things, and more.
10112
10113 For example, you can do something like this:
10114
10115 \begin{ctikzExample}
10116 \begin{circuitikz}[]
10117 \draw (0,1) to[R, v=$v$] ++(3,0);
10118 \draw (0,0) to[R, v, name=R, voltage/bump b=3] ++(3,0);
10119 \draw [thin, red, -{Stealth[width=8pt]}, ]
10120 (R-Vfrom) .. controls (R-Vcont1) and (R-Vcont2).. (R-Vto)
10121 node [black, pos=0.5, fill=white]{v};
10122 \end{circuitikz}
10123 \end{ctikzExample}
10124
10125 Or, for example, to have a different voltage style; normally you would define a macro (see~\ref{sec:american-voltage-custom} to understand the \verb|\vphantom|).
10126
10127 \begin{ctikzExample}
10128 \begin{circuitikz}[voltage shift=0.5]
10129 \def\eurVPM#1#2{% node, label
10130 \draw [thin, -{Stealth[width=8pt]}, shorten >=5pt,
10131 shorten <=5pt] (#1-Vfrom) node[font=\tiny]{$\vphantom{+}-$}
10132 .. controls (#1-Vcont1) and (#1-Vcont2)..
10133 (#1-Vto) node[font=\tiny]{$+$}
10134 node[pos=0.5,anchor=\ctikzgetanchor{#1}{Vlab}]{#2};}
10135 \draw (0,0) to[R=R1, name=R1, v, i=$i$] ++(3,0)
10136 to[R, l_=R2, v^, name=R2] ++(0,-3);
10137 \eurVPM{R1}{$v_1$} \eurVPM{R2}{$v_2$}
10138 \end{circuitikz}
10139 \end{ctikzExample}
10140
10141 \subsubsection{Using standard label with custom symbols}\label{sec:no-symbols}
10142
10143 Since \texttt{v1.4.1} you can also keep the voltage, current and flow labels and suppress the output of the symbols (arrows or plus/minus depending on the style) with the keys \IndexKey{no v symbols}, \IndexKey{no i symbols}, \IndexKey{no f symbols} (there are also the corresponding \IndexKey{v symbols}, \IndexKey{i symbols} and \IndexKey{f symbols} in case you want to switch the behavior off/on globally). This for example simplify an often requested feature, like having all the current in one color and the voltages in another one, which is not possible natively because the arrows are part of the same path. One possible implementation of that is the following one:
10144
10145 \begin{ctikzExample}
10146 \newcommand{\iarronly}[1]{% name
10147 \node [currarrow, color=red, anchor=center,
10148 rotate=\ctikzgetdirection{#1-Iarrow}] at (#1-Ipos) {};
10149 }
10150 \newcommand{\varronly}[1]{% name
10151 \draw [color=blue] (#1-Vfrom) .. controls (#1-Vcont1)
10152 and (#1-Vcont2).. (#1-Vto) node [currarrow,
10153 sloped, anchor=tip, allow upside down,pos=1]{};
10154 }
10155 \begin{circuitikz}[]
10156 \ctikzset{!vi/.style={no v symbols, no i symbols}}
10157 \ctikzset{bipole voltage style/.style={color=blue},
10158 bipole current style/.style={color=red}}
10159 \draw (120:6) to[R, *-, name=R, v^=$v_R$, !vi]
10160 (120:3) to[short, i=$i_R$, name=SR, !vi] (0,0);
10161 \draw (180:4) to[L, o-, l=$L$, name=L2, v=$v_L$, !vi]
10162 (180:2) to[V, -*, name=V2, v_=$v_2$, !vi] (0:0);
10163 \iarronly{SR}\varronly{R}\varronly{L2}\varronly{V2}
10164 \end{circuitikz}
10165 \end{ctikzExample}
10166
10167 \subsubsection{Activating the anchors}
10168 \label{sec:activating-the-anchors}
10169
10170 You will have access to the anchors for voltages, currents and flows when, in the bipole, you have a \texttt{v}, \texttt{i}, \texttt{f} specification (one or more of them). If you have a \texttt{name} key, to give the bipole a name, they will be easily accessible. Without a \texttt{name} key, a temporary name is generated, to be used by the ``automatic v-i-f'' mechanism (see~\ref{sec:automatic-vif}). Otherwise, the anchors and the associated functions are not defined.
10171 To suppress the normal output of the \texttt{v}, \texttt{i}, \texttt{f} keys, you can use such keys without any argument, like in the previous example; notice that the \verb|_| and \verb|^| modifiers work as expected.
10172
10173 The following line of resistors has been drawn with the following commands; it is used to show the name of the available anchors.
10174
10175 \begin{lstlisting}
10176 \draw (0,0) to[R=R1, v=$v$, name=R1] ++(4,0)
10177 to[R, l_=R2, i=$i$, name=R2] ++(4,0)
10178 to[R=R3, f=$f$, name=R3] ++(4,0);
10179 \end{lstlisting}
10180
10181 \begin{circuitikz}[]
10182 \draw (0,0) to[R=R1, v=$v$, name=R1] ++(4,0) to[R, l_=R2, i=$i$, name=R2] ++(4,0) to[R=R3, f=$f$, name=R3] ++(4,0);
10183 \path
10184 (R1-Vto) \showcoord(R1-Vto)<-135:0.2>
10185 (R1-Vfrom) \showcoord(R1-Vfrom)<-45:0.2>
10186 (R1-Vcont1) \showcoord(R1-Vcont1)<-45:0.2>
10187 (R1-Vcont2) \showcoord(R1-Vcont2)<-135:0.2>
10188 (R1-Vlab) \showcoord(R1-Vlab)<-90:0.5>
10189 (R2-Ito) \showcoord(R2-Ito)<45:0.3>
10190 (R2-Ifrom) \showcoord(R2-Ifrom)<135:0.3>
10191 (R2-Ipos) \showcoord(R2-Ipos)<-90:0.3>
10192 (R3-Fto) \showcoord(R3-Fto)<45:0.3>
10193 (R3-Ffrom) \showcoord(R3-Ffrom)<135:0.3>
10194 (R3-Fpos) \showcoord(R3-Fpos)<-90:0.4>
10195 ;
10196 \end{circuitikz}
10197
10198 The meaning of the anchors is the following:
10199 \begin{itemize}
10200 \item
10201 \IndexKey{Vfrom} and \IndexKey{Vto} are the main points where the voltage information is given: start and end point of the arrow, or position of the $+$ or $-$ sign. This is the same for the \IndexKey{Ffrom} or \IndexKey{Fto} anchors for flows; for inline currents, the corresponding \IndexKey{Ifrom} and \IndexKey{Ito} mark the wire segment where the arrowhead is positioned (at the specified \IndexKey{current/distance} fraction. The direction of the arrow is available using the auxiliary macro \verb|\ctikzgetdirection| (see below).
10202 \item
10203 \IndexKey{Vcont1} and \IndexKey{Vcont2} are the control points for the curved arrow (see the examples above); in the case of straight arrows or american-style voltages, they are set at the midpoint between \texttt{Vfrom} and \texttt{Vto}.
10204 \item
10205 \IndexKey{Vlab} is where the text label for the voltage is normally positioned. The anchor used for such label is available using the auxiliary macro \verb|\ctikzgetanchor| (see below). Consider the default \verb|inner sep=2pt| of voltage label nodes.
10206 \item
10207 \IndexKey{Ipos} and \IndexKey{Fpos} are the position for the arrowhead or the small flow arrow (which is a \texttt{currarrow} or \texttt{flowarrow} node normally) is positioned, respectively. The label is then added to the correct side of it using the anchor available via \verb|\ctikzgetanchor| (see below,~\ref{sec:advances-aux-info}). In this case, the exact position of the label is not available if you do not position the element, for this there is no \texttt{Flab} or \texttt{Ilab} coordinate; you have to use the \texttt{Fpos} and \texttt{Ipos} coordinate with the corresponding \IndexKey{Ilab} and \IndexKey{Flab} anchors.
10208 \end{itemize}
10209
10210 Changing the options of the elements will change the anchors accordingly:
10211
10212 \begin{lstlisting}
10213 \ctikzset{current/distance=0.2}
10214 \draw (0,0) to[R=R1, v>=$v$, name=R1] ++(4,0)
10215 to[R, l_=R2, i<_=$i$, name=R2] ++(4,0)
10216 to[R, l_=R3, f<_=$f$, name=R3] ++(4,0);
10217 \end{lstlisting}
10218
10219 \begin{circuitikz}[]
10220 \ctikzset{current/distance=0.2}
10221 \draw (0,0) to[R=R1, v>=$v$, name=R1] ++(4,0) to[R, l_=R2, i<_=$i$, name=R2] ++(4,0) to[R, l_=R3, f<_=$f$, name=R3] ++(4,0);
10222 \path
10223 (R1-Vto) \showcoord(R1-Vto)<-45:0.2>
10224 (R1-Vfrom) \showcoord(R1-Vfrom)<-135:0.2>
10225 (R1-Vcont1) \showcoord(R1-Vcont1)<-135:0.2>
10226 (R1-Vcont2) \showcoord(R1-Vcont2)<-45:0.2>
10227 (R1-Vlab) \showcoord(R1-Vlab)<-90:0.5>
10228 (R2-Ito) \showcoord(R2-Ito)<135:0.3>
10229 (R2-Ifrom) \showcoord(R2-Ifrom)<45:0.3>
10230 (R2-Ipos) \showcoord(R2-Ipos)<90:0.3>
10231 (R3-Fto) \showcoord(R3-Fto)<90:0.4>
10232 (R3-Ffrom) \showcoord(R3-Ffrom)<80:0.4>
10233 (R3-Fpos) \showcoord(R3-Fpos)<-90:0.4>
10234 ;
10235 \end{circuitikz}
10236
10237 Obviously, the anchors follow the voltage style you choose:
10238
10239 \begin{lstlisting}
10240 \draw (0,0) to[R=R1, v=$v$, name=R1, voltage=straight] ++(4,0)
10241 to[R=R2, v=$v$, name=R2, voltage=american] ++(4,0)
10242 to[R=R3, v=$v$, name=R3, voltage=raised] ++(4,0);
10243 \end{lstlisting}
10244
10245 \begin{circuitikz}[]
10246 \ctikzset{current/distance=0.2}
10247 \draw (0,0) to[R=R1, v=$v$, name=R1, voltage=straight] ++(4,0)
10248 to[R=R2, v=$v$, name=R2, voltage=american] ++(4,0)
10249 to[R=R3, v=$v$, name=R3, voltage=raised] ++(4,0);
10250 \foreach \i in {1, 2, 3} {
10251 \path
10252 (R\i-Vto) \showcoord(R\i-Vto)<-90:0.4>
10253 (R\i-Vfrom) \showcoord(R\i-Vfrom)<-90:0.4>
10254 (R\i-Vcont1) \showcoord(R\i-Vcont1)<135:0.6>
10255 (R\i-Vcont2) \showcoord(R\i-Vcont2)<45:0.6>
10256 (R\i-Vlab) \showcoord(R\i-Vlab)<-90:0.6>
10257 ;
10258 }
10259 \end{circuitikz}
10260
10261 Notice the position of the control points, as well as the fact that the anchor available with \verb|\ctikzgetanchor| is applied to \texttt{Vfrom} and \texttt{Vto} symbols, too.
10262
10263 Finally, as ever, generators are treated differently, but you have all your anchors too.
10264
10265 \begin{lstlisting}
10266 \ctikzset{american}
10267 \draw (0,0) to[V=$v$, name=G1, voltage=european] ++(4,0)
10268 to[V=$v$, v=$v$, name=G2, voltage=american] ++(4,0)
10269 to[battery2, v=$v$, name=G3, voltage=raised] ++(4,0);
10270 \end{lstlisting}
10271
10272 \begin{circuitikz}[]
10273 \ctikzset{american}
10274 \draw (0,0) to[V=$v$, name=G1, voltage=european] ++(4,0)
10275 to[V=$v$, v=$v$, name=G2, voltage=american] ++(4,0)
10276 to[battery2, v=$v$, name=G3, voltage=raised] ++(4,0);
10277 \foreach \i in {1, 2, 3} {
10278 \path
10279 (G\i-Vto) \showcoord(G\i-Vto)<-60:0.1>
10280 (G\i-Vfrom) \showcoord(G\i-Vfrom)<-120:0.1>
10281 (G\i-Vlab) \showcoord(G\i-Vlab)<90:0.3>
10282 ;
10283 }
10284 \end{circuitikz}
10285
10286 \subsubsection{Auxiliary information}\label{sec:advances-aux-info}
10287
10288 When the anchors are activated, there are additional macros that you can use:
10289 \begin{itemize}
10290 \item \IndexKey[ctikzgetanchor]{}\texttt{\textbackslash ctikzgetanchor\{\emph{<name>}\}\{\emph{<anchor>}\}}: \emph{name} is the name of the bipole, and \emph{anchor} can be \IndexKey{Vlab}, \IndexKey{Flab} or \IndexKey{Ilab}. This macro expands to the normal anchor position (something like \texttt{north}, \texttt{south west}). Notice that if you have not activated the corresponding anchor, the content of this macro is not specified. It could be equivalent to \verb|\relax| (basically, empty) or contains the anchor of a bipole with the same name from another drawing --- it's a global macro like the coordinates.
10291 \item \IndexKey[ctikzgetdirection]{}\texttt{\textbackslash ctikzgetdirection\{\emph{<name>}\}}: a number which is the direction of the \emph{name}d bipole.
10292 \item \texttt{\textbackslash ctikzgetdirection\{\emph{<name>}-Iarrow\}}: a number which is the direction of the current arrow requested for the \emph{name}d bipole; using \texttt{\emph{<name>}-Farrow} you get the same information for flow arrows.
10293 \end{itemize}
10294
10295 For example, you could like the voltage label oriented with the bipole:
10296
10297 \begin{ctikzExample}
10298 \begin{circuitikz}[]
10299 \def\myvv#1#2{%
10300 \draw [thin, blue, ->,]
10301 (#1-Vfrom) .. controls (#1-Vcont1) and (#1-Vcont2).. (#1-Vto)
10302 node [pos=0.5, below,
10303 rotate=\ctikzgetdirection{#1}] at (#1-Vlab) {#2}; }
10304 \draw (0,0) to[R, v, name=A] ++(3,0);
10305 \draw (0,0) to[R, v, name=B] ++(3,3);
10306 \myvv{A}{$v_A$}\myvv{B}{$v_B$}
10307 \end{circuitikz}
10308 \end{ctikzExample}
10309
10310 Or you could use the anchor to substitute the flow with a fancy one and still position the label automatically; suppose you have the following definition in your preamble (see \TikZ{} manual, \href{https://tikz.dev/tikz-decorations}{``Path decorations''}):
10311
10312 \begin{ctikzExample}[exec outside]
10313 % requires \usetikzlibrary{decorations, decorations.pathmorphing}
10314 \tikzset{%
10315 lray/.style={decorate, decoration={
10316 snake, amplitude=2pt,pre length=1pt,post length=2pt, segment length=5pt,},
10317 -Triangle,
10318 }}
10319 \end{ctikzExample}
10320
10321 You can then define a kind of ``power flow'' style:
10322
10323 \begin{ctikzExample}
10324 \begin{circuitikz}[]
10325 \newcommand\myff[3][blue]{% [opt: color] node label
10326 \draw [lray, #1, ] (#2-Ffrom) -- (#2-Fto)
10327 node [anchor=\ctikzgetanchor{#2}{Flab}, inner sep=4pt]
10328 at (#2-Fpos) {#3};}
10329 \draw (0,1) to[R, f, name=A] ++(3,0);
10330 \draw (0,0) to[R, f_<, name=B] ++(3,0);
10331 \myff{A}{$P_A$}\myff[red]{B}{$P_B$}
10332 \end{circuitikz}
10333 \end{ctikzExample}
10334
10335
10336
10337 \subsubsection{Fixed voltage arrows: an example of advanced voltage usage}
10338 \label{sec:fixed-voltage-arrows}
10339
10340 \begingroup % to contain example definitions
10341 An interesting application of the advanced voltage is to have fixed length straight voltage arrows.\footnote{This was suggested by users \texttt{Franklin} and \texttt{Zarko} in \href{https://tex.stackexchange.com/questions/574576/circuitikz-straight-voltage-arrows-with-fixed-length}{a question on \texttt{tex.stackexchange.com}}}
10342 The normal voltage arrows length depends not on the component length but on the node distance (this is the behavior since when the voltages were first introduced, so it can't be changed).
10343
10344 \begin{ctikzExample}[varwidth=true, basicstyle=\scriptsize\ttfamily, pos=t]
10345 \begin{circuitikz}[european,]
10346 \ctikzset{voltage=straight}
10347 \draw (0,0) to[R,v=$v_1$,*-*] ++(2,0) to[R, v<=$v_2$] ++(4,0) to[C, *-*, v=$v_3$] ++(1,0);
10348 \end{circuitikz}
10349 \end{ctikzExample}
10350
10351 Using the advanced voltage interface mechanism, you can for example design voltages that are of fixed lengths; in the example below the new \texttt{xparse} method for defining commands is used, so that we can have a couple of different optional arguments:
10352
10353
10354 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily, exec outside, dollar]
10355 \NewDocumentCommand{\fixedvlen}{O{0.5cm} m m O{}}{% [semilength]{node}{label}[extra options]
10356 % get the center of the standard arrow
10357 \coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
10358 % draw an arrow of a fixed size around that center and on the same line
10359 \draw[-Triangle, #4] ($(#2-Vcenter)!#1!(#2-Vfrom)$) -- ($(#2-Vcenter)!#1!(#2-Vto)$);
10360 % position the label as in the normal voltages (inner sep of voltage labels is 2pt per default)
10361 \node[anchor=\ctikzgetanchor{#2}{Vlab}, inner sep=2pt, #4] at (#2-Vlab) {#3};
10362 }
10363 \end{ctikzExample}
10364
10365 \begin{ctikzExample}[varwidth=true, basicstyle=\scriptsize\ttfamily, pos=t]
10366 \begin{circuitikz}[european,]
10367 \ctikzset{voltage=straight}
10368 \draw (0,2) to[R,v=$v_1$,*-*] ++(2,0) to[R, v<=$v_2$] ++(4,0) to[C, *-*, v=$v_3$] ++(1,0);
10369 \draw (0,0) to[R,v=,name=v1,*-*] ++(2,0) to[R, v<=, name=v2] ++(4,0) to[C, *-*, v, name=v3] ++(1,0);
10370 \fixedvlen{v1}{$V_1$}
10371 \fixedvlen{v2}{$V_2$}
10372 \fixedvlen{v3}{$V_3$}[red]
10373 \end{circuitikz}
10374 \end{ctikzExample}
10375
10376 Notice that with a coherent naming you can use a \verb|\foreach| loop for the last three lines.
10377
10378 You can also notice that the arrow is not exactly the same as other arrows in the circuit; if you want them to be exactly the same, you can use a trick to get the default \Circuitikz{} arrow size --- please look at \href{https://tex.stackexchange.com/questions/549347/circuitikz-arrowhead/549354#549354}{this answer by Romano on \texttt{tex.stackexchange.com}}.
10379
10380 Another possibility is to have the arrow length based on the length of the component; for example you can use this code:
10381
10382 \begin{ctikzExample}[basicstyle=\scriptsize\ttfamily, exec outside, dollar]
10383 \NewDocumentCommand{\compvlen}{O{1.5} m m O{}}{% [relative length]{node}{label}[extra options]
10384 % get the center of the standard arrow
10385 \coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
10386 % draw an arrow of a size proportional to the component length
10387 % around that center and on the same line
10388 % the component length is calculated using the let...in with the left and right anchors
10389 % and multiplied by the relative length
10390 \draw[-Triangle, #4] let \p1=(#2.left), \p2=(#2.right), \n1={0.5*#1*veclen(\x2-\x1,\y2-\y1)}
10391 in ($(#2-Vcenter)!\n1!(#2-Vfrom)$) -- ($(#2-Vcenter)!\n1!(#2-Vto)$);
10392 % position the label as in the normal voltages
10393 \node[anchor=\ctikzgetanchor{#2}{Vlab}, #4] at (#2-Vlab) {#3};
10394 }
10395 \end{ctikzExample}
10396
10397 \begin{ctikzExample}[varwidth=true, basicstyle=\scriptsize\ttfamily, pos=t]
10398 \begin{circuitikz}[european,]
10399 \ctikzset{voltage=straight}
10400 \draw (0,2) to[R,v=$v_1$,*-*] ++(2,0) to[R, v<=$v_2$] ++(4,0) to[C, *-*, v=$v_3$] ++(1,0);
10401 \draw (0,0) to[R,v=,name=v1,*-*] ++(2,0) to[R, v<=, name=v2] ++(4,0) to[C, *-*, v, name=v3] ++(1,0);
10402 \compvlen{v1}{$V_1$}
10403 \compvlen{v2}{$V_2$}
10404 \compvlen{v3}{$V_3$}[red]
10405 \end{circuitikz}
10406 \end{ctikzExample}
10407
10408 \endgroup
10409
10410 \subsubsection{Automatic advanced voltages, current and flows (experimental)}\label{sec:automatic-vif}
10411
10412 \begingroup % let's contain definitions here
10413
10414 Since \texttt{v1.8.5}, a new mechanism has been added\footnote{As with all the advanced v–i–f features, this was added by Romano; see the discussion \href{https://github.com/circuitikz/circuitikz/discussions/911}{on
10415 GitHub}.} to simplify the use of advanced voltages, currents, and flows in circuits. The idea is to avoid the manual invocation of the macros that draw the appropriate symbols and/or labels at the end of a path or picture.
10416
10417 \emph{\textbf{Please notice} that this feature is \textbf{experimental} --- at least for a couple of releases. The behavior, macro names, and restrictions can change in the next versions.}
10418
10419 The core addition consists of a new \verb!\ctikzset! key, \IndexKey{vif queue add}, which takes four arguments: a macro \emph{name} and three further arguments\footnote{The idea is that this way you can pass to the custom macro a label, options for the labels, and options for the drawing of the symbols; however they can be whatever the user decides.}, which can contain arbitrary content. For example, if you use the following key in a \texttt{to} bipole:
10420 \begin{lstlisting}[numbers=none]
10421 to[R, ..., vif queue add={mymacro}{$\alfa$}{red}{foo}]
10422 \end{lstlisting}
10423 the effect of the key is to add a macro call of the form:
10424 \begin{lstlisting}[numbers=none]
10425 \mymacro{nodename}{$\alfa$}{red}{foo}
10426 \end{lstlisting}
10427 to an internal list of “macros to be executed”. The \emph{nodename} is added automatically; if no explicit \texttt{name} key is given, a temporary name is generated.
10428
10429 It is important that the \texttt{vif queue add} key appears last, or at least after any \texttt{v}, \texttt{i}, \texttt{f}, or \texttt{name} key in the \texttt{to[\dots]} options. Moreover, its correct operation is guaranteed only when the \texttt{to} command places a \Circuitikz{} bipole (in other words, it should not be expected to work with a basic \TikZ{} \texttt{to}, such as \texttt{to[bend left, \dots]}), \textbf{and} when the voltages, current and/or flow anchors are activated (that is, a \texttt{v}, \texttt{i} or \texttt{f} key is present).
10430
10431 In the case you want to delegate to your custom macro only the drawing of the symbols, but let the standard mechanism place the label, you can still use the \texttt{no v symbols} and similar (see~\ref{sec:no-symbols}). In that case you need to use an explicit \texttt{v={label}} to set the value label; notice that this also sets the default ``direction'' of the symbols (that you can override with \texttt{v>=\dots}, \verb!v^=!\texttt{\dots} or similar, of course). If you need to modify the label value without affecting a previously issued \texttt{v\dots=\dots} command, you can use the key \IndexKey{v label} (and the corresponding \IndexKey{i label}, \IndexKey{f label}) that changes \emph{only} the value of the label, without any other action (not even activating the anchors, that is).
10432
10433 The stored macro will be replayed automatically at the end of the environment, in the same order in which they were added to the queue, at least if you are using a recent enough version of \LaTeX; if you are using an older version or a different format (like for example \ConTeXt) you need to add the key \IndexKey{use auto vif} in the options of the \texttt{tikzpicture} environment. If you forget it, a warning will be issued.
10434
10435 You also can ``execute'' the stored commands with the \IndexKey[ctikzprocessvif]{}\verb!\ctikzprocessvif! macro if you need to draw them before the end of the environment. This can be important if you define some name in your macros and you need to use them in another part of the circuit; by default all the stored macros are executed at the end of the environment. The call to \verb!\ctikzprocessvif! ``clear'' the queue, so consecutive calls have no effect.
10436
10437 Naturally, you must define the macro(s) that will be called, such as the \verb!\mymacro! shown above. The macro \textbf{must} have three arguments, like this:
10438 \begin{lstlisting}[numbers=none]
10439 \newcommand{\mymacro}[4]{% try not to add spurious spaces
10440 % #1 -> node name
10441 % #2 -> first user argument
10442 % #3 -> second user argument
10443 ... code here ...
10444 }
10445 \end{lstlisting}
10446
10447 There is little sense in using the \texttt{vif queue add} key explicitly; it is better hidden behind more specific user-level keys, as shown in the following examples. This also helps remove some arguments when they are not needed.
10448
10449 For example, let's suppose you like the \texttt{raised} voltage notation, but you want the plus and minus signs at a fixed distance from the label, independently on the size of the branch where the component is, and moreover you want to be able to change the color or the style of the signs. We can setup the voltage like this:
10450
10451 % TODO: Move this in the listing as well?
10452 \ctikzset{voltage=raised, !v sym/.style={no v symbols}}
10453 \begin{ctikzExample}[exec outside, dollar]
10454 %% The voltage label (the text) will be managed normally by v...={}
10455 %% We need just one parameter to specify the coloa/styler of the signs; we
10456 %% set the other argument to nothing.
10457 \ctikzset{my v/.style = {
10458 voltage=raised, no v symbols, vif queue add={placesigns}{#1}{}{}
10459 }}
10460 %% my V: standard labels, drawing the signs at fixed distance.
10461 %% The macro ALWAYS receive 4 arguments. The first is the node name
10462 %% (that is, the anchor prefix) and the second, in this case, the color/style.
10463 \newcommand{\placesigns}[4]{% place the +- signs at a fixed distance
10464 \path ($(#1voltage.center)!0.5cm!(#1-Vto)$) node[#2]{$+$};
10465 \path ($(#1voltage.center)!0.5cm!(#1-Vfrom)$) node[#2]{$-$};
10466 }
10467 \end{ctikzExample}
10468
10469 \begin{ctikzExample}
10470 \begin{circuitikz}
10471 \draw (3,0) -- ++(1,0) coordinate(Rbot)
10472 to[R=R, name=vR, v={$u_R$}, my v={red}]
10473 ++(0,+3) -- ++(-1,0);
10474 \draw (Rbot) -- ++(2,0) coordinate(Cbot)
10475 to[C=C, name=vC, v>={$u_C$}, my v={draw,blue}]
10476 ++(0,+3) -- ++(-2,0);
10477 \draw (Cbot) to [L=L, v_>={$u_L$},
10478 my v={white,fill=black}] ++(2,0);
10479 \end{circuitikz}
10480 \end{ctikzExample}
10481
10482 If you have an old \LaTeX{} or are using \ConTeXt, you must add the \texttt{use auto vif} to the options of the environment; the option will not have any negative effect if it is not needed.
10483
10484 \begin{lstlisting}
10485 \begin{tikzpicture}[use auto vif]
10486 ... as before
10487 \end{tikzpicture}
10488 \end{lstlisting}
10489
10490 Suppose now we want to change the current indication so that we can typeset the label using \verb!\boldmath!, changing the style of the label and the color of the arrow. For example, we could define the following:
10491
10492 \begin{ctikzExample}[exec outside]
10493 %% arguments: label, style for the arrow, style for the label
10494 \ctikzset{my i/.style n args = {3}{vif queue add={docurrent}{#1}{#2}{#3}}}
10495 \newcommand{\docurrent}[4]{
10496 \node [currarrow, anchor=center, rotate=\ctikzgetdirection{#1-Iarrow},
10497 #3] at (#1-Ipos) {};
10498 \node [anchor=\ctikzgetanchor{#1}{Ilab}, outer sep=4pt, inner sep=1pt,
10499 #4] at (#1-Ipos) {{\boldmath #2}}; %the double {} are needed!!!
10500 }
10501 \end{ctikzExample}
10502
10503 \begin{ctikzExample}
10504 \begin{circuitikz}
10505 % set a default for my v
10506 \ctikzset{my v/.default=blue}
10507 \draw (3,0) -- ++(0.5,0) coordinate(Rbot)
10508 to[R=R, name=vR, v={$u_R$}, my v,
10509 i, my i={$i_r$}{red}{draw, color=red}]
10510 ++(0,+3) -- ++(-.5,0);
10511 \draw (Rbot) -- ++(2,0) coordinate(Cbot)
10512 to[C=C, name=vC, v>={$u_C$}, my v]
10513 ++(0,+3) -- ++(-2,0);
10514 \draw (Cbot) to [L=L, v_>={$u_L$}, my v, i,
10515 my i={\rotatebox{90}{$i=0$}}{green}{fill=yellow}]
10516 ++(2,0);
10517 \end{circuitikz}
10518 \end{ctikzExample}
10519
10520
10521 \subsubsection{Creating new voltage/current/flows commands}\label{sec:activate-directions}
10522
10523 Sometimes, the need of using the syntax \texttt{v, my v=\dots} can result tedious; unfortunately, it is not possible to add the \texttt{v} to the key \texttt{my v} because it will reset the direction/position of the key. To avoid this problem, you can use the new command
10524 \verb!\!\IndexKey{ctikzactivatevoltagedirections} (and their sibling \verb!\!\IndexKey{ctikzactivatecurrentdirections} and \verb!\!\IndexKey{ctikzactivateflowdirections}) which will create the full set of personalized voltage (or current or flow) commands with the appended directions. For example, this is how we can reimplement the ``European arrow with signs'' shown in the previous section:
10525
10526 \begin{ctikzExample}[exec outside]
10527 \newcommand\eurVPM[4]{% node, label, two ignored arguments
10528 \draw [thin, -{Stealth[width=4pt]}, shorten >=5pt, shorten <=5pt]
10529 (#1-Vfrom) node[font=\tiny]{$\vphantom{+}-$}
10530 .. controls (#1-Vcont1) and (#1-Vcont2)..
10531 (#1-Vto) node[font=\tiny]{$+$}
10532 node[pos=0.5,anchor=\ctikzgetanchor{#1}{Vlab}]{#2};
10533 }
10534 \ctikzset{vpm/.style={european voltages, v, vif queue add={eurVPM}{#1}{}{}}}
10535 % do magic with vpm
10536 \ctikzactivatevoltagedirections{vpm}
10537 \end{ctikzExample}
10538
10539 \begin{ctikzExample}
10540 \begin{circuitikz}[voltage shift=0.5]
10541 \draw (0,0)
10542 to[R=R1, name=R1, i=$i$, vpm=$v_1$] ++(4,0)
10543 to[R, l_=R2, vpm^>=$v_2$] ++(0,-3);
10544 \end{circuitikz}
10545 \end{ctikzExample}
10546
10547 You can use this trick even with styles with more than one argument, but then you have to be sure to always add both argument \emph{braced}, otherwise very strange errors will be generated.
10548
10549 \begin{ctikzExample}[exec outside]
10550 \newcommand\eurVPMstyled[4]{% node, label, arrow style, one ignored arguments
10551 \draw [thin, -{Stealth[width=4pt]}, shorten >=5pt, shorten <=5pt, #3]
10552 (#1-Vfrom) node[font=\tiny]{$\vphantom{+}-$}
10553 .. controls (#1-Vcont1) and (#1-Vcont2)..
10554 (#1-Vto) node[font=\tiny]{$+$}
10555 node[pos=0.5,anchor=\ctikzgetanchor{#1}{Vlab}]{#2};
10556 }
10557 \ctikzset{vpms/.style 2 args={european voltages, v,
10558 vif queue add={eurVPMstyled}{#1}{#2}{}}}
10559 \ctikzactivatevoltagedirections{vpms}%
10560 \end{ctikzExample}
10561
10562 \begin{ctikzExample}
10563 \begin{circuitikz}[voltage shift=0.5]
10564 \draw (0,0)
10565 to[R=R1, name=R1, i=$i$, vpms={$v_1$}{dashed}]
10566 ++(4,0)
10567 to[R, l_=R2, vpms^>={$v_2$}{blue}] ++(0,-3);
10568 \end{circuitikz}
10569 \end{ctikzExample}
10570
10571 \endgroup % close automatic-vif
10572
10573 You can see a full example at~\ref{sec:example-auto-vif}.
10574
10575 \subsection{Integration with {\ttfamily siunitx}}
10576 \label{sec:integration-with-siunitx}
10577
10578 If the option {\ttfamily siunitx} is active\footnote{This option is still experimental --- personally (Romano) I would advise using the normal \texttt{\textbackslash SI\{\}\{\}} syntax, or the \texttt{\textbackslash qty\{\}\{\}} one for \IndexKey{siunitx} \texttt{v3} and newer.}, then the following are equivalent (this will \textbf{not} work in \ConTeXt{}, it has been disabled in upstream \ConTeXt, in favor of \href{https://www.pragma-ade.nl/general/manuals/units-mkiv.pdf}{its own \texttt{units} module}):
10579
10580 \begin{ctikzExample}
10581 \begin{circuitikz}
10582 \draw (0,0) to[R, l=1<\kilo\ohm>] (2,0);
10583 \end{circuitikz}
10584 \end{ctikzExample}
10585
10586 \begin{ctikzExample}
10587 \begin{circuitikz}
10588 \draw (0,0) to[R, l=$\SI{1}{\kilo\ohm}$] (2,0);
10589 \end{circuitikz}
10590 \end{ctikzExample}
10591
10592 \begin{ctikzExample}
10593 \begin{circuitikz}
10594 \draw (0,0) to[R, i=1<\milli\ampere>] (2,0);
10595 \end{circuitikz}
10596 \end{ctikzExample}
10597
10598 \begin{ctikzExample}
10599 \begin{circuitikz}
10600 \draw (0,0) to[R, i=$\SI{1}{\milli\ampere}$] (2,0);
10601 \end{circuitikz}
10602 \end{ctikzExample}
10603
10604 \begin{ctikzExample}
10605 \begin{circuitikz}
10606 \draw (0,0) to[R, v=1<\volt>] (2,0);
10607 \end{circuitikz}
10608 \end{ctikzExample}
10609
10610 \begin{ctikzExample}
10611 \begin{circuitikz}
10612 \draw (0,0) to[R, v=$\SI{1}{\volt}$] (2,0);
10613 \end{circuitikz}
10614 \end{ctikzExample}
10615
10616
10617 \section{Using bipoles in circuits}
10618
10619 \subsection{Nodes (also called poles)}\label{sec:bipole-nodes}
10620
10621 You can add nodes to the bipoles, positioned at the coordinates surrounding the component. The general style to use is \IndexKey[bipole nodes]{bipole nodes=\{start\}\{stop\}}, where \texttt{start} and \texttt{stop} are the nodes --- to be chosen between \texttt{none}, \texttt{circ}, \texttt{ocirc}, \texttt{squarepole}, \texttt{osquarepole}, \texttt{diamondpole}, \texttt{odiamondpole} and \texttt{rectfill}\footnote{You can use other shapes too, but at your own risk\dots Moreover, notice that \texttt{none} is not really a node, just a special word used to say ``do not put any node here''.} (see section~\ref{sec:terminals}).
10622
10623
10624 \begin{ctikzExample}
10625 \begin{circuitikz}
10626 \ctikzset{bipoles/length=.5cm, nodes width=0.1}%small components, big nodes
10627 \foreach \a/\p [evaluate=\a as \b using (\a+180)] in
10628 {-90/none, -60/circ, -30/ocirc, 0/diamondpole, 30/odiamondpole, 60/squarepole, 90/osquarepole}
10629 \draw (0,0) to[R, bipole nodes={none}{\p}] ++(\a:1.5) node[font=\tiny, anchor=\b]{\p};
10630 \end{circuitikz}
10631 \end{ctikzExample}
10632
10633 These bipole nodes are added \emph{after} any single path is drawn, as every node in \TikZ\ --- this is the reason why they are always filled (with the main color the normal nodes, with white the open ones), in order to ``hide'' the wire below. You can override the fill color if you want; but notice that if you draw things in two different paths, you will have ``strange'' results; notice that in the second line of resistors the second wire is starting from the center of the white \texttt{ocirc} of the previous path.
10634
10635 \begin{ctikzExample}[varwidth=true, pos=t]
10636 \begin{circuitikz}
10637 \draw (0,0) to[R, *-o] ++(2,0) to[R, -d] ++(2,0)
10638 to[R, bipole nodes={diamondpole}{odiamondpole, fill=red}] ++(2,0);
10639 \draw (0,-1) to[R, *-o] ++(2,0) ;
10640 \draw (2,-1) to[R, -d] ++(2,0) to[R, bipole nodes={none}{squarepole}] ++(2,0);
10641 \end{circuitikz}
10642 \end{ctikzExample}
10643
10644 You can define shortcuts for the \texttt{bipole nodes} you use most; for example if you want a shortcut for a bipole with open square node in red in the right side you can:
10645
10646 \begin{ctikzExample}
10647 \begin{circuitikz}
10648 \ctikzset{-s/.style = {bipole nodes={none}{osquarepole, fill=red}}}
10649 \draw (0,0) to[R, -s] ++(2,0);
10650 \end{circuitikz}
10651 \end{ctikzExample}
10652
10653 There are several predefined shorthand as the above; in the following pages you can see all of them.
10654
10655 \begin{ctikzExample}
10656 \begin{circuitikz}
10657 \draw (0,0) to[R, o-o] (2,0);
10658 \end{circuitikz}
10659 \end{ctikzExample}
10660
10661 \begin{ctikzExample}
10662 \begin{circuitikz}
10663 \draw (0,0) to[R, -o] (2,0);
10664 \end{circuitikz}
10665 \end{ctikzExample}
10666
10667 \begin{ctikzExample}
10668 \begin{circuitikz}
10669 \draw (0,0) to[R, o-] (2,0);
10670 \end{circuitikz}
10671 \end{ctikzExample}
10672
10673 \begin{ctikzExample}
10674 \begin{circuitikz}
10675 \draw (0,0) to[R, *-*] (2,0);
10676 \end{circuitikz}
10677 \end{ctikzExample}
10678
10679 \begin{ctikzExample}
10680 \begin{circuitikz}
10681 \draw (0,0) to[R, -*] (2,0);
10682 \end{circuitikz}
10683 \end{ctikzExample}
10684
10685 \begin{ctikzExample}
10686 \begin{circuitikz}
10687 \draw (0,0) to[R, *-] (2,0);
10688 \end{circuitikz}
10689 \end{ctikzExample}
10690
10691 \begin{ctikzExample}
10692 \begin{circuitikz}
10693 \draw (0,0) to[R, d-d] (2,0);
10694 \end{circuitikz}
10695 \end{ctikzExample}
10696
10697 \begin{ctikzExample}
10698 \begin{circuitikz}
10699 \draw (0,0) to[R, -d] (2,0);
10700 \end{circuitikz}
10701 \end{ctikzExample}
10702
10703 \begin{ctikzExample}
10704 \begin{circuitikz}
10705 \draw (0,0) to[R, d-] (2,0);
10706 \end{circuitikz}
10707 \end{ctikzExample}
10708
10709 \begin{ctikzExample}
10710 \begin{circuitikz}
10711 \draw (0,0) to[R, o-*] (2,0);
10712 \end{circuitikz}
10713 \end{ctikzExample}
10714
10715 \begin{ctikzExample}
10716 \begin{circuitikz}
10717 \draw (0,0) to[R, *-o] (2,0);
10718 \end{circuitikz}
10719 \end{ctikzExample}
10720
10721 \begin{ctikzExample}
10722 \begin{circuitikz}
10723 \draw (0,0) to[R, o-d] (2,0);
10724 \end{circuitikz}
10725 \end{ctikzExample}
10726
10727 \begin{ctikzExample}
10728 \begin{circuitikz}
10729 \draw (0,0) to[R, d-o] (2,0);
10730 \end{circuitikz}
10731 \end{ctikzExample}
10732
10733 \begin{ctikzExample}
10734 \begin{circuitikz}
10735 \draw (0,0) to[R, *-d] (2,0);
10736 \end{circuitikz}
10737 \end{ctikzExample}
10738
10739 \begin{ctikzExample}
10740 \begin{circuitikz}
10741 \draw (0,0) to[R, d-*] (2,0);
10742 \end{circuitikz}
10743 \end{ctikzExample}
10744
10745 \subsubsection{Transparent poles}\label{sec:transparent-poles}
10746
10747 ``Open-poles'' terminals (\texttt{ocirc}, \texttt{odiamondpole}, and \texttt{osquarepole}) are normally filled with the background color at full opacity. The is reason is that \TikZ{}, when stroking a path, places and draws the nodes \emph{after} the lines are drawn; that way the poles ``white-out'' the underlying lines. Clearly this works if the wires and poles are written \emph{in the same path command}, otherwise the explicit order is respected.
10748
10749 Anyway, \emph{if you know what you are doing}, you can change it with the key \IndexKey[poles/open fill opacity]{poles/open fill opacity} (with \verb|\ctikzset|) or the style \IndexKey[open poles opacity]{open poles opacity}. Notice that you will have artifacts if you don't use the border anchors of the poles to connect wires, and you need to do that by hand.
10750
10751 Notice that in poles, the opacity is \emph{always} selected with these keys, and it overrides the opacity of the draw commands (when not set explicitly is as if it is set to \texttt{1.0}, i.e., full opaque). This is because you normally do not want unfilled poles!
10752
10753 \begin{ctikzExample}[pos=t]
10754 \begin{circuitikz}[scale=3, transform shape]
10755 \fill[cyan] (0,0) rectangle (4.1,-0.6);
10756 \ctikzset{open poles fill=red}
10757 \tikzset{open poles opacity=0.5}
10758 % automatic positioning when opacity is not 1.0 creates artifacts
10759 % note that the global fill opacity affects the "generic shape", but not the poles!
10760 % the fill color of the poles, instead, goes with the component
10761 \draw[fill opacity=0.8] (0,0) to[generic, fill=white, -o] ++(2,0) --++(0,-0.5);
10762 % \draw (0,0) to[generic, fill=white, -o] ++(2,0) --++(0,-0.5);
10763 % you have to use manual positioning
10764 \draw (2.2,0) -- ++(0.5,0) node[ocirc, anchor=180, fill opacity=0.5]{};
10765 \draw (3,0) node[ocirc, fill opacity=0.5](B){} (B.0) --++(0.5,0) (B.-90) --++(0,-0.5);
10766 % maybe really useful only for terminals going out of the circuit...
10767 % notice that in node commands you can specify the opacity directly
10768 \draw (3.6,0) -- ++(0.2,0) node[ocirc, fill=white, fill opacity=0.5, anchor=180]{};
10769 \end{circuitikz}
10770 \end{ctikzExample}
10771
10772 You also have the similar keys for the ``full'' poles (albeit they are probably not useful at all).
10773
10774
10775 \subsection{Mirroring and Inverting}
10776 \label{sec:mirroring-and-inverting}
10777 Bipole paths can also be mirrored and inverted (or reverted) to change the drawing direction.
10778
10779 \begin{ctikzExample}
10780 \begin{circuitikz}
10781 \draw (0,0) to[pD] (2,0);
10782 \end{circuitikz}
10783 \end{ctikzExample}
10784
10785 \begin{ctikzExample}
10786 \begin{circuitikz}
10787 \draw (0,0) to[pD, mirror] (2,0);
10788 \end{circuitikz}
10789 \end{ctikzExample}
10790 \begin{ctikzExample}
10791 \begin{circuitikz}
10792 \draw (0,0) to[pD, invert] (2,0);
10793 \end{circuitikz}
10794 \end{ctikzExample}
10795
10796 Placing labels, currents and voltages also works, please note, that mirroring and inverting does not influence the positioning of labels and voltages. Labels are by default above/right of the bipole and voltages below/left, respectively.
10797 \begin{ctikzExample}
10798 \begin{circuitikz}
10799 \draw (0,0) to[ospst=T, i=$i_1$, v=$v$] (2,0);
10800 \end{circuitikz}
10801 \end{ctikzExample}
10802
10803 \begin{ctikzExample}
10804 \begin{circuitikz}
10805 \draw (0,0) to[ospst=T, mirror, i=$i_1$, v=$v$] (2,0);
10806 \end{circuitikz}
10807 \end{ctikzExample}
10808
10809 \begin{ctikzExample}
10810 \begin{circuitikz}
10811 \draw (0,0) to[ospst=T, invert, i=$i_1$, v=$v$] (2,0);
10812 \end{circuitikz}
10813 \end{ctikzExample}
10814 \begin{ctikzExample}
10815 \begin{circuitikz}
10816 \draw (0,0) to[ospst=T,mirror,invert, i=$i_1$, v=$v$] (2,0);
10817 \end{circuitikz}
10818 \end{ctikzExample}
10819
10820
10821 \subsection{Putting them together}
10822 \label{sec:putting-them-together}
10823 \begin{ctikzExample}
10824 \begin{circuitikz}
10825 \draw (0,0) to[R=1<\kilo\ohm>,
10826 i>_=1<\milli\ampere>, o-*] (3,0);
10827 \end{circuitikz}
10828 \end{ctikzExample}
10829
10830 \begin{ctikzExample}
10831 \begin{circuitikz}
10832 \draw (0,0) to[D*, v=$v_D$,
10833 i=1<\milli\ampere>, o-*] (3,0);
10834 \end{circuitikz}
10835 \end{ctikzExample}
10836
10837 \subsection{Line joins between Path Components}
10838 \label{sec:line-joins}
10839
10840 Line joins should be calculated correctly - if they are on the same path, and the path is not closed. For example, the following path is not closed correctly (\texttt{--cycle} does not work here!):
10841 \begin{ctikzExample}
10842 \begin{tikzpicture}[line width=3pt,european]
10843 \draw (0,0) to[R]++(2,0)to[R]++(0,2)
10844 --++(-2,0)to[R]++(0,-2);
10845 \draw[red,line width=1pt] circle(2mm);
10846 \end{tikzpicture}
10847 \end{ctikzExample}
10848 To correct the line ending, there are support shapes to fill the missing rectangle. They can be used like the support shapes (*,o,d) using a dot (.) on one or both ends of a component (have a look at the last resistor in this example:
10849 \begin{ctikzExample}
10850 \begin{tikzpicture}[line width=3pt,european]
10851 \draw (0,0) to[R]++(2,0)to[R]++(0,2)
10852 --++(-2,0)to[R,-.]++(0,-2);
10853 \draw[red,line width=1pt] circle(2mm);
10854 \end{tikzpicture}
10855 \end{ctikzExample}
10856
10857 \section{Colors}\label{sec:colors}
10858
10859 Color support in \Circuitikz{} has been quite limited up to version 1.5.1; from that one onward there has been an effort to make components' behavior more intuitive.
10860
10861 Part of the problem is how colors in paths are treated by \TikZ{} itself; you can see part of the discussion on \href{https://github.com/circuitikz/circuitikz/issues/605}{this issue} and in \href{https://tex.stackexchange.com/questions/634987/pgf-basic-layer-struggling-again-with-colors}{this question on TeX.SX} --- many thanks to \texttt{@muzimuzhi} for helping there. Basically, nodes are drawn \emph{after} the path is completed, and color is applied to the path at the end. Look at this code (pure \TikZ, no \Circuitikz{} here):
10862
10863 \begin{ctikzExample}[varwidth=true]
10864 \tikz \draw[thick] (0,0) -- (1,0) {[color=red] -- (2,0) node[draw]{}} --(3,0); \par
10865 \tikz \draw[thick] (0,0) -- (1,0) [color=red] -- (2,0) node[draw]{} --(3,0);
10866 \end{ctikzExample}
10867
10868 So the path is drawn with the last ``effective'' (in current group) color. The deferred behavior of the color properties is very difficult to track for \Circuitikz, especially when the shorthand \IndexKey[color]{color-name} (e.g., \texttt{red} instead of \texttt{color=red}) is used. \Circuitikz{} will try to keep track of the colors specified by \texttt{color=...} and \texttt{fill=...}, but if you use the implicit way (\texttt{\textbackslash draw[red]...}) it often fails.
10869
10870 If you're adventurous, you can try to add
10871 \begin{lstlisting}[numbers=none]
10872 \usepackage{regexpatch}\ctikzPatchImplicitColor
10873 \end{lstlisting}
10874 after loading \Circuitikz, and it will try to patch the default commands to keep track of the ``current color''; if it fails will give a warning like \texttt{patch failed, use only explicit color=...}. This is, unfortunately, not compatible with package \texttt{xpatch} (and much others, which load \texttt{xpatch}).\footnote{version \texttt{1.5.0} loaded it unconditionally for LaTeX; please do not use it}.
10875
10876 Before 1.5.0, \Circuitikz{} used black as the default color. Now it tries to follow the current color, as \TikZ{} does normally; but notice that there is a difference with the fill strategy:
10877
10878
10879 \begin{ctikzExample}[pos=t]
10880 \color{red}
10881 Red text
10882 \tikz \draw (0,0) -- node[draw] {x} (1,0) -- node[draw=cyan] {y} (2,0);
10883 \tikz \draw (0,0) to[R] (2,0) to[R,color=cyan] (4,0) to [generic] (6,0) to [fullgeneric] (8,0);
10884
10885 \color{blue}
10886 Blue text
10887 \tikz \draw (0,0) -- node[draw] {x} (1,0) -- node[draw=cyan] {y} (2,0);
10888 \tikz \draw (0,0) to[R] (2,0) to[R,color=cyan] (4,0) to [generic] (6,0) to [fullgeneric] (8,0);
10889
10890 \color{black}
10891 Black text
10892 \tikz \draw[fill=yellow] (0,0) -- node[draw, fill] {x} (1,0) -- node[draw=cyan] {y} (2,0);
10893 \tikz \draw[fill=yellow] (0,0) to[R] (2,0) to[R,color=cyan] (4,0) to [generic] (6,0) to [fullgeneric] (8,0);
10894 \end{ctikzExample}
10895
10896 \Circuitikz{} components that are fillable will inherit the \IndexKey[fill (color)]{fill} property of the path (it is almost impossible to do otherwise) as if the \texttt{fill} flag was present. ``Full''-type elements (for example, full diodes or similar) are filled with the draw color; elements with intrinsic labels (i.e., labels that are part of the shape, like signs on amplifiers and pin numbers in chips) are drawn with the ``draw'' colors.
10897
10898 Basically, you should have no problem if:
10899 \begin{enumerate}
10900 \item You stick to use styles (see~\ref{sec:styling-fillcolor}) for filling your components, or using a direct \texttt{fill=...} option in the component node or \texttt{to} option;
10901 \item do not try to change the color mid-path; sometimes it works (see the examples below), but it's better to avoid it (using different paths is better);
10902 \item when coloring whole circuits, it's better to use the option \texttt{color=...} in your global picture options or in the \verb|\draw| command (not just the color name as a shorthand);
10903 \item forget about transparency.
10904 \end{enumerate}
10905
10906 Nevertheless, if you really need to do strange things with colors you can read on; you can do almost everything but there are several glitches to take into account.
10907
10908 Moreover, in some cases, also the engine you are using (as \texttt{pdflatex}, \texttt{xelatex}, and so on) can impact corner cases (or even not so corner, like in \href{https://tex.stackexchange.com/q/709273/38080}{american-style voltage source signs}).
10909
10910 \subsection{Shape colors}
10911 \label{sec:shape-colors}
10912
10913 The color of the components is stored in the key \verb!\circuitikzbasekey/color!. Circui\TikZ\ tries to follow the color set in \TikZ, although sometimes it fails. The following circuit will fail to draw the circuit in red if the patching of the inner commands of \TikZ{} fails, like for example in \ConTeXt{}.
10914
10915 \begin{ctikzExample}
10916 \begin{circuitikz} \draw[red]
10917 (0,2) node[and port](myand1){1}
10918 (0,0) node[and port](myand2){2}
10919 (2,1) node[xnor port](myxnor){3}
10920 (myand1.out) -| (myxnor.in 1)
10921 (myand2.out) -| (myxnor.in 2)
10922 ;\end{circuitikz}
10923 \end{ctikzExample}
10924
10925 If you see this problem, please do not use just the color name as a style, like \verb![red]!, but rather assign the style \verb![color=red]!.
10926
10927 \begin{ctikzExample}
10928 \begin{circuitikz} \draw[color=red]
10929 (0,2) node[and port](myand1){1}
10930 (0,0) node[and port](myand2){2}
10931 (2,1) node[xnor port](myxnor){3}
10932 (myand1.out) -| (myxnor.in 1)
10933 (myand2.out) -| (myxnor.in 2)
10934 ;\end{circuitikz}
10935 \end{ctikzExample}
10936
10937 One can, of course, change the color directly in the component:
10938 \begin{ctikzExample}[pos=t, varwidth=true]
10939 \begin{circuitikz} \draw
10940 (0,0) node[pnp, color=blue](pnp2){q1}
10941 (pnp2.B) node[pnp, xscale=-1, anchor=B, color=brown](pnp1){\ctikzflipx{q2}}
10942 (pnp1.C) node[npn, anchor=C, color=green](npn1){q3}
10943 (pnp2.C) node[npn, xscale=-1, anchor=C, color=magenta](npn2){\ctikzflipx{q4}}
10944 (pnp1.E) -- (pnp2.E) (npn1.E) -- (npn2.E)
10945 (pnp1.B) node[circ]{} |- (pnp2.C) node[circ]{}
10946 ;\end{circuitikz}
10947 \end{ctikzExample}
10948
10949 The all-in-one stream of bipoles poses some challenges, as only the actual body of the bipole, and not the connecting lines, will be rendered in the specified color (Notice that the following example uses the special \texttt{siunitx} shorthand; you can use it only in simple cases like here, in general using the full \verb|\SI{}| or \verb|\qty{}| commands).
10950
10951 \begin{ctikzExample}
10952 \begin{circuitikz} \draw
10953 (0,0) to[V=1<\volt>] (0,2)
10954 to[R=1<\ohm>, color=red] (2,2)
10955 to[C=1<\farad>] (2,0) -- (0,0)
10956 ;\end{circuitikz}
10957 \end{ctikzExample}
10958
10959 The postponed application of colors creates a problem if you want to use arrows for voltages, because the ``arrows'' are partially part of the path, partially nodes:
10960
10961 \begin{ctikzExample}
10962 \begin{circuitikz} \draw
10963 (0,0){[red] to[V=1<\volt>] (0,2) }
10964 to[R=1<\ohm>] (2,2)
10965 to[C=1<\farad>] (2,0) -- (0,0)
10966 ;\end{circuitikz}
10967 \end{ctikzExample}
10968
10969 ...and that can become quite frustrating:
10970
10971 \begin{ctikzExample}
10972 \begin{circuitikz} \draw
10973 (0,0) to[V=1<\volt>, color=red] (0,2)
10974 to[R=1<\ohm>] (2,2)
10975 to[C=1<\farad>] (2,0) -- (0,0)
10976 ;\end{circuitikz}
10977 \end{ctikzExample}
10978
10979 In those cases, the only way out is to specify different paths (and/or using advanced voltages, see~\ref{sec:vif-anchors})
10980
10981 \begin{ctikzExample}
10982 \begin{circuitikz} \draw[color=red]
10983 (0,0) to[V=1<\volt>, color=red] (0,2);
10984 \draw (0,2) to[R=1<\ohm>] (2,2)
10985 to[C=1<\farad>] (2,0) -- (0,0)
10986 ;\end{circuitikz}
10987 \end{ctikzExample}
10988
10989 \subsection{Fill colors}
10990 \label{sec:fill-colors}
10991
10992 Since version 0.9.0, you can also fill most shapes with a color (the manual specifies which ones are fillable or not). The syntax is quite intuitive:
10993
10994 \begin{ctikzExample}
10995 \begin{circuitikz} \draw
10996 (0,2) node[and port, fill=yellow](myand1){1}
10997 (0,0) node[and port, fill=cyan](myand2){2}
10998 (2,1) node[xnor port,fill=red!30!white](myxnor){3}
10999 (myand1.out) -| (myxnor.in 1)
11000 (myand2.out) -| (myxnor.in 2)
11001 ;\end{circuitikz}
11002 \end{ctikzExample}
11003
11004
11005 This fill color will override any color defined by the style (see section~\ref{sec:styling-fillcolor}). If you want to override a style fill color with no-fill for a specific component, you need to override the style --- it's a bit unfortunate, but should be an exceptional thing anyway. Notice that in simple case \IndexKey{fill opacity} works, but don't count too much on it.
11006
11007 \begin{ctikzExample}
11008 \begin{circuitikz}
11009 \ctikzset{logic ports/fill=cyan!30!white}
11010 \draw[red] (-0.5,3) -- (-0.5, -1);
11011 \draw[red] (1.5,3) -- (1.5, -1);
11012 \draw
11013 (0,2) node[and port](myand1){1}
11014 (0,0) node[and port, fill=cyan, fill opacity=0.7](myand2){2}
11015 (2,1) node[xnor port, circuitikz/logic ports/fill=none
11016 ](myxnor){3}
11017 (myand1.out) -| (myxnor.in 1)
11018 (myand2.out) -| (myxnor.in 2)
11019 ;\end{circuitikz}
11020 \end{ctikzExample}
11021
11022 You can combine shape colors with fill colors, too, but you should use the explicit \texttt{color} option style for this:
11023
11024 \begin{ctikzExample}
11025 \begin{circuitikz} \draw[color=red]
11026 (0,2) node[and port, fill=yellow](myand1) {1}
11027 (0,0) node[and port, fill=cyan] (myand2){2}
11028 (2,1) node[xnor port,fill=red!30!white](myxnor){3}
11029 (myand1.out) -| (myxnor.in 1)
11030 (myand2.out) -| (myxnor.in 2)
11031 ;\end{circuitikz}
11032 \end{ctikzExample}
11033
11034 \begin{ctikzExample}
11035 \begin{circuitikz} \draw
11036 (0,2) node[and port, color=black](myand1){1}
11037 (0,0) node[and port, color=blue, fill=cyan](myand2){2}
11038 (2,1) node[xnor port, color=red, fill=cyan](myxnor){3}
11039 (myand1.out) -| (myxnor.in 1)
11040 (myand2.out) -| (myxnor.in 2)
11041 ;\end{circuitikz}
11042 \end{ctikzExample}
11043
11044 \subsubsection{Background colors different from white}
11045 \label{sec:background-colors-different}
11046
11047 Notice also that the connection point is always filled, and the color \emph{tries} to follow the color of the filling of the component (but look at section~\ref{sec:transparent-poles}). Moreover, if you want to pass fill transparency down to path-style components, you \emph{have} to put it into the options of the \verb|\draw| command.
11048
11049 \begin{ctikzExample}[varwidth=true, pos=t]
11050 \begin{circuitikz}
11051 \fill[cyan] (0,3.0) rectangle (7,7);
11052 \draw [fill opacity=0.5] (1,6.5) to[generic, fill=white,o-o] ++(2,0);
11053 \draw (1,5.5) to[short, fill=red, o-o] ++(1,0) to[short, -o] ++(1,0);
11054 \draw[fill=yellow] (1,5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0);
11055 \draw (1,4.5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0);
11056 \draw (1,4) node[ocirc]{} -- ++(1,0) node[ocirc]{};
11057 \draw [thick, color=green!50!black] (4,4) to [D,o-o,fill=yellow] ++(0,2) to[D*, fill=yellow]
11058 ++(2,0) to[D*,fill=yellow] ++(0,-2) to[D, fill=red, o-o] ++(-2,0);
11059 \end{circuitikz}
11060 \end{ctikzExample}
11061
11062 As you can see, the ``black'' components (as \texttt{D*}) follow the color of the line, not the fill.
11063
11064 Note, however, that if you choose a colored background, for example with the \verb|\pagecolor{}| command or with other tricks, the nodes will be by default still filled with white.
11065
11066 \begin{ctikzExample}
11067 \begin{circuitikz}[european]
11068 \fill[color=blue] (-1,-1) rectangle (4,1);
11069 \draw[color=white] (0,0) to[R, o-o] ++(3,0);
11070 \end{circuitikz}
11071 \end{ctikzExample}
11072
11073 You have two solutions for this. You can redefine the \IndexKey{o-o} (and the similar commands \IndexKey{-o}, \IndexKey{o-}, \IndexKey{*-o} and so on) with a blue filled ``open'' pole:
11074
11075 \begin{ctikzExample}
11076 \tikzset{bcirc/.style={shape=ocirc, fill=blue}}
11077 \ctikzset{o-o/.style ={
11078 \circuitikzbasekey/bipole/nodes/left=bcirc,
11079 \circuitikzbasekey/bipole/nodes/right=bcirc}}
11080 \begin{circuitikz}[european]
11081 \fill[color=blue] (-1,-1) rectangle (4,1);
11082 \draw[color=white] (0,0) to[R, o-o] ++(3,0);
11083 \end{circuitikz}
11084 \end{ctikzExample}
11085
11086 Also, since \texttt{v1.2.3}, you can set the key \IndexKey{open poles fill} (default: \texttt{white} which works for \texttt{ocirc}, \texttt{odiamondpole} and \texttt{osquarepole}):
11087
11088 \begin{ctikzExample}
11089 \begin{circuitikz}[european]
11090 \ctikzset{open poles fill=blue}
11091 \fill[color=blue] (-1,-1) rectangle (4,1);
11092 \draw[color=white] (0,0) to[R, o-o] ++(3,0);
11093 \end{circuitikz}
11094 \end{ctikzExample}
11095
11096
11097 \section{FAQ: Frequently asked questions}
11098 \label{sec:faq-frequently-asked}
11099
11100 \def\faqQ{\par\medskip\noindent\textbf{Q: }}
11101 \def\faqA{\par\noindent\textbf{A: }}
11102
11103 \subsection{Using named nodes in circuits}\label{faqs:nodes}
11104
11105 \faqQ When I use a node to name a connection in the circuit, I have gaps in the wires! I am sure it used to work!
11106
11107 \faqA This is explained in~\ref{sec:incompatible-changes}. The fast answer is that in a hurry, use the \texttt{1.1.2} fallback point with:
11108
11109 \verb|\usepackage{circuitikz-1.1.2}|
11110
11111 in your preamble.
11112
11113 But really, your circuit definition is buggy, so the best thing to do is fix that; if you want to name a point in your circuit, you should use a \texttt{coordinate}, not a \texttt{node}.\footnote{Yes, I understand from where the confusion arise --- in circuit theory they are called nodes.} Here is a small tutorial on \emph{why} you should change your circuit.
11114
11115 Nodes, in \TikZ, normally have a non-zero size even when they are empty; moreover, connections are supposed to join the border of nodes. Please study the following (pure \TikZ, not \Circuitikz):
11116
11117 \begin{ctikzExample}
11118 \begin{tikzpicture}
11119 \path (1,1) node (A){}; % empty node at (1,1)
11120 \draw (1,0) -- (A) -- (2,1); % surprise!
11121 \end{tikzpicture}
11122 \end{ctikzExample}
11123
11124 The gap is there because the node has a non-zero size (more in detail, its \texttt{inner sep} is by default different from zero). You can see it easily if you draw the node shape:
11125
11126 \begin{ctikzExample}
11127 \begin{tikzpicture}
11128 \path (1,1) node [draw=red](A){};
11129 \draw (1,0) -- (A) -- (2,1);
11130 \end{tikzpicture}
11131 \end{ctikzExample}
11132
11133 The problem is that when you want to name a coordinate, in the sense of a dimensionless point, you should use a \texttt{coordinate}, \textbf{not} a node!
11134
11135 \begin{ctikzExample}
11136 \begin{tikzpicture}
11137 \path (1,1) coordinate (A); % give a name to (1,1)
11138 \draw (1,0) -- (A) -- (2,1);% now it's ok!
11139 \end{tikzpicture}
11140 \end{ctikzExample}
11141
11142 Now, before version \texttt{1.2.1} (and since around \texttt{0.6}), \Circuitikz{} was detecting when a connection was between nodes and sort-of added a \texttt{node.center} movement to the path. That in turn generated the need of hacks to draw the correct joining of lines, because that kind of movement broke the continuity of the path, like in this example:
11143
11144 \begin{ctikzExample}
11145 \begin{tikzpicture}[line width=4pt]
11146 \path (1,1) node (A){};
11147 \draw (1,0) -- (A.center) (A) (A.center) -- (2,1);
11148 \end{tikzpicture}
11149 \end{ctikzExample}
11150
11151 You can see more examples and more reasonings on GitHub; start from the
11152 \href{https://github.com/circuitikz/circuitikz/issues/417}{issue detecting the join problem}, then
11153 \href{https://github.com/circuitikz/circuitikz/pull/418}{look at the merged fix}; you can follow several issues and discussions from there, but for example there are circuits that can't be drawn with the ``hack'' in, \href{https://github.com/circuitikz/circuitikz/issues/76#issuecomment-652980687}{like this one}.
11154
11155 So finally it was decided\footnote{well, Romano decided, so you can blame him. \emph{I do not think that workarounds to correct malformed circuits are really maintainable; just see the bunch of code removed by the patch! --- Romano.}} to remove the change, to simplify the code and to make the package more maintainable.
11156
11157 \subsection{Using dashed (or colored) wires in circuits}\label{faqs:dashed}
11158
11159 \faqQ How can I make part of the wires dashed (or colored)? This does not work:
11160
11161 \begin{ctikzExample}
11162 \begin{circuitikz}
11163 \draw (0,0) to[R] ++(2,0)
11164 to[short, dashed, red] ++(1,0)
11165 to [R] ++(2,0); % surprise!
11166 \end{circuitikz}
11167 \end{ctikzExample}
11168
11169 Nor this one, which is even stranger:
11170
11171 \begin{ctikzExample}
11172 \begin{circuitikz}
11173 \draw (0,0) to[R] ++(2,0)
11174 [dashed, red] -- ++(1,0)
11175 to [R] ++(2,0); % surprise!
11176 \end{circuitikz}
11177 \end{ctikzExample}
11178
11179 \faqA This is an effect on how \TikZ{} builds and draws path. As explained in the \TikZ{} manual,\footnote{in 3.1.5b, section~14, \href{https://tikz.dev/tikz-paths}{``syntax for path specification''}} most path options are globally valid for the whole path; color and dash/dot is one of this. You have two options in this case. The first one is to use two paths.
11180
11181 \begin{ctikzExample}
11182 \begin{circuitikz}
11183 \draw (0,0) to[R] ++(2,0) coordinate(a);
11184 \draw [dashed, red] (a) -- ++(1,0) coordinate(b);
11185 \draw (b) to [R] ++(2,0);
11186 \end{circuitikz}
11187 \end{ctikzExample}
11188
11189 The other one is to use \texttt{edge} operations\footnote{I took the idea form \href{https://tex.stackexchange.com/a/554905/38080}{this answer by \texttt{@LaTeXdraw-com} user on TeX.SE}, thanks!}; be sure to read about it on the \TikZ{} manual\footnote{in 3.1.5b, section~17.12, \href{https://tikz.dev/tikz-shapes\#sec-17.12.1}{``connecting nodes: use the \texttt{edge} operation''}} --- but basically this is similar to the \texttt{to} operation but it builds another path (added at the end of the current path, like nodes are). This means that it can use different options, and that it \textbf{does not} move the path coordinates.
11190
11191 So, for example:
11192
11193 \begin{ctikzExample}
11194 \begin{circuitikz}
11195 \draw (0,0) to[R] ++(2,0)
11196 edge[dashed, red] ++(1,0)
11197 % we have to move the path position here!
11198 ++(1,0) to [R] ++(2,0);
11199 \end{circuitikz}
11200 \end{ctikzExample}
11201
11202 The only problem with this approach is that the \texttt{edge}s are added \emph{after} the nodes, so it can create problems with nodes (look carefully!):
11203
11204 \begin{ctikzExample}
11205 \begin{circuitikz}
11206 \draw (0,0) to[R,-o] ++(2,0)
11207 edge[dashed, red] ++(1,0)
11208 ++(1,0) to [R] ++(2,0);
11209 \end{circuitikz}
11210 \end{ctikzExample}
11211
11212 So it's better, in this case, to add the nodes manually after the path (there is no perfect solution!):
11213
11214 \begin{ctikzExample}
11215 \begin{circuitikz}
11216 \draw (0,0) to[R] ++(2,0) coordinate(a)
11217 edge[dashed, red] ++(1,0)
11218 ++(1,0) to [R] ++(2,0);
11219 \node [ocirc] at (a){};
11220 \end{circuitikz}
11221 \end{ctikzExample}
11222
11223
11224 A more complex example can be seen (look at the comments!) in the following circuit.
11225
11226 \begin{ctikzExample}
11227 \begin{circuitikz}[american]
11228 \draw (0,0) to[R, v=$v_1$] ++(2,0)
11229 edge[dashed] ++(1,0)
11230 ++(1,0) to[R]
11231 ++(2,0) to [R] ++(0,2) coordinate(a)
11232 edge[red, dashed] ++(0,1)
11233 % several edges start from the same position
11234 edge[dashed, ->] node[above]{here} ++(-1,0)
11235 % notice that the path here is still
11236 % at coordinate (a)!
11237 ++(0,1) to[R] ++(0,2)
11238 (a) ++(-1,0) to[sV] ++(-2,0);
11239 \end{circuitikz}
11240 \end{ctikzExample}
11241
11242 \subsection{Errors when externalizing pictures}\label{faqs:externalize}
11243
11244 \faqQ When using \verb!\tikzexternalize! I get the following error:
11245 \begin{verbatim}
11246 ! Emergency stop.
11247 \end{verbatim}
11248
11249 \faqA The \TikZ\ manual states:
11250
11251 \begin{quotation}
11252 \noindent Furthermore, the library assumes that all \LaTeX\ pictures are ended
11253 with \\\verb!\end{tikzpicture}!.
11254 \end{quotation}
11255
11256 Just substitute every occurrence of the environment \verb!circuitikz! with \verb!tikzpicture!. They are actually pretty much the same.
11257
11258 \subsection{Labels, voltages and currents woes}\label{faqs:labels}
11259
11260 \faqQ How do I draw the voltage between two nodes?
11261
11262 \faqA Between any two nodes there is an open circuit!
11263 \begin{ctikzExample}
11264 \begin{circuitikz} \draw
11265 node[ocirc] (A) at (0,0) {}
11266 node[ocirc] (B) at (2,1) {}
11267 (A) to[open, v=$v$] (B)
11268 ;\end{circuitikz}
11269 \end{ctikzExample}
11270
11271 \bigskip
11272
11273 \faqQ I cannot write \verb!to[R = $R_1=12V$]! nor \verb!to[ospst = open, 3s]!: I get errors.
11274
11275 \faqA It is a limitation of the parser, joined with a suboptimal processing by \Circuitikz{} (up to \texttt{1.2.7}) of the passing of the argument of keys.
11276
11277 You should protect commas and equal signs like in \verb!to[R = {$R_1=12V$}]! or \verb!to[ospst = {open, 3s}]!.
11278
11279 In versions up to \texttt{1.2.7}, use for example \verb|\mbox{}| or define \verb|\def{\eq}{=}| and use \verb!to[R = $R_1\eq 12V$]!, or try to protect commas and equal signs like \verb!to[ospst = open{,} 3s]! or \verb|ospst=\mbox{open, 3s}| instead; see caveat in section~\ref{sec:labels-and-annotations}.
11280
11281 \subsection{Global scaling and rotating}\label{faqs:scale-and-rotate}
11282
11283 \faqQ I tried to change the direction of the $y$-axis with \texttt{yscale=-1}, but the circuit is completely messed up.
11284
11285 \faqA Yes, it's a known bug (or misfeature, or limitation). See section~\ref{sec:bugs}. Don't do that.
11286
11287
11288 \faqQ I tried to put a diode in a \IndexKey{pic}, but it's coming out badly rotated.
11289
11290 \faqA This is a bug that \emph{should} have been fixed in \texttt{v1.8.0}. Previous versions of \Circuitikz{} are plainly not compatible with \texttt{pic}s.
11291
11292 \subsection{Tunable components}\label{faq:tunable-arrow}
11293
11294 \faqQ The direction of the arrows in variable resistors or capacitors changed!
11295
11296 \faqA Yes, it changed in \texttt{v1.3.3}.
11297
11298 Version 1.3.3 fixes the direction of the arrows in tunable elements; before this version, they were more or less random, now the arrow goes from bottom left to top right. You have the option to go back to the old behavior with \IndexKey[bipoles/fix tunable direction]{}\texttt{\textbackslash ctikzset\{bipoles/fix tunable direction=false\}}. As a compensation for the fuss, now the arrows are configurable.
11299
11300
11301 \begin{ctikzExample}[pos=t]
11302 \begin{circuitikz}[european]
11303 \draw (1,0) node{new default} (4,0) node{old default} (7,0) node{new!};
11304 \foreach [count=\i] \comp in
11305 {variable american resistor, variable european resistor,
11306 variable cute inductor, variable american inductor, tfullgeneric,
11307 variable capacitor} {
11308 \draw (0,-\i) node[left]{\texttt{\comp}} to[\comp, name=E] ++(2,0);
11309 \ctikzset{bipoles/fix tunable direction=false}
11310 \draw (3,-\i) to[\comp, name=E] ++(2,0);
11311 \ctikzset{bipoles/fix tunable direction=true, tunable end arrow={Bar}}
11312 \draw (6,-\i) to[\comp, name=E] ++(2,0);
11313 }
11314 \end{circuitikz}
11315 \end{ctikzExample}
11316
11317
11318 \section{Defining new components}
11319 \label{sec:defining-new-components}
11320
11321 \begin{quote}
11322 Per me si va ne la città dolente,\\
11323 per me si va ne l'etterno dolore,\\
11324 per me si va tra la perduta gente.\\
11325 \dots\\
11326 Lasciate ogne speranza, voi ch'intrate.%
11327 \footnote{\url{https://classicsincontext.wordpress.com/2010/02/28/canto-iii-per-me-si-va-ne-la-citta-dolente/}}
11328 \end{quote}
11329
11330
11331 \textbf{Big fat warning}: this material is reserved for \TeX-hackers; do not delve into this if you have no familiarity with (at least) a bit of core \TeX{} programming and to the basic \TikZ{} layer. You have been warned.
11332
11333 \subsection{Suggested setup}
11334 \label{sec:suggested-setup}
11335
11336 Notice: the source code has been reorganized after release 1.2.7; if you are bound to use an older version check the corresponding manual.
11337
11338 The suggested way to start working on a new component is to use the utilities of the \Circuitikz{} manual for checking and testing your device. Basically, find (or download) the source code of the last version of \Circuitikz{} and find the file \texttt{ctikzmanutils.sty}; copy it in your directory and prepare a file like this:
11339
11340 \begin{lstlisting}[keepspaces=true]
11341 \documentclass[a4paper, titlepage]{article}
11342 \usepackage{a4wide} %smaller borders
11343 \usepackage[utf8]{inputenc} %not needed since LaTeX 2019
11344 \usepackage[T1]{fontenc}
11345 \parindent=0pt
11346 \parskip=4pt plus 6pt minus 2pt
11347 \usepackage[siunitx, RPvoltages]{circuitikzgit}
11348 \usepackage{ctikzmanutils}
11349 \makeatletter
11350 %% Test things here
11351 % defines
11352
11353 % components
11354
11355 % paths
11356 \makeatother
11357
11358 \begin{document}
11359
11360 \circuitdescbip*{damper}{Mechanical damping}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
11361
11362 \geolrcoord{dampershape, fill=yellow}
11363
11364 \begin{ctikzExample}
11365 \begin{circuitikz}
11366 \draw (0,0) to[R] ++(2,0)
11367 to[damper] ++(2,0);
11368 \end{circuitikz}
11369 \end{ctikzExample}
11370 \end{document}
11371 \end{lstlisting}
11372
11373 This will compile to something like this (in this case, we are using a couple of existing components to check everything is OK):
11374
11375 \circuitdescbip*{damper}{Mechanical damping}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
11376
11377 \geolrcoord{dampershape, fill=yellow}
11378
11379 \begin{ctikzExample}
11380 \begin{circuitikz}
11381 \draw (0,0) to[R] ++(2,0)
11382 to[damper] ++(2,0);
11383 \end{circuitikz}
11384 \end{ctikzExample}
11385
11386 The command \verb|circuitdescbip*| is used to show the component description (you can check the definition and the usage looking at \texttt{ctikzmanutils.sty} file, and the \verb|\geolrcoord| is used to show the main anchors (geographical plus \texttt{left} and \texttt{right}) of the component.
11387
11388 From now on, you can add the new commands for the component between the \verb|\makeatletter| and \verb|\makeatother| commands and, modifying the example, check the results.
11389
11390 \subsection{Path-style component}
11391 \label{sec:path-style-component}
11392
11393 Let's define for example a path style component, like the one suggested by the user \texttt{@alex} on \href{https://tex.stackexchange.com/questions/484268/combined-spring-damper-in-circuitikz}{\TeX{} stackexchange site}. The component will be a mix of the \texttt{damper} and the \texttt{spring} components already present.
11394
11395 The definitions of the components are in the files \texttt{pgfcirc\emph{something}.tex}; they are more or less distributed by the number of terminals, but there are exceptions (for example, switches are in \texttt{bipoles}, even if several of them are tripoles or more\dots \texttt{grep} is your friend here.
11396
11397 To define the new component we will look into (in this case) \texttt{pgfcircbipoles.tex}; at the start of the block where the components are defined, you can find the relevant definitions (sometime some of the definitions are in \texttt{pgfcirc.defines.tex}, for historical or dependencies reasons).
11398 The first step is to check if we can use the definition already existing for similar elements (for coherence of size) or if we need to define new ones; for this you have to check into the we find
11399
11400 \begin{lstlisting}
11401 \ctikzset{bipoles/spring/height/.initial=.5}
11402 \ctikzset{bipoles/spring/width/.initial=.5}
11403 \ctikzset{bipoles/damper/height/.initial=.35}
11404 \ctikzset{bipoles/damper/length/.initial=.3}
11405 \ctikzset{bipoles/damper/width/.initial=.4}
11406 \end{lstlisting}
11407
11408 We will use them; at this stage you can decide to add other parameters if you need them. (Notice, however, than although flexibility is good, these parameters should be described in the manual, otherwise they're as good as a fixed number in the code).
11409
11410
11411 After that we will copy, for example, the definition of the damper into our code, just changing the name:
11412
11413 \begin{lstlisting}[keepspaces=true]
11414 %% mechanical resistor - damper
11415 \pgfcircdeclarebipolescaled{mechanicals}
11416 {} % extra anchors
11417 {\ctikzvalof{bipoles/damper/height}} % depth (under the path line)
11418 {viscoe} % name
11419 {\ctikzvalof{bipoles/damper/height}} % height (above the path line)
11420 {\ctikzvalof{bipoles/damper/width}} % width
11421 {
11422 \pgfpathrectanglecorners{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
11423 \pgf@circ@maybefill
11424
11425 % line into the damper
11426 \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
11427 \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
11428 {\pgf@circ@res@zero}}
11429 \pgfusepath{stroke}
11430
11431 % damper box
11432 \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
11433 \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
11434 \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
11435 \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
11436 \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
11437
11438 \pgfsetrectcap
11439 \pgfsetmiterjoin
11440 \pgfusepath{stroke}
11441
11442 % damper vertical element
11443 \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
11444 {.8\pgf@circ@res@down}}
11445 \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
11446 {.8\pgf@circ@res@up}}
11447 \pgfsetbuttcap
11448 \pgfusepath{stroke}
11449
11450 }
11451 \end{lstlisting}
11452
11453 This \verb|\pgfcircdeclarebipolescaled| command will define a shape that is named \texttt{viscoeshape}, with all the correct geographical anchors based on the depth, height and width defined in the parameters: in this case we are reusing the ones of the \texttt{damper} shape. Moreover, the element is assigned to the class \texttt{mechanicals} for styling.
11454
11455 To be coherent with the styling, you should use (when needed) the length \verb|\pgf@circ@scaled@Rlen| as the ``basic'' length for drawing, using the fill functions (they are defined at the start of the file \texttt{pgfcirc.defines.tex}) to fill and stroke --- so that the operation will follow the style parameters and, finally, use the macro \verb|\pgf@circ@setlinewidth| to set the line thickness: the first argument is the ``legacy'' class, if you do not want to assign one you can use the pseudo-legacy class \texttt{none}.
11456
11457 The anchors for the bipole (which then set the lengths \verb|\pgf@circ@res@left|) are already scaled for your use. You can use these lengths (which defines, normally, the geographical anchors of the element) to draw your shapes.
11458
11459 This is not sufficient for using the element in a \texttt{to[]} path command; you need to ``activate'' it (the definition of the commands are normally in \texttt{pgfcircpath.tex}). In this case the component is simple --- look at the definitions if you need to do more complex things.
11460
11461 \begin{lstlisting}
11462 \pgfcirc@activate@bipole@simple{l}{viscoe}
11463 \end{lstlisting}
11464
11465 In the definition above, the \texttt{\{l\}} parameter means that using the component like \texttt{to[viscoe=A]} will be equivalent to \texttt{to[viscoe, l=A]}; you can also use \texttt{v} or \texttt{i} or \texttt{f} if your component needs it.
11466 Now you can show it with:
11467
11468 \begin{lstlisting}
11469 \circuitdescbip*{viscoe}{Mechanical viscoelastic element}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
11470
11471 \geolrcoord{viscoeshape, fill=yellow}
11472
11473 \begin{ctikzExample}
11474 \begin{circuitikz}
11475 \draw (0,0) to[spring] ++(2,0)
11476 to[viscoe] ++(2,0);
11477 \end{circuitikz}
11478 \end{ctikzExample}
11479 \end{lstlisting}
11480
11481 Obviously, at first you just have a component that is the same as the one you copied with another name.
11482 It is now just a matter of modifying it so that it has the desired shape; in the example above you can already see the new symbol after the changes.
11483
11484 When doing the drawing in the main argument of the \verb|\pgfcircdeclarebipolescaled|, things will be set up so that the lengths \verb|\pgf@circ@res@right|
11485 and \verb|\pgf@circ@res@up| are the $x$-$y$ coordinates of the upper right corner, and
11486 \verb|\pgf@circ@res@left| and \verb|\pgf@circ@res@down| are the $x$-$y$ coordinates of the lower left corner of your shape. The \texttt{center} coordinate is usually at $(0pt, 0pt)$.
11487
11488 Looking at the implementation of the \texttt{spring} element, one possibility is changing the lines between lines~12 and~16 with:
11489
11490 \begin{lstlisting}
11491 % spring into the damper
11492 \pgfscope
11493 \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
11494 \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
11495 \pgfsetcornersarced{\pgfpoint{.25\pgf@circ@res@up}{.25\pgf@circ@res@up}}
11496 \pgfpathlineto{\pgfpoint{.75\pgf@circ@res@left}{.75\pgf@circ@res@up}}
11497 \pgfpathlineto{\pgfpoint{.5\pgf@circ@res@left}{-.75\pgf@circ@res@up}}
11498 \pgfpathlineto{\pgfpoint{.25\pgf@circ@res@left}{.75\pgf@circ@res@up}}
11499 \pgfpathlineto{\pgfpoint{0pt}{-.75\pgf@circ@res@up}}
11500 \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{.75\pgf@circ@res@up}}
11501 \pgfusepath{stroke}
11502 \endpgfscope
11503 \end{lstlisting}
11504
11505 which leads to:
11506
11507 \circuitdescbip*{viscoe}{Mechanical viscoelastic element}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
11508
11509 \geolrcoord{viscoeshape, fill=yellow}
11510
11511 \begin{ctikzExample}
11512 \begin{circuitikz}
11513 \draw (0,0) to[spring] ++(2,0)
11514 to[viscoe] ++(2,0);
11515 \end{circuitikz}
11516 \end{ctikzExample}
11517
11518 Now you can check if the voltage labels are correct for your new component:
11519
11520 \begin{ctikzExample}
11521 \begin{circuitikz}[]
11522 \draw (0,0) to[spring] ++(2,0)
11523 to[viscoe, v=V] ++(2,0);
11524 \end{circuitikz}
11525 \end{ctikzExample}
11526
11527 If you think they are too tight or too loose, you can use a (developer-only) key to adjust the distance:
11528
11529 \begin{ctikzExample}
11530 \begin{circuitikz}
11531 \ctikzset{bipoles/viscoe/voltage/additional shift/.initial=1}
11532 \draw (0,0) to[spring] ++(2,0)
11533 to[viscoe, v=V] ++(2,0);
11534 \end{circuitikz}
11535 \end{ctikzExample}
11536
11537 Notice that by default the key \texttt{bipoles/\emph{mybipole}/voltage/additional shift} is not defined, so if you want to use it you must create it before (this is the meaning of the \texttt{.initial} here).
11538
11539 Now you can save all the code between the \verb|\makeatletter| and \verb|\makeatother| in a file and \verb|\input{}| it for using your special component, or submit the component to the project (see below).
11540
11541 As a final note, notice that the \texttt{viscoe} element is already added to the standard package.
11542
11543 \subsection{Node-style component}
11544 \label{sec:node-style-component}
11545
11546 Adding a node-style component is much more straightforward. Just define it by following examples in, for example, \texttt{pgfcirctripoles.tex} or the other files; be careful that you should define all the geographical anchors of the shape if you want that the \TikZ{} positioning options (like \texttt{left}, \texttt{above}, etc.) behave correctly with your component.
11547
11548 To have a scalable component, for example in the \texttt{transistors} class, you should use something like
11549 \begin{lstlisting}
11550 \savedmacro{\ctikzclass}{\edef\ctikzclass{transistors}}
11551 \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
11552 \end{lstlisting}
11553 at the start of anchors and macros definition, and use (for example, the exact code will change greatly depending on your component):
11554 \begin{lstlisting}
11555 \savedanchor\northeast{% upper right
11556 \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
11557 \pgf@y=\pgf@circ@scaled@Rlen
11558 \pgf@y=0.5\pgf@y
11559 \pgf@x=0.3\pgf@y
11560 }
11561 \end{lstlisting}
11562 in all the \texttt{savedanchors}.
11563
11564 Then, to draw your component, you should start with\footnote{Since \texttt{v1.5.0}; component defined with this mechanism will not be compatible with older \Circuitikz{}.}:
11565 \begin{lstlisting}
11566 \pgf@circ@draw@component{%
11567 \pgf@circ@scaled@Rlen=\scaledRlen
11568 ...
11569 }
11570 \end{lstlisting}
11571 and then use \verb|\pgf@circ@scaled@Rlen| (or the anchors) as the default length while you draw it.
11572
11573 The special command \verb|\pgf@circ@draw@component| will issue a \texttt{\textbackslash behindforegroundpath} command, and take care of calling the start and end hooks for the component. Notice that, given the use of \texttt{\textbackslash behindforegroundpath}, you must take care to use the path you define here! The path itself is protected bu a \texttt{pgfscope} (and so also by a \TeX{} group), so local definitions will be reset after exiting.
11574
11575 \subsubsection{The internal hook system}\label{sec:drawing-hooks}
11576
11577 Since version \texttt{v1.5.0}, before starting the drawing of any component, \Circuitikz{} will check for the existence of three different hooks, in the following order (suppose that the shape name is \texttt{\emph{myname}}, and it has a class \texttt{\emph{myclass}}:
11578 \begin{itemize}
11579 \item \texttt{\textbackslash ctikz@hook@start@draw@component@\emph{myname}}
11580 \item \texttt{\textbackslash ctikz@hook@start@draw@class@\emph{myclass}}
11581 \item \texttt{\textbackslash ctikz@hook@start@draw@default}
11582 \end{itemize}
11583 The first one that is defined in the current (or outer) scope is used, and the following ones are not used. These hooks can be used to set drawing parameters, or to reset them to a known state: \TikZ{} normally inherit most of the drawing option, but that can lead to surprises (like unexpected arrows, etc.).
11584
11585 In the same way, before leaving \verb|\pgf@circ@draw@component|, a set of similar hooks (with \texttt{end} instead of \texttt{start}) is tried, with the same logic.
11586
11587 The only predefined hook is \texttt{\textbackslash ctikz@hook@start@draw@default}, which is set to the equivalent of:
11588 \begin{lstlisting}
11589 \pgfsetshortenstart{+0pt}\pgfsetshortenend{+0pt}\pgfsetarrows{-}%
11590 \def\pgf@circ@reset@rounded{\pgfsetcornersarced{\pgfpointorigin}}%
11591 \end{lstlisting}
11592 which means that, by default, arrows parameters are reset to the default (no shorten, no arrows) and that corners are not rounded. If you want to override them, just define the appropriate hook for your component/class and the generic one will not be called.
11593
11594 No \texttt{...@end@draw@...} hook is defined by default.
11595
11596 \subsubsection{Finishing your work}
11597 \label{sec:finishing-your-work}
11598
11599 Once you have a satisfactory element, you should
11600 \begin{itemize}
11601 \item Clean up your code;
11602 \item write a piece of documentation explaining its use, with an example;
11603 \item Propose the element for inclusion in the GitHub page of the project (you will have to license this as explained in that page, of course).
11604 \end{itemize}
11605
11606 The best way of contributing is forking the project, adding your component in the correct files, modifying the manual and creating a pull request for the developers to merge. Anyway, if this is a problem, just open an issue and someone (when they have time\dots) will answer.
11607
11608 \section{Examples}
11609 \label{sec:examples}
11610
11611 Here a series of examples, contributed by several people, is shown with their code.
11612
11613 \subsection{A red diode}
11614 \label{sec:a-red-diode}
11615
11616 \begin{ctikzExample}[pos=t,varwidth=true]
11617 \begin{circuitikz}[scale=1.4]\draw
11618 (0,0) to[C, l=10<\micro\farad>] (0,2) -- (0,3)
11619 to[R, l=2.2<\kilo\ohm>] (4,3) -- (4,2)
11620 to[L, l=12<\milli\henry>, i=$i_1$,v=b] (4,0) -- (0,0)
11621 (4,2) to[D*, color=red] (2,0)
11622 (0,2) to[R, l=1<\kilo\ohm>, *-] (2,2)
11623 to[cV, i=1, -*, v=$\SI{.3}{\kilo\ohm}\, i_1$] (4,2)
11624 (2,0) to[I, i=1<\milli\ampere>, *-*] (2,2)
11625 ;\end{circuitikz}
11626 \end{ctikzExample}
11627
11628 \newpage
11629 \subsection{Using the (experimental) \texttt{siunitx} syntax}
11630 \label{sec:using-the-experimental}
11631
11632 \begin{ctikzExample}[pos=t,varwidth=true]
11633 \begin{circuitikz}[scale=1.2]\draw
11634 (0,0) node[ground] {}
11635 to[V=$e(t)$, *-*] (0,2) to[C=4<\nano\farad>] (2,2)
11636 to[R, l_=.25<\kilo\ohm>, *-*] (2,0)
11637 (2,2) to[R=1<\kilo\ohm>] (4,2)
11638 to[C, l_=2<\nano\farad>, *-*] (4,0)
11639 (5,0) to[I, i_=$a(t)$, -*] (5,2) -- (4,2)
11640 (0,0) -- (5,0)
11641 (0,2) -- (0,3) to[L, l=2<\milli\henry>] (5,3) -- (5,2)
11642
11643 {[anchor=south east] (0,2) node {1} (2,2) node {2} (4,2) node {3}}
11644 ;
11645 \end{circuitikz}
11646 \end{ctikzExample}
11647
11648
11649 \begin{ctikzExample}[pos=t,varwidth=true]
11650 \begin{circuitikz}[scale=1.2]\draw
11651 (0,0) node[anchor=east] {B}
11652 to[short, o-*] (1,0)
11653 to[R=20<\ohm>, *-*] (1,2)
11654 to[R=10<\ohm>, v=$v_x$] (3,2) -- (4,2)
11655 to[cI=$\frac{\si{\siemens}}{5} v_x$, *-*] (4,0) -- (3,0)
11656 to[R=5<\ohm>, *-*] (3,2)
11657 (3,0) -- (1,0)
11658 (1,2) to[short, -o] (0,2) node[anchor=east]{A}
11659 ;\end{circuitikz}
11660 \end{ctikzExample}
11661
11662 \newpage
11663 \subsection{Photodiodes}
11664 \label{sec:photodiodes}
11665
11666 \begin{ctikzExample}[pos=t,varwidth=true]
11667 \begin{circuitikz}[scale=1]\draw
11668 (0,0) node[transformer] (T) {}
11669 (T.B2) to[pD] ($(T.B2)+(2,0)$) -| (3.5, -1)
11670 (T.B1) to[pD] ($(T.B1)+(2,0)$) -| (3.5, -1)
11671 ;\end{circuitikz}
11672 \end{ctikzExample}
11673
11674 \subsection{A Sallen-Key cell}
11675 \label{sec:a-sallen-key}
11676
11677 \begin{ctikzExample}[pos=t,varwidth=true]
11678 \begin{circuitikz}[scale=1]\draw
11679 (5,.5) node [op amp] (opamp) {}
11680 (0,0) node [left] {$U_{we}$} to [R, l=$R_d$, o-*] (2,0)
11681 to [R, l=$R_d$, *-*] (opamp.+)
11682 to [C, l_=$C_{d2}$, *-] ($(opamp.+)+(0,-2)$) node [ground] {}
11683 (opamp.out) |- (3.5,2) to [C, l_=$C_{d1}$, *-] (2,2) to [short] (2,0)
11684 (opamp.-) -| (3.5,2)
11685 (opamp.out) to [short, *-o] (7,.5) node [right] {$U_{wy}$}
11686 ;\end{circuitikz}
11687 \end{ctikzExample}
11688
11689 \newpage
11690 \subsection{Mixing circuits and graphs}
11691 \label{sec:mixing-circuits-and}
11692
11693 \begin{ctikzExample}[pos=t,varwidth=true]
11694 \begin{circuitikz}[scale=1.2, american]\draw
11695 (0,2) to[I=1<\milli\ampere>] (2,2)
11696 to[R, l_=2<\kilo\ohm>, *-*] (0,0)
11697 to[R, l_=2<\kilo\ohm>] (2,0)
11698 to[V, v_=2<\volt>] (2,2)
11699 to[cspst, l=$t_0$] (4,2) -- (4,1.5)
11700 to [generic, i=$i_1$, v=$v_1$] (4,-.5) -- (4,-1.5)
11701 (0,2) -- (0,-1.5) to[V, v_=4<\volt>] (2,-1.5)
11702 to [R, l=1<\kilo\ohm>] (4,-1.5);
11703
11704 \begin{scope}[xshift=6.5cm, yshift=.5cm]
11705 \draw [->] (-2,0) -- (2.5,0) node[anchor=west] {$v_1/\si{\volt}$};
11706 \draw [->] (0,-2) -- (0,2) node[anchor=west] {$i_1/\si{\milli\ampere}$} ;
11707 \draw (-1,0) node[anchor=north] {-2} (1,0) node[anchor=south] {2}
11708 (0,1) node[anchor=west] {4} (0,-1) node[anchor=east] {-4}
11709 (2,0) node[anchor=north west] {4}
11710 (-1.5,0) node[anchor=south east] {-3};
11711 \draw [thick] (-2,-1) -- (-1,1) -- (1,-1) -- (2,0) -- (2.5,.5);
11712 \draw [dotted] (-1,1) -- (-1,0) (1,-1) -- (1,0)
11713 (-1,1) -- (0,1) (1,-1) -- (0,-1);
11714 \end{scope}
11715 \end{circuitikz}
11716 \end{ctikzExample}
11717
11718 \newpage
11719 \subsection{RF circuit}
11720 \label{sec:rf-circuit}
11721
11722 \begin{ctikzExample}[pos=t,varwidth=true]
11723 \begin{circuitikz}[scale=1]
11724 \ctikzset{bipoles/detector/width=.35}
11725 \ctikzset{quadpoles/coupler/width=1}
11726 \ctikzset{quadpoles/coupler/height=1}
11727 \ctikzset{tripoles/wilkinson/width=1}
11728 \ctikzset{tripoles/wilkinson/height=1}
11729 %\draw[help lines,red,thin,dotted] (0,-5) grid (5,5);
11730 \draw
11731 (-2,0) node[wilkinson](w1){}
11732 (2,0) node[coupler] (c1) {}
11733 (0,2) node[coupler,rotate=90] (c2) {}
11734 (0,-2) node[coupler,rotate=90] (c3) {}
11735 (w1.out1) .. controls ++(0.8,0) and ++(0,0.8) .. (c3.port3)
11736 (w1.out2) .. controls ++(0.8,0) and ++(0,-0.8) .. (c2.port4)
11737 (c1.port1) .. controls ++(-0.8,0) and ++(0,0.8) .. (c3.port2)
11738 (c1.port4) .. controls ++(-0.8,0) and ++(0,-0.8) .. (c2.port1)
11739 (w1.in) to[short,-o] ++(-1,0)
11740 (w1.in) node[left=30] {LO}
11741 (c1.port2) node[match,yscale=1] {}
11742 (c1.port3) to[short,-o] ++(1,0)
11743 (c1.port3) node[right=30] {RF}
11744 (c2.port3) to[detector,-o] ++(0,1.5)
11745 (c2.port2) to[detector,-o] ++(0,1.5)
11746 (c3.port1) to[detector,-o] ++(0,-1.5)
11747 (c3.port4) to[detector,-o] ++(0,-1.5)
11748 ;
11749 \end{circuitikz}
11750 \end{ctikzExample}
11751
11752 \subsection{A styled low noise input stage}
11753 \label{sec:a-styled-low}
11754
11755 \begin{ctikzExample}[pos=t, box=hbox, dollar]
11756 \ctikzloadstyle{romano}
11757 \scalebox{0.707}{%
11758 \begin{circuitikz}[american, romano circuit style]
11759 \ctikzset{bipoles/cuteswitch/thickness=0.5}
11760 \draw (0,0) node[ground](GND0){} to[sV, l=$v_{cm}$] ++(0,1)
11761 to [R, l=$R_c$, -*] ++(0,1.5) coordinate(vcm) --++(0,0.5) coordinate(diffc);
11762 \draw (diffc) -| ++(-0.5, 0.5) to[sV,l=$v_+$, name=vplus] ++(0,1) --++(0,2)
11763 -- ++(2.5,0) coordinate(skin+ a) to[battery2, l=$E_+$, name=eplus] ++(1,0)
11764 to[R=$R_+$, name=rplus] ++(2,0) coordinate(skin+ b) -- ++(0.5,0)
11765 -- ++(4,0) coordinate(hpin+) to[highpass] ++(2,0)
11766 node[inst amp, anchor=+, noinv input up,
11767 circuitikz/amplifiers/scale=1.6,
11768 circuitikz/tripoles/inst amp/width=1](LNA){LNA}
11769 (LNA.out);
11770 \coordinate (skin- a) at (LNA.- -| skin+ a);
11771 \draw (diffc) -| ++(0.5,0.5) to[sV,l_=$v_-$, name=vminus] ++(0, 1) |- (skin- a);
11772 \draw (skin- a) to[battery2, l_=$E_-$, name=eminus] ++(1,0)
11773 to[R, l_=$R_-$, name=rminus] ++(2,0) coordinate(skin- b) -- ++(2.5,0)
11774 -- (skin- b -| hpin+) to[highpass] (LNA.-);
11775 \coordinate (gnd a) at (vcm -| skin+ a);
11776 \draw (vcm) -- (gnd a) to[battery2, l_=$E_\mathrm{gnd}$, name=egnd] ++(1,0)
11777 to[R, l_=$R_\mathrm{gnd}$, name=rgnd] ++(2,0) coordinate(gnd b);
11778 % switch set
11779 \def\swdown{-3.2}
11780 \draw (skin- b) ++(1,0) coordinate(sw1) to[cosw, invert, mirror, l=1, *-, name=s1] ++(0,\swdown) to[short, -*] ++(0, -1.5);
11781 \draw (sw1) ++(1,0) coordinate(sw2) to[cosw, invert, mirror, l=2, *-] ++(0,\swdown) to[R=$R$, -*] ++(0, -1.5);
11782 \draw (sw2|-skin+ b) ++(1,0) coordinate(sw3) to[short, *-] (sw3|-sw2) to[cosw, invert, mirror, l=3,] ++(0,\swdown) to[R=$R$, -*] ++(0, -1.5);
11783 \draw (sw3) ++(1,0) coordinate(sw4) to[short, *-] (sw4|-sw2) to[cosw, invert, mirror, l=4, name=s4] ++(0,\swdown) to[short] ++(0, -1.5) coordinate(endsw);
11784 \draw (gnd b) |- (endsw) node[rectjoinfill]{};
11785 % boxes
11786 \node [rectangle, draw, dashed, fit=(GND0) (vplus) (vpluslabel) (vminuslabel)](body){};
11787 \node [anchor=south east, align=center] at (body.south east) {Body} ;
11788 \node [rectangle, draw, dashed, fit=(rplus) (eplus) (epluslabel) (rpluslabel)](top){};
11789 \node [rectangle, draw, dashed, fit=(eminus) (rminus) (eminuslabel) (rminuslabel)](bot){};
11790 \node [anchor=center, align=center] at ($(top.south)!0.5!(bot.north)$) {electrodes} ;
11791 \node [rectangle, draw, dashed, fit=(egnd) (rgnd) (egndlabel) (rgndlabel)](gnd){};
11792 \node [below, align=center] at (gnd.south) {ground\\ electrode} ;
11793 \node [rectangle, draw, dashed, fit=(s1) (s4label), inner ysep=8pt](switches){};
11794 % ADC and micro
11795 \draw (LNA.out) -- ++(0.5,0) node[msport,circuitikz/RF/scale=2](ADC){ADC};
11796 \draw (ADC.right) -- ++(0.5,0) node[twoportshape, anchor=left, t=$\upmu$C](uC){};
11797 \draw (uC.south) -- (uC.south |- switches.east) -- ++(-4,0)
11798 node[align=left, anchor=east](DCS){\small digitally\\ controlled\\ switches};
11799 \draw[-Stealth] (DCS.west) -- (switches.east);
11800 % components
11801 \node [anchor=north west] at ([xshift=-10pt, yshift=-5pt]switches.south east) {ADG1414};
11802 \node [anchor=north west] at ([yshift=-5pt]LNA.refv down) {AD8429};
11803 \end{circuitikz}
11804 } % scalebox
11805 \end{ctikzExample}
11806
11807 \subsection{An example with the \texttt{compatibility} option}
11808 \label{ex:compatibility}
11809
11810 \IfFileExists{compatibility.pdf}{\fbox{\includegraphics{compatibility.pdf}}}{}
11811
11812 \begin{lstlisting}
11813 \documentclass{standalone}
11814
11815 \usepackage{tikz}
11816 \usetikzlibrary{circuits.ee.IEC}
11817 \usetikzlibrary{positioning}
11818
11819 \usepackage[compatibility]{circuitikzgit}
11820 \ctikzset{bipoles/length=.9cm}
11821
11822 \begin{document}
11823 \begin{tikzpicture}[circuit ee IEC]
11824 \draw (0,0) to [resistor={name=R}] (0,2)
11825 to[diode={name=D}] (3,2);
11826 \draw (0,0) to[*R=$R_1$] (1.5,0) to[*Tnpn] (3,0)
11827 to[*D](3,2);
11828 \end{tikzpicture}
11829 \end{document}
11830 \end{lstlisting}
11831
11832 \newpage
11833 \subsection{3-phases block schematic}
11834 \label{sec:3-phases-block}
11835
11836 \begin{ctikzExample}[varwidth=true,pos=t]
11837 \begin{circuitikz}[smallR/.style={european resistor, resistors/scale=0.5}]
11838 \draw (0,0) node[tacdcshape, anchor=ac mid in](acdc){} to[smallR] ++(-2,0)
11839 -- coordinate(point) node[circ](){} ++(-.5,0);
11840 \draw (acdc.ac up in)
11841 to[nos, invert, mirror, name=switch,color=red] ++(-2,0)
11842 -- (point);
11843 \draw (acdc.ac down in) to[smallR] ++(-2,0)
11844 -- (point)
11845 to[oosourcetrans,prim=wye,sec=delta,l=transformer] ++(-1.5,0)
11846 to[tmultiwire] ++(-.5,0)
11847 node[gridnode, anchor=right]{};
11848 \node[above=.3cm,color=red] at (switch) {fault};
11849 \draw (acdc.dc up out) to[smallR,l=HVDC line] ++(2,0 )
11850 node[tdcacshape, anchor=dc up in](dcac){};
11851 \draw (acdc.dc down out) -- (dcac.dc down in);
11852 \draw (dcac.right)
11853 to[ooosource,prim=delta,sec=delta,tert=wye,invert] ++(1.5,0)
11854 to[tmultiwire] ++(.5,0) node[gridnode,anchor=left]{};
11855 \end{circuitikz}
11856 \end{ctikzExample}
11857
11858 \newpage
11859 \subsection{Using components in \texttt{pic}s (since \texttt{v1.8.0})}\label{sec:example-pics}
11860
11861 \begin{ctikzExample}[varwidth=true,pos=t]
11862 \tikzset{mypic/.pic = {
11863 \draw (0,0) coordinate(-in)
11864 % unnamed component
11865 to[R=#1] ++(2,1)
11866 % named component
11867 to[leD*, diodes/scale=0.6, led arrows from cathode,
11868 name=-led, l=label, v]
11869 ++(2,-1) coordinate(-out);
11870 }
11871 }
11872 \begin{tikzpicture}
11873 \ctikzset{voltage=raised}
11874 \draw (0,0) to[R] ++(2,1);
11875 \begin{scope}[xshift=2cm,
11876 name prefix=inner-
11877 ]
11878 \draw (0,0) to[R, name=r, i<] ++(2,1);
11879 \end{scope}
11880 \draw (4,0) pic(P){mypic=PR};
11881 \node[circ] at (inner-r) {};
11882 \node[circ, cyan] at (inner-r-Ipos) {};
11883 \node[circ, red] at (P-led) {};
11884 \node[circ, blue] at (P-ledlabel) {};
11885 \node[circ, green] at (P-led-Vto) {};
11886 \node[circ, purple] at (P-led-Vfrom) {};
11887 \draw (4,0) pic[rotate=-60, scale=0.7, transform shape](P2){mypic=P2R};
11888 \node[circ, red] at (P2-led) {};
11889 \node[circ, blue] at (P2-ledlabel) {};
11890 \node[circ, green] at (P2-led-Vto) {};
11891 \node[circ, purple] at (P2-led-Vfrom) {};
11892 %% extra data
11893 \node[right] at (0, -1) {DIR: \ctikzgetdirection{inner-r}};
11894 \node[right] at (0, -1.5) {ANC: \ctikzgetanchor{P-led}{Vlab}};
11895 \node[right] at (0, -2) {Iarr: \ctikzgetdirection{inner-r-Iarrow}};
11896 \node[right] at (0, -2.5) {LAB: \ctikzgetdirection{P2-ledlabel}};
11897 \end{tikzpicture}
11898 \end{ctikzExample}
11899
11900 \newpage
11901 \subsection{Automatic user-defined voltages, currents and flows (since \texttt{v1.8.5})}%
11902 \label{sec:example-auto-vif}
11903
11904
11905 \begin{ctikzExample}
11906 [varwidth=true,pos=t, basicstyle=\footnotesize\ttfamily, dollar]
11907 %% This can go to your preamble and/or a style file!
11908 %% setup voltage drawing macro: european style, but adding "+" and "-"
11909 \newcommand\eurVPMstyled[4]{% node, label, style, one ignored arguments
11910 \draw [thin, -{Stealth[width=4pt]}, shorten >=5pt, shorten <=5pt, #3]
11911 % NOTICE that boldmath requires double braces to work in nodes
11912 % see https://tex.stackexchange.com/q/487777/38080
11913 (#1-Vfrom) node[font=\tiny]{{\boldmath$\vphantom{+}-$}}
11914 .. controls (#1-Vcont1) and (#1-Vcont2)..
11915 (#1-Vto) node[font=\tiny]{{\boldmath$+$}}
11916 node[pos=0.5,anchor=\ctikzgetanchor{#1}{Vlab}]{#2};
11917 }
11918 % voltage shift must go after the "european voltage, v" pair
11919 \ctikzset{vpms/.style 2 args={european voltages, v, voltage shift=2,
11920 vif queue add={eurVPMstyled}{#1}{#2}{}}}
11921 \ctikzactivatevoltagedirections{vpms}
11922 % setup flow drawing macro: squiggle for power flux
11923 %% requires \usetikzlibrary{decorations, decorations.pathmorphing}
11924 \tikzset{ lray/.style={decorate, decoration={
11925 snake, amplitude=2pt,pre length=1pt,post length=2pt, segment length=5pt,},
11926 -Triangle}}
11927 \newcommand\flowpow[4]{% node, label, color
11928 \draw [lray, #3 ] (#1-Ffrom) -- (#1-Fto)
11929 node [anchor=\ctikzgetanchor{#1}{Flab}, inner sep=4pt]
11930 at (#1-Fpos) {#2};}
11931 \ctikzset{fpow/.style 2 args={f, vif queue add={flowpow}{#1}{#2}{}}}
11932 \ctikzactivateflowdirections{fpow}
11933 % setup current drawing macros: 6 mm with Stealth arrow on the line, dark green
11934 \newcommand{\inlinecurrent}[4]{% node, label
11935 \draw [-{Stealth[scale=1.5]}, thick, color=green!50!black]
11936 ($(#1-Ipos)!3mm!(#1-Ifrom)$) -- ($(#1-Ipos)!3mm!(#1-Ito)$)
11937 node [midway, inner sep=6pt, anchor=\ctikzgetanchor{#1}{Ilab}] {#2};
11938 }
11939 \ctikzset{iline/.style ={i, vif queue add={inlinecurrent}{#1}{}{}}}
11940 \ctikzactivatecurrentdirections{iline}
11941 %% setup end
11942 %
11943 % Let's draw our circuit!
11944 %
11945 % % "use auto vif" only needed if using old (before 2020) LaTeX or Plain or ConTeXt
11946 \begin{circuitikz}[use auto vif]
11947 \draw (0,0) to[R=$R_1$, iline={$i$}, vpms={$v_1$}{dashed}] ++(4,0)
11948 to[R, l_=$R_2$, vpms^>={$v_2$}{blue}, fpow_={$P$}{red}] ++(4,0)
11949 to[L=$L$, i=$i$, v=$v_L$, f>^=$P_L$] ++(4,0); % traditional still working!
11950 \end{circuitikz}
11951 \end{ctikzExample}
11952
11953
11954 % % changelog.tex will be updated by makefile from CHANGELOG.md
11955 \section{Changelog and Release Notes}
11956 \label{sec:changelog-and-release}
11957 \IfFileExists{changelog.tex}
11958 {\sloppy\input{changelog.tex}}
11959 {The file changelog.tex was not found, run 'make changelog' at toplevel to generate it with pandoc from CHANGELOG.md}
11960
11961 \printindex
11962
11963 \end{document}
11964 % vim: set fdm=marker fmr=%<<<,%>>>: