CTAN
Comprehensive TeX Archive Network

Direc­tory tex-archive/graphics/circuit_macros

* Circuit_macros Version 8.2, copyright (c) 2015 J. D. Aplevich under     *
* the LaTeX Project Public License. The files of this distribution may    *
* be redistributed or modified provided that this copyright notice is     *
* included and provided that modifications are clearly marked to          *
* distinguish them from this distribution.  There is no warranty          *
* whatsoever for these files.                                             *

  This is a set of macros for drawing high-quality line diagrams to
  include in LaTeX, web, or similar documents, with support for SVG and
  other formats.  Fundamental electric circuit elements and basic logic
  gates based on IEEE and European standards are included with several
  tools and examples of other types of diagrams.  Elements can be scaled
  or drawn in any orientation and are easy to modify.  The advantages
  and disadvantages of such a system are similar to those of TeX itself,
  which is macro-based and non-wysiwyg, with ordinary text input.

  The macros are to be processed by an m4 macro processor, and evaluate to
  drawing commands in the pic "little language," which is easy to read and
  learn. The diagram is then automatically translated into TiKZ, PSTricks,
  or other formats for processing by LaTeX or other applications. Pic
  is well suited to line drawings requiring parametric or conditional
  components, fine adjustment, significant geometric calculations,
  repetition, or recursion.  Arbitrary text for formatting by LaTeX can
  be placed at will in the diagram. Free interpreters for m4 and pic
  are readily available.

REQUIRED SOFTWARE:
Preferred setup:
  GNU m4, dpic (see below), LaTeX, PSTricks, dvips
  or
  m4, dpic, LaTeX or PDFLaTeX, TikZ-PGF

  The dpic interpreter can translate pic input into several forms,
  typically a .tex file for processing by latex with pgf/TiKz or PSTicks.

  The GNU m4 macro processor is assumed since its -I option and M4PATH
  environment variable simplify file inclusion (see INSTALLATION below).
  Early versions of these macros required absolute path names to be
  used in include statements, which is still possible.

Alternative:
  m4, GNU pic (gpic), TeX or LaTeX, and a driver recognizing tpic specials
   (eg dvips)

  The GNU pic interpreter with option -t produces tpic special commands.

Also possible for some diagrams:
  m4 and dpic with output in the following formats:
    LaTeX graphics or LaTeX eepic (for simple diagrams), mfpic, xfig,
    MetaPost, SVG, PDF, or Postscript.

USAGE
  First-time users should read the Quick Start section of CMman.pdf.

  The following describes the most common basic usage; see below for
  integration with other tools and production of other formats. You
  probably should try out the basic usage before combining the macros
  with more sophisticated, but system-dependent, tools. 

  Suppose that  a source file, cct.m4 say, has been created and the top
  two lines are
  .PS
  cct_init
  ...

  The file is processed by feeding a configuration file followed by the
  diagram source to m4, and routing the output to dpic.  If you have set
  the M4PATH environment variable as described in the INSTAllATION
  instructions, the command is

    m4 pstricks.m4 cct.m4 | dpic -p > cct.tex

  If you have not set the M4PATH environmental variable then the command is

    m4 -I <path> pstricks.m4 cct.m4 | dpic -p > cct.tex

  where <path> is the absolute path to the directory containing the library
  macros.

  If the first line of cct.m4 is include(pstricks.m4) and M4PATH is defined,
  then this command can be simplified to

    m4 cct.m4 | dpic -p > cct.tex

  Omitting the include(pstricks.m4) line causes a default configuration file
  to be read.

  To use the gpic processor (called pic on some systems) instead of dpic,
  the command is

    m4 gpic.m4 cct.m4 | gpic -t > cct.tex

  with the -I <path> option added if M4PATH has not been defined.

  In each case, the resulting file cct.tex is normally inserted into a
  document to be processed by LaTeX, which produces a dvi file to be
  converted to postscript using dvips. Otherwise, to produce pdf output
  with PDFLaTeX, pgf.m4 is read instead of pstricks.m4 and the dpic option
  is -g, so the command is

    m4 pgf.m4 cct.m4 | dpic -g > cct.tex

  or, using include(pgf.m4) in cct.m4,

    m4 cct.m4 | dpic -g > cct.tex

  The document is then processed either by LaTeX to produce postscript
  or PDFLaTeX to produce pdf directly.

  Read Section 2 of the manual to see how to process the diagram source
  from within the main .tex source file.

INSTALLATION:
  1.  Decide where you will be installing the .m4 library files. In
      principle, they can go anywhere, $HOME/Circuit_macros or in your
      localtexmf folder such as c:\localtexmf\Circuit_macros, for example.
      Copy the files from the top-level directory of the distribution
      to the installation directory, or simply expand the .tar.gz or
      .zip distribution file to create the installation directory,
      which will then include the doc and examples subdirectories.

  2.  Copy boxdims.sty (see Section 9 of the manual) from the top
      distribution directory to where LaTeX will find it, typically
      localtexmf/tex/latex/local/ or C:\localtexmf\tex\latex\local,
      and refresh the LaTeX filename database.

  3.  Define the environment variable M4PATH to point to the installation
      directory determined in step 1. On Cygwin, for example, add the
      following to your .bashrc file:
      export M4PATH='.:/cygdrive/c/localtexmf/Circuit_macros:'
      but modify the path to the installation directory as necessary. 
      On a Unix or Linux machine, the line might be
      export M4PATH='/usr/local/share/texmf/tex/latex/circuit_macros/'
      depending on where you have installed the files.

  4.  This is optional. The default configuration file as distributed
      is gpic.m4. You can change it to pgf.m4 or pstricks.m4 for use with
      dpic by editing the include command near the top of libgen.m4.  To do
      this automatically, go to the installation directory and type
        "make pgfdefault" to set the default processor to dpic with Tikz pgf
        "make psdefault"  to set the default processor to dpic with PSTricks
        "make gpicdefault" to restore gpic as the default.

WORKFLOW: The basic commands given above suffice for documents of moderate
  size and complexity; otherwise, a "make" facility or equivalent should be
  used or, for modest documents, diagram processing can be controlled from
  within the tex document source as described in the manual.  Special-purpose
  editors and project tools such as TeXnicCenter or Cirkuit can be employed.
  A scripting language can also automate the steps as done by Latexmk or
  several other similar tools; see, for example,
  http://tex.stackexchange.com/questions/64/tools-for-automating-document-compilation

  NOTE: One of the configuration files (gpic.m4, pstricks.m4, pgf.m4,
  pdf.m4, postscript.m4, mpost.m4, mfpic.m4, svg.m4, or xfig.m4) must be
  read by m4 before (or at the beginning of) the diagram source file,
  depending on the required form of pic output. Otherwise, libgen.m4
  can be read first but it will invoke the default configuration file,
  which is gpic.m4 in the distribution unless it has been changed during
  installation.

TESTING:
  To test your installation, go to the examples directory and create
  a test circuit in the file test.m4.  Copy ex01.m4, for example, or
  quick.m4 from the doc directory into test.m4.

  On a system with a "make" facility, first check the definitions at
  the top of the Makefile, and then type "make tst1" to produce the
  file tst.ps.  If the source requires processing twice, type "make
  tst" instead.  To process one of the example .m4 files in the
  examples directory, simply type "make name.ps" to process name.m4.
  If these tests work to your satisfaction, try typing simply "make" to
  produce examples.ps.  To test .pdf files, go to the pgf directory,
  copy name.m4 there, and type either "make name.ps" or "make name.pdf"
  to test the file under pdflatex and TikZ PGF.

  No "make" facility?  You have to test by hand (but see below for
  diagram production software).  Copy a test file as above into
  test.m4.  Assuming you have dpic installed, type the following:

  m4 -I <path> pstricks.m4 test.m4 > test.pic
  dpic -p test.pic > test.tex
  latex tst
  dvips tst -o tst.ps

  For several years, these macros were developed and tested on a Solaris
  operating system. More recently, they have been maintained on a PC
  with Cygwin, MiKTeX, and dpic.

SOURCES:
  M4 is widely available on Unix systems.  PC source and executables are
  also available: http://gnuwin32.sourceforge.net/packages/m4.htm
  A large set of Unix-like Windows tools, including m4, is available via
  http://www.cygwin.com/
  DJGPP versions are available as m4-NNb.zip (where NN is the current
  release number) on web archives and at
  http://www.delorie.com/djgpp/dl/ofc/dlfiles.cgi/current/v2gnu/

  There are several sources of hints on m4 usage; some places to look are
  http://gnuwin32.sourceforge.net/packages/m4.htm
  http://www.gnu.org/software/m4/manual/
  http://www.seindal.dk/rene/gnu/
  The m4 (computer language) article in Wikipedia gives a concise overview.
  An academic discussion of the language can be found in
  http://www.cs.stir.ac.uk/~kjt/research/pdf/expl-m4.pdf.

  Gpic is part of the GNU groff distribution, for which the latest
  source is available from http://ftp.gnu.org/gnu/groff/, but there are
  mirror sites that archive these sources, and others that distribute
  executables.

DPIC:
  Dpic is not included here you say?  If you want to try the LaTeX
  picture objects, mfpic, PSTricks, TikZ-PGF, MetaPost, xfig, SVG, PDF,
  or Postscript output provided by dpic, the current (free) ANSI C source
  and Windows executable can be obtained from
  http://ece.uwaterloo.ca/~aplevich/dpic/

MANUALS:
  View or print CMman.pdf in the doc directory.

  The dpic distribution includes a manual containing a summary of the pic
  language and discussion of features unique to dpic.

  The original pic manual can be obtained at
  http://www.cs.bell-labs.com/10thEdMan/pic.pdf.  A more extensive
  manual is found in the documentation that comes with GNU pic, which
  is typically installed as gpic.  The latest version can be found in
  the groff package at http://ftp.gnu.org/gnu/groff/ .  A pdf copy
  is included with the dpic distribution and a version can be found
  on the web at http://www.kohala.com/start/troff/gpic.raymond.ps

EXAMPLES AND INTEGRATION WITH OTHER TOOLS:
  A set of examples is included in this distribution, showing electric
  circuits, block diagrams, flow charts, signal-flow graphs, basic use
  of colour and fill, and other applications.

  Read the manual CMman.pdf and view or print the file examples.ps in the
  examples directory.  For the possibly unstable development version of
  these macros, try http://ece.uwaterloo.ca/~aplevich/Circuit_macros/

  The examples directory Makefile automates the generation of .ps, .eps,
  .png, and .pdf files for individual diagrams.  Subdirectories of the
  examples directory are for testing metafont, metapost, pdflatex, pgf,
  psfrag, pdf, and xfig examples.

  Installation and usage of the macros have evolved a little since the
  beginning so archived instructions on the net may be slightly more
  complicated than currently necessary.  However, a number of people
  have developed tools that simplify workflow for their circumstances,
  which are beyond the scope of this distribution.  The following may
  be of interest:

  A set of examples and hints intended for his colleagues has been
  produced by Alan Robert Clark at http://ytdp.ee.wits.ac.za/cct.html

  A website describing usage and tools for Circuit_macros has been created
  by Peter-Jan Randewijk at
  http://staff.ee.sun.ac.za/pjrandewijk/wiki/index.php/M4_Circuit_Macros
  The site includes examples ranging from basic circuits to block diagrams.
  Tools for creating pdf and web diagrams are included, along with
  Circuit_macro customizations for the Kile LaTeX editor, which are described at
  http://staff.ee.sun.ac.za/pjrandewijk/wiki/index.php/M4_Circuit_Macros_-_Kile_Integration

  A KDE interface created by Matteo Agostinelli can be found at
  http://wwwu.uni-klu.ac.at/magostin/cirkuit.html

  Mac users:
  A previewer script written by Collin J. Delker is available at
  https://bitbucket.org/cdelker/circuit_macros-generation-and-preview

  An introduction to installation and use on OS X by Felipe Cavalcanti is at
  http://www.lara.unb.br/~fbcavalcanti/docs/tech/circuit_macros/using_circuit_macros_in_mac_osx.pdf

  For more examples in the context of a textbook, have a look at
  Aplevich, J.D., "The Essentials of Linear State-Space Systems," New
  York: John Wiley & Sons Inc., 2000.  In Canada, look at Andrews,
  G.C., Aplevich, J.D., Fraser, and R.A., MacGregor, C.G.,
  "Introduction to Professional Engineering in Canada," (fourth edition)
  Toronto:  Pearson Education Canada, Inc., 2014.  Some samples from these
  books can be found at
  http://ece.uwaterloo.ca/~aplevich/

  For an example of the use of dpic in a wiki (thanks to Jason Grout), see
  http://math.byu.edu/~grout/software/dokuwiki/format-plugin

  A Windows batch file for Circuit_macros is found at
  http://someonehasdonethis.blogspot.ca/2012/12/a-solution-for-drawing-circuit-diagrams.html

  The examples in the current distribution include some flowchart elements
  in Flow.m4.  For a pic-only version that does not require m4, look at
  http://www2.ing.puc.cl/~mtorrest/downloads/latex/flowchart.pdf

  Pic dates from the 1980s and was first developed as a preprocessor for
  the *roff family of Unix word processors.  Some additional libraries such
  as chem (for chemical structures) and dformat (for data structures) are
  still viable.

  A pic tutorial on the web is found at
  http://www.onlamp.com/pub/a/onlamp/2007/06/21/in-praise-of-pic.html

  Pic macros for drawing graphs are described at
  http://www.math.uiuc.edu/~west/gpic.html
  After minor adaptation to dpic syntax, many of them can be simplified.

  A collection of pic resources and related material is available at
  http://www.kohala.com/start/troff/troff.html In particular, W. Richard
  Stevens illustrated his books on Unix and TCP/IP using pic macros. Some
  of the sources found there need minor tuning to work under dpic.

TikZ-PGF: Check the Makefile in the examples/pgf directory as described
  in the README file, and type "make" or "make examples.pdf".

MetaPost examples:  Go to the examples/mpost directory.  Check the
  Makefile as described in the README file, type "make", and stand well back.

PDFLaTeX: Check the Makefile in the examples/pdflatex directory as described
  in the README file, and type "make".  These examples use Metafont as an
  intermediate format and are made somewhat obselete by the above TikZ-PGF
  compatibility.

Postscript with embedded psfrag strings:
  Type "make" in the examples/psfrag directory to process examples
  using dpic -f for creating .eps files with embedded psfrag strings.

Postscript, CorelDraw, Adobe Illustrator:
  Circuits and other diagrams not requiring LaTeX-formatted text can be
  processed through m4 and dpic -r to produce encapsulated Postscript
  output. This output can also be imported into CorelDraw or Adobe
  Illustrator.  However, Postscript is not a word processor, so any
  LaTeX formatting instructions in the source are not obeyed. These programs
  also import svg output produced by dpic -v.

SVG output, Inkscape:
  Dpic -v produces svg output.  If the result is to be directly
  inserted into html, then as for Postscript output, the diagram source
  file has to be adapted to remove any LaTeX formatting.  A switch in these
  macros deletes explicit LaTeX markup from the defined elements and provides
  other macros in svg.m4 for xml text formatting.

  If SVG is the ultimate goal, then it may be advisable to use the tool
  dvisvgm to convert dvi to svg.

  SVG is the native file format for the Inkscape graphics editor.
  Therefore, elements defined by these macros can be output by dpic -v
  in svg format for later manipulation by Inkscape.  Recent Inkscape versions
  can export graphics to eps or pdf format and text to tex format, so
  that labels can be formatted by LaTeX and overlaid on the graphics
  file. This process allows the use of Inkscape to place and embellish
  circuit elements.

  A basic library of circuit elements created from these macros for
  importing into Inkscape is found in examples/svg/svglib.m4.
  You would probably wish to add to or customize these diagrams for
  extensive use.

Metafont:
  The file examples/mf/cct.mf is a Metafont source for a few variants of
  the basic elements, produced using the mfpic output of dpic.  It may
  be of interest to persons who cannot otherwise implement the macros.
  To see the elements (assuming a typical installation), type "make"
  in the mf directory.

Xfig:
  The file examples/xfig/xfiglib.fig contains circuit elements in xfig
  3.2 format produced by dpic.  The file is a prototype because many
  more elements could be included.  Logic gates often have many labels,
  and xfig is not a word processor, so some fine tuning of labels is in
  order.  Translation between languages always involves a loss of
  information and idiom, but Xfig can store diagrams in pic format, so
  it is possible to alternate between xfig and dpic.

LIBRARIES:
  The file libgen.m4 contains general-purpose macros and is read
  automatically by other libraries.  The file libcct.m4 defines basic
  circuit elements.  Binary logic-circuit elements are in liblog.m4.
  Macros for drawing 3D projections are in lib3D.m4, and some macros
  for drawing double-line arrows are in darrow.m4. The file dpictools.pic
  contains pic macros and is read automatically by some of the examples.

MODIFICATIONS:
  Macros such as these inevitably will be modified to suit individual
  needs and taste.  They continue to evolve in my own library as I use
  them and as others send comments.  No such collection can hope to
  include all possible circuit-related symbols, so you will probably
  find yourself writing your own macros or adapting some of these.  Be
  careful to rename modified macros to avoid confusion.  The learning
  curve compares well to other packages, but there is no trivially easy
  way to produce high-quality graphics.

Feel free to contact me with comments or questions.  I have retired
from full-time work but continue the hobby of maintaining these files.
I may now be able to spend more time on individual requests but I may
not reply instantly to email.


Dwight Aplevich
aplevich (AT) uwaterloo (DOT) ca

Direc­to­ries

Name Notes
doc
ex­am­ples

Files

Name Size Date Notes
CHANGES 9997 2015-06-17 20:10
Copy­ing 456 2015-06-17 20:10
Make­file 1489 2015-06-17 20:10
README 18917 2015-06-17 20:10
boxdims.sty 1187 2015-06-17 20:10
dar­row.m4 14901 2015-06-17 20:10
dpic­tools.pic 11340 2015-06-17 20:10
gpic.m4 1010 2015-06-17 20:10
lib3D.m4 8646 2015-06-17 20:10
libcct.m4 137034 2015-06-17 20:10
lib­gen.m4 64684 2015-06-17 20:10
li­blog.m4 49504 2015-06-17 20:10
mf­pic.m4 1108 2015-06-17 20:10
mpost.m4 1592 2015-06-17 20:10
pgf.m4 1531 2015-06-17 20:10
postscript.m4 2594 2015-06-17 20:10
pstricks.m4 2093 2015-06-17 20:10
svg.m4 3044 2015-06-17 20:10
xfig.m4 1023 2015-06-17 20:10

Down­load the con­tents of this pack­age in one zip archive (1.9M).

cir­cuit-macros – M4 Macros for Elec­tric cir­cuit di­a­grams

A set of macros for draw­ing high-qual­ity elec­tric cir­cuits con­tain­ing fun­da­men­tal el­e­ments, am­pli­fiers, tran­sis­tors, and ba­sic logic gates to in­clude in TeX, LaTeX, or sim­i­lar doc­u­ments. Some tools and ex­am­ples for other types of di­a­grams are also in­cluded.

The macros can be eval­u­ated to draw­ing com­mands in the pic lan­guage, which is very easy to un­der­stand and which has a good power/com­plex­ity ra­tio. Pic con­tains el­e­ments of a sim­ple pro­gram­ming lan­guage, and is well-suited to line draw­ings re­quir­ing para­met­ric or con­di­tional com­po­nents, fine tun­ing, sig­nif­i­cant ge­o­met­ric cal­cu­la­tions or rep­e­ti­tion, or that are nat­u­rally block struc­tured or tree struc­tured. (The m4 and pic pro­ces­sors are read­ily avail­able for Unix and PC ma­chines.)

Al­ter­na­tive out­put macros can cre­ate TeX out­put to be read by pstricks, Tikz com­mands for use by the pgf bun­dle, or SVG.

Pack­age De­tailscir­cuit-macros
Ver­sion8.2
Li­censeThe LaTeX Project Public Li­cense
Copy­right2010–2015 J. D. Aple­vich
Main­tainerDwight Aple­vich
Topics sup­port of elec­tronic de­sign
cir­cuit di­a­grams
See also circ
circuitikz
Guest Book Sitemap Contact Contact Author