In Part I, I discussed what all the programs (or stuff) is that is required to get started. As mentioned a LaTeX installation is paramount as we will be generating LaTeX code from our (m4) circuit-macros to be inserted in our LaTeX document.
Because (m4) circuit-macros also form part of the CTAN, I usually extract them to one of my TEXMF root directories according to the TDS structure, e.g. on Windows,
- I copy the boxdims.sty LaTeX style file and all the *.m4 files in the Circuit_macros<version number>.zip to C:\Users\<my user name>\texmf\tex\latex\circuit_macros
- and all the rest of the files to C:\Users\<my user name>\texmf\doc\latex\circuit_macros
This is my personal choice, however it is important that boxdims.sty is located in one of the TEXMF root directories. In MikTeX a TEXMF root directory can be add using MikTeX Console as follows:

Here, C:\User\petra\texmf, is my personal or custom or local TEXMF root directory. According to the TDS all LaTeX packages (i.e. class or style files) are situated in the C:\User\petra\texmf\latex directory, where as all the documentation is the C:\User\petra\texmf\doc directory. After a local TEXMF root directory was created, and new package where added, the package file name database (FNDB) needs to be updated,

Now that the (m4) circuit-macros have been “installed”, we need to “install” the m4 macro processor to expand these circuit-macros into pic code. We also need to “install” the (d)pic compiler to convert the pic code into LaTeX code. The following three files therefore needs to be copied somewhere in your PATH:
- m4.exe
- regex2.dll (required by m4.exe)
- dpic.exe
Because I use m4 and dpic exclusively with LaTeX, I usually (on Windows) copy them into my MikTeX bin directory, i.e. C:\Program Files\MiKTeX 2.9\miktex\bin\x64 But this is personal preference, the only requirement is that they are in the path somewhere…
To check if m4 and dpic are indeed in the path, issue the following commands in a directory other than where these executable were copied to.
$ m4 --version
Should result is,
m4 (GNU M4) 1.4.17 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Rene' Seindal.
And,
$ dpic --version
Should result in,
*** dpic version 2019.01.01
Options:
(none) LaTeX picture output
-d PDF output
-e Pict2e output
-f Postscript output, psfrag strings
-g PGF-TikZ output
-h write this message and quit
-m mfpic output
-p PSTricks output
-r Postscript output
-s MetaPost output
-t eepicemu output
-v SVG output
-x xfig output
-z safe mode (disable sh, copy, and print to file)
The final part of the “installation” is to let the m4 macro processor know where our m4 circuit-macro “libraries” are located. This is done by creating an M4PATH variable point to the installation path of our m4 circuit-macros. This is done by clicking on the Environment Variables… button on the Advanced tab of System Properties in Windows.

And adding the new M4PATH variable.

In my case, M4PATH=C:\User\petra\texmf\latex\circuit_macros
By opening the command promp in Windows, one can check the M4PATH variable by issueing the following command,
$ set m4path
In my case, this should return,
M4PATH=C:\Users\petra\texmf\tex\latex\circuit_macros
In the next part (Part III), I will discuss how to “draw” (i.e. program) our first M4 Circuit Macro picture and basically test to see if everything is smoothly working together.
