You are on page 1of 3

11/8/23, 23:00 Getting started with M4 Circuit Macros – Part I – The M4 Circuit Macro Python build automation tool

The M4 Circuit Macro Python build automation tool


A Blog on how to create beautiful standalone PDF, JPG or PNG picture with M4 Circuit Macros using the
m4cm.py Python script as well as some other tips and tricks.

Getting started with M4 Circuit


Macros – Part I

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.

1. 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

https://m4cmpy.wordpress.com/2020/02/23/getting-started-with-m4-circuit-macros/ 1/3
11/8/23, 23:00 Getting started with M4 Circuit Macros – Part I – The M4 Circuit Macro Python build automation tool

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.
2. Preferable the latest version of (m4) circuit-macros from either
https://ctan.org/pkg/circuit-macros,
https://ece.uwaterloo.ca/~aplevich/Circuit_macros/ or
https://gitlab.com/aplevich/circuit_macros
3. 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
4. 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
5. 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.
6. 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
https://m4cmpy.wordpress.com/2020/02/23/getting-started-with-m4-circuit-macros/ 2/3
11/8/23, 23:00 Getting started with M4 Circuit Macros – Part I – The M4 Circuit Macro Python build automation tool

installation, just to get started and wet the appetite for more.

Sponsored Content

Peter Jan Randewijk / 23 February 2020 / Downloading, Getting started / dpic, m4, regex2.dll,
sumatrapdf

One thought on “Getting started with M4 Circuit


Macros – Part I”

Billy
8 July 2021 at 20:08

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.

The M4 Circuit Macro Python build automation tool / A WordPress.com Website.

https://m4cmpy.wordpress.com/2020/02/23/getting-started-with-m4-circuit-macros/ 3/3

You might also like