SVG Circuit_macros examples, Version 9.6.4


This file shows diagrams in .svg format; png versions are also available. The PDF equivalent can be found in examples.pdf of the distribution.

The diagrams shown below have been adapted from the Circuit_macros examples in order to test the svg output of dpic. Generating svg line art is straightforward, but TeX, LaTeX, and related word processors do not produce svg. Either less-sophisticated text formatting must be employed or an intermediate format such as pdf can be produced, followed by an additional processing step to convert to svg. Two possibilities for the latter are dvisvgm and pdf2svg although there may be font-related issues for some diagrams.
Many circuit and similar diagrams intended for the web do not require sophisticated labels, however; the examples shown below might be representative.

Click on the link to view the source of each diagram.


There are a number of other issues:

  • Embedding .svg files in html documents with the <embed> or <object> tag seems to be a perennial issue.
  • This file has been tested mainly by using Firefox.
  • The Adobe reader apparently requires a line of the form
    <embed src="figure.svg" width="x" height="y" type="image/svg+xml" /> This means that the html file has to contain dimension information for each figure, whereas Firefox can determine the figure size from the <svg ... object. Currently, dpic includes a comment line giving reasonable dimensions in pixels but this has to be insterted into the <embed or <object line. A makefile does it easily but otherwise this could be tedious.
  • The default font face is not specified in all of these diagrams but is inherited from the enclosing document, so the appearance of labels can differ depending on the browser. Some of these diagrams set the font at the beginning of the diagram source.
  • The <svg tag may require modification from the default used for this test. Dpic might be modified to allow the generation of custom headers but that has not been done.
  • Diagrams such as these contain text labels that have to be treated differently from the LaTeX-compatible versions. Apparently there is no direct way to know the bounding box of arbitrary svg text. Consequently, text placement is approximate and may require manual adjustment. Rather than patch the original source files for svg production, edited copies have been used. The configuration file svg.m4 read by m4 prior to libcct.m4 contains the following macros defined for svg. Others could be defined to exercise some of the media capabilties of svg. They are subject to change:
    • svg_font(font-face,nominal size[:dptextratio],textoffset, dpic commands): Change font face, size, textratio and dpic textoffset parameters. Change font face and dpic textht, dptextratio, and textoffset parameters. If arg4 is blank, the font is changed and requires command "</g>" to cancel the font change.
      Note: Nominal height = text height in drawing units; actual height = nominal ht x dptextratio.
      Examples:
      svg_font(Times)
      svg_font(Times,14bp__)
      svg_font(sans-serif,14bp__:0.71)
      svg_font(Times,11bp__,1bp__,"text" at A)
      svg_font(font-family="Times")
      svg_font(font-family="Times" font-style="italic")
      svg_font(style="font-family:Times; font-style:italic")
    • svgfontratio(font name); Reasonable dptextratio value for common fonts, used by svg_font.
    • svg_tspan(text attributes, text); e.g. svg_tspan(font-style="italic" font-size="75%",XYZ)
    • svg_it(text): for italics
    • svg_tt(text): for monospace (courier)
    • svg_sf(text): sans-serif (Helvetica)
    • svg_norm(text): for normal text
    • svg_bf(text): for bold face
    • svg_small(text, percent): to set a smaller text size, default 66
    • svg_fsize(text, percent): for setting larger or smaller text size, default 100
    • svg_sub(text, size percent, y displ, x displ): subscript
    • svg_ul(text): underlined text
    • svg_ol(text): overlined text
    • svg_sup(text, size percent, y displ, x displ): superscript
    • svg_hat(character): circumflex-accented character
    • svg_frac(numerator[:wid], denominator[:wid]): basic fraction, wid in drawing units
    • svg_rot(degrees, "text" [at position]): Rotate text degrees (default 90) ccw. Requires svg_rot_init(filename) and the source must be processed twice.
    • svg_rot_init(filename): filename is the basename of the output of dpic -v filename.pic > filename.svg
    • svg_symbol(text): allow quoted pound sign in text, e.g., svg_symbol(10&`#'176;) produces 10°
    • svgLink(URL, drawing object, [B]): link to external file using <a xlink:href=...>...</a> (default is target="_blank" unless arg 3 = B)
    • svgLinkString as above but for strings attached to objects
    • Greek and other symbols:
      svg_alpha α svg_beta β svg_Gamma Γ svg_gamma γ svg_Delta Δ svg_delta δ svg_epsilon ε svg_zeta ζ
      svg_eta η svg_Theta Θ svg_theta θ svg_iota ι svg_kappa κ svg_Lambda Λ svg_lambda λ svg_mu μ
      svg_nu ν svg_Xi Ξ svg_xi ξ svg_Pi Π svg_pi π svg_rho ρ svg_Sigma Σ svg_sigma σ
      svg_tau τ svg_upsilon υ svg_Phi Φ svg_phi φ svg_chi χ svg_Psi Ψ svg_psi ψ svg_Omega Ω
      svg_omega ω svg_micro μ svg_ohm Ω svg_lt < svg_gt > svg_leq svg_geq svg_prime
      svg_backsl \ svg_pound # svg_comma , svg_lparen ( svg_rparen ) svg_circ ˆ svg_deg ° svg_grave `
      svg_emsp | | svg_ensp | | svg_thinsp | |
  • Inkscape: It may be efficient to define elements by macro and to place them using a wysiwyg graphics editor. A draft page intended for Inkscape is included. A reasonable variety of elements is defined but many more could be added and they should be customized for particular applications. Adjustments may also have to be made to obtain the proper snap-to actions.
  • Link experiments: Click on the resistor or source of quickSVG to go to external files in new windows. Click on "n-port" in NportSVG to replace the diagram and then "back" to return.
  • Some of the assumptions used to create this draft may be naïve. Comments are welcome.



quickSVG.m4: SVG produced by dpic  



quick.m4: SVG produced from quick.pdf by dvisvgm  




ResistorsSVG.m4: Resistors  




CapacitorsSVG.m4: Capacitors  




InductorsSVG.m4: Inductors  




MoreTableSVG.m4: Some other two-terminal elements  




DiodesSVG.m4: Diodes: a K in the second argument draws an open arrowhead  




EmarrowsSVG.m4: Radiation arrows  




SourcesSVG.m4: Sources and source-like elements  




VariableSVG.m4: Arrows and marks indicating variability  




AmpTableSVG.m4: Macros amp, delay, and integrator




FusesSVG.m4: Macros fuse and cbreaker




SwitchesSVG.m4: The switch macros; switch(,,,L|B|D) is a wrapper for lswitch, bswitch, and dswitch




GroundsSVG.m4: Ground symbols  




AntennasSVG.m4: Antenna symbols  




AudioSVG.m4: Audio elements  




OpampSVG.m4: The opamp  




XformSVG.m4: The transformer element, drawing direction down  




NPDTSVG.m4: Double throw with the NPDT macro  




ContactSVG.m4: A non-exhaustive sampling of contact macro variations  




ContactsSVG.m4: The contacts macro  




relaycoilSVG.m4: The relaycoil macro  




RelaySVG.m4: Some variants of the relay macro  




JackSVG.m4: The jack and plug macros  




ConnSVG.m4: The tstrip, ccoax, tconn, and tbox macros  




PconnSVG.m4: The pconnex macro  




HeadersSVG.m4: The Header macro  




ConnectorsSVG.m4: Some integrated circuits and connectors with simple geometry and lists of labels  




ChipsSVG.m4: IC outlines  




fetSVG.m4: FETs, showing programmable components and example customizations  




ujtSVG.m4: UJT examples  




thyristorSVG.m4: Thyristor examples  




BipSVG.m4: Bipolar transistors (drawing direction: up)  




TgateSVG.m4: The tgate and ptrans elements  




NportSVG.m4: The nport and nterm macros  




NLGSVG.m4: Some customizations of nport




WindingsSVG.m4: The macro winding(L|R,diam,pitch,turns,core wid,core color)




ex01SVG.m4: Two simple labeled circuits  




ex02SVG.m4: Elements at obtuse angles  




OptoisoSVG.m4: Optical isolator: a circuit with right or left orientation  




MixerSVG.m4: A balanced mixer, using mosfet and a custom transformer  




PushPullSVG.m4: A push-pull mixer, showing FETs with multiple gates  




QuantumSVG.m4: A quantum circuit  




SQUIDSVG.m4: Superconducting quantum interface device (drawing direction down)  




SixpoleSVG.m4: A six-pole filter  




ex18SVG.m4: Precision half-wave rectifier and a tunnel diode circuit (illustrating opamp, diode, resistor, ground, and labels)  




MCSVG.m4: A three-phase switched AC-AC converter and a DC-DC converter  




ex10SVG.m4: Non-planar graph and bistable circuit (illustrating the crossover macro and colored elements)  




ThreeSVG.m4: Three-phase oscillator  




ex17SVG.m4: A repetitive network created by Pic looping and a skewed circuit used to test the macro parallel_




ex12SVG.m4: A CMOS NAND gate, a test circuit, and an XMOSFET example  




pwrsupplySVG.m4: An elementary power supply circuit with colored elements, and a multiple-winding transformer with 3-phase rectifier  




TTLnandSVG.m4: TTL NAND gate illustrating a transistor with multiple emitters  




I2LSVG.m4: Gate circuit and equivalent embedded components illustrating multiple collectors  




SchottkySVG.m4: A 4-input NAND circuit illustrating the S (Schottky) option of bi_trans




ex11SVG.m4: Transistor radio audio chain  




ex04SVG.m4: Labels on non-manhattan elements  




CsourceSVG.m4: Realization of a controlled source (illustrating stacked element labels)  




DriveSVG.m4: Synchronous machine driven by variable-speed drive and rectifier  




ex16SVG.m4: A rate 1/2 binary convolutional coder and its state diagram  




ex03SVG.m4: Digital filter  




MotorControlSVG.m4: Motor control connections  




RectifiersSVG.m4: Rectifier circuits and waveforms  




HeathkitSVG.m4: The power supply of a Heathkit AR-15 (Now, that was a receiver!) with custom transformer and other elements, drawn on a grid (partially shown) to aid in placement  




lcctSVG.m4: A digital circuit of moderate size, redrawn from M. P. Maclenan and G. M. Burns, "An Approach to Drawing Circuit Diagrams for Text Books," Tugboat (12)1, March 1991, pp. 66-69  




UNOSVG.m4: An Arduino UNO circuit adapted and redrawn  




TubediagsSVG.m4: Electron-tube diagrams: a few bottom-view base diagrams, a generic triode test circuit, and a 25-watt audio amplifier adapted from F. Langford-Smith, Radiotron Designers Handbook, fourth edition, Harrison, NJ: Radio Corporation of America, 1952  




sfgSVG.m4: Signal-flow graphs  




LogicSVG.m4: Basic logic gates  




ex08SVG.m4: General-purpose latch: a small logic circuit  




DecoderSVG.m4: Decoder logic, constructed using the for_ macro  




ex21SVG.m4: Some flip-flops  




MultiplexerSVG.m4: Multiplexer  




DemultiplexerSVG.m4: Demultiplexer  




ShiftRSVG.m4: A 5-bit shift register drawn using a custom flip-flop  




AdderSVG.m4: A full adder and a cascade of n-bit adders  




CanLogicSVG.m4: A way of automatically drawing two-layer logic diagrams  




AlogixSVG.m4: The Autologix(Boolean expression; Boolean expression... , options) macro automatically draws Boolean expressions in function notation. The function tree is drawn, then a row or column of inputs, then the connections. The default result is on the left, a custom element at the top, and a tree of gates only is shown on the right.  




ABlogixSVG.m4: The Autologix macro can draw inputs on the left but the added drawing complexity may require hand tuning with second-argument options: L puts the inputs on the left, R reverses their order, V scans the input arguments in reverse order, and offset=value displaces the array of inputs  




XORSVG.m4: Realizations of the XOR function using Autologix




EEPSVG.m4: Part of a single-line diagram of a power distribution system using draft elements  




paletteSVG.m4: A draft palette of a few elements for Inkscape using a 1 mm grid  




ex00SVG.m4: Line diagrams  




controlSVG.m4: Control-system block diagrams  




GrayCodeSVG.m4: Gray code 10-bit encoder disk pattern, and a crossbar switch  


#cfig(CrossbarSVG, # A crossbar switch)



ByteSVG.m4: Elementary splines  




RotboxSVG.m4: The macro rotbox(wid,ht,type,[r|t=val]) draws a box in the current direction  




ex06SVG.m4: Crosshatching by for loops  




ex09SVG.m4: Illustrating the macro dimension_(linespec, offset, label, H|W|D|blank width, tic offset, <-|->). A negative second argument implies an offset to the right of the linespec direction. A label starting with " or sprintf is copied literally. If label is an s_box(...) then setting argument 4 to H, W, or D tailors the blank width to the s_box height, width, or diagonal respectively; i.e., W is equivalent to s_wd+textoffset*2. The macro arcdimension_ is similar but the first argument specifies the arc to be dimensioned and the second argument is the outward radial offset of the dimension arrow arc.  




PlateSVG.m4: Dimensioning with tolerances according to ASME Y14.5  


Use of darrow and Darc)



ex05SVG.m4: Use of darrow and Darc




LoglogSVG.m4: A graph drawn using the pic language  




GeometrySVG.m4: Plane geometry examples and an illustration of a Lyapunov function  




randomSVG.m4: Testing random numbers  




expSVG.m4: Test of project and other lib3D macros, showing the projection of a solid onto the y1,z1 plane by sighting along the x1 axis.  




graysurfSVG.m4: Plotting surfaces using gray scales. A sort algorithm determines plotting order  




shapesSVG.m4: Basic shapes  


#fig(AntiqueClockSVG, # An antique clock face)



cscSVG.m4: Conestoga Sailing Club (illustrating the filling of arbitrary shapes), and an antique clock face with shading and rotated text  




roseSVG.m4: A window redrawn from a detail of the set design for the musical Dracula, used for testing dpic, and an experimental halftone. This diagram consumes much LaTeX main memory but can be produced directly as pdf using dpic -d, as svg using dpic -g, or as postscript using dpic -r since no text formatting is required. The right object adjusts the size of dots to produce a halftone effect  




diamondSVG.m4: Variations on M. Goossens, S. Rahtz, and F. Mittelbach, The LaTeX Graphics Companion, Addison-Wesley 1997, pp. 57-58  




wormSVG.m4: An exercise in calculating RGB colours  




ButtonsSVG.m4: Shading in color  




DiniSVG.m4: Dini surface and an icosahedron  




SierpinskiSVG.m4: The Sierpinski triangle and a Cayley graph: tests of pic macro recursion  




recycleSVG.m4: Modest repetition and partial fill  




ex15SVG.m4: Simple diagrams that are easily drawn by looping  




CountingSVG.m4: An example of enumeration  




CrowSVG.m4: Illustrating shadebox and a custom crowfoot line termination  




FlowSVG.m4: A flowchart sampler  




BtreeSVG.m4: Binary trees  




InclepsSVG.m4: Overlaying a figure with line graphics