# De-macro script not working anymore?

I would like to use a script which is included in TeX Live called De-macro (link), this module is a bit old, the last update is from 2007 and it works with Python 2.7 I guess.

I tried to use it yesterday, so I followed the instructions :

• I created a file with some tex using macros called ideas.tex.
• I included \usepackage{rmsmacros-private} in this file.
• I created a file called rmsmacros-private.sty with my macros.
• Then I used the script and I did de-macro ideas.tex
• The script told me that all is ok and created ideas.db and ideas-clean.tex
• All seemed to be okay.

But finally, when I opened ideas-clean.tex which should had all my macros expanded, finally just the line \usepackage{rmsmacros-private} has been erased and nothing else had been changed.

So do someone has this script working or does this script not working anymore?

My code is available here : https://we.tl/t-gT3UMxOfyu

• When I try to run de-macro, I get a syntax error (most likely it was written for Python2 and fails on Python3, will not look into it). – Skillmon Feb 17 at 12:13
• de-macro seems to work fine for me... could you post your code? (system python 2.7.10 on macOS 10.13) – Peater de Xel Feb 17 at 12:15
• Also works for me. Remember to clean out intermediate files between testing, in particular the .db file. – Andrew Swann Feb 17 at 12:21
• I would suggest to replace the \def with the fresher \newcommand, for most of your commands it should be straight forward. Also, maybe you could just copy-paste the code from .sty into the header of your .tex, if you want to make your file portable? – Peater de Xel Feb 17 at 12:30

The documentation of de-macro states that


As you use \def in your .sty-file, de-macro does not work like you expected. I would suggest to either

• replace \def with the newer \newcommand, if you want to continue using de-macro
• put your own definitions directly into the main file, and skip de-macro.

Syntax Error

Note that de-macro requires python 2, so if you get a SyntaxError: invalid syntax, your /usr/bin/python is most likely version 3.

A quick and dirty fix would be to change the first line of the de-macro-script from

#!/usr/bin/python -O


to

#!/usr/bin/python2 -O


You can find the location of the de-macro-script with which de-macro — on my Mac it's /Library/TeX/texbin/de-macro.