To get started with M4 Circuit Macros, a lot of different programs (or stuff) is required. On a Windows box, this could seem very daunting. On a Linux box it is slightly easier.
In Part I, I will only discuss all the stuff that needs to be download first. Part II will focus on where these stuff needs to placed to work together properly. Part III wil discuss how to test our installation and generate an M4 Circuit Macros picture from the command line. Again for a Windows user this may seem a bit daunting, but for a Linux user this should not be relative easy to follow. Part IV will discuss how these command line step can be simplified using the Python script, m4cm.py. Part V will discuss how the creation of an M4 Circuit Macros picture can simplified further using Notepad++ on Windows and Kile on Linux.
OK, so let’s start with all of the stuff that needs to be downloaded first.
- The most important is a LaTeX installation as the (d)pic compiler generates LaTeX code that needs to included into the main LaTeX and compiled to show the picture. On Windows I prefer MikTeX and on Linux, TexLive. I wouldn’t go into the details in Part II on how to install LaTeX, as this is beyond the scope of this Blog, but for MikTeX, have a look at the HOWTO links here. I have a complete installation, but missing packages can be installed on the fly.
- Preferable the latest version of (m4) circuit-macros from either
- Make sure the general-purpose macro processor m4, to expand the circuit-macros into (d)pic code, is installed. On a Linux box, it is usually installed by default. For a Window box, m4 can be downloaded from Sourceforge :
- https://sourceforge.net/projects/gnuwin32/files/m4/1.4.14-1/m4-1.4.14-1-bin.zip/download
or just the pre-compiled version for Windows here, - https://ece.uwaterloo.ca/~aplevich/dpic/Windows
- https://sourceforge.net/projects/gnuwin32/files/m4/1.4.14-1/m4-1.4.14-1-bin.zip/download
- The dpic compiler, to compile the (d)pic output generated by the macro processor m4 into LaTeX code, can be downloaded here,
- https://ece.uwaterloo.ca/~aplevich/dpic/ or
- https://gitlab.com/aplevich/dpic or in pre-compiled form for Windows
- https://ece.uwaterloo.ca/~aplevich/dpic/Windows/index.html
- A nice editor that preferable allows for custom syntax highlighting in order to ease the “programming” of (m4) circuit-macros. On Windows, I prefer Notepad++ for (m4) circuit-macros, whilst using TeXstudio for my LaTeX documents (just because I still have not figured out how to do syntax highlighting for TeXstudio).
On Linux I use Kile (which is basically “KatePart for LaTeX”) for both my LaTeX documents and my (m4) circuit-macros.
Have a look in the Syntax Highlighting directory of my m4cmpy GitHub repository for custom syntax highlighting for both these editors, i.e. Notepad++ and KatePart/Kile. - And finally on a PDF viewer that allows a PDF file to be altered while it is being viewed, e.g. Sumatra PDF on Windows or Okular on Linux.
Adobe Acrobat unfortunately does not work as one has to close the file whilst compiling a new version.
In the next part (Part II), we will look at how to install some the above mentioned programs, or more correctly where to copy some of these files to, for a basic installation, just to get started and wet the appetite for more.

Thanks a million for this. Been using circuit_macros since 2019 and I was struggling to get a head start due to the lack of available resources I could find online. It’s always a nice thing to see people writing these articles.