Similar to CircuiTikZ — create new component
I am using circuitikz to create an electric circuit diagram.
I have found the preset symbol for the zener diode to be different to the symbol I wish to use to represent the zener diode.
I have constructed the following code in tikz
to display the symbol i wish to use.
My question is, How can I store this as a component, to recalled with [nzD]
like the preset symbols, so that it works in a circuit.
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{5mm}
\usepackage{tikz}
\usepackage{circuitikz}
\title{New Zener Diode}
\begin{document}
\begin{preview}
\centering
\begin{circuitikz}
\draw (0,0) --(0.22,0) to [open] (0.78,0)-- (1,0) ; % connecting wires
\draw [thick](0.22,0)--(0.22,0.35)--(0.78,0)--(0.22,-0.35)--(0.22,0) % triangle
(0.84,0.35)--(0.78,0.35)--(0.78,-0.35)--(0.72,-0.35) ; % vertical
%\draw (0,0) to [zD] (1,0) ; % preset zener diode
\end{circuitikz}
\end{preview}
\end{document}
Best Answer
The file
circuitikz1.code.tex
holds all style definition for the Zener diodezD
and its variantzD*
andzDo
as well as the long formsZener diode
,empty Zener diode
andfull Zener diode
.(The
zD
andZener diode
styles switch dynamically to empty or full diodes depending on the styles/optionsempty diodes
/emptydiodes
orfull diodes
/fulldiodes
respectively.)These styles are copied to make a
new
Zener diode family. As we want to use this shape on paths we also need to define a set ofpath
s. These are simply copied from the old Zener diode family and are adjusted to match the new shapes.The actual shape re-definition happens with the
\pgfcircledeclarebipole
macro. Again, these definitions are copied from thepgfcircbipoles.sty
file: The names are changed (I added ann
).The first path is the path of the triangle, the second path is the path of the line thing in front of it.
Notice the additional
.8
in the\pgfpathmoveto
line? That’s it!Code
Output