3

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?

Thank you in advance for your help.

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

19
  • 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, 2019 at 12:13
  • 1
    de-macro seems to work fine for me... could you post your code? (system python 2.7.10 on macOS 10.13) Feb 17, 2019 at 12:15
  • 1
    You used \defs in you .sty file, which are not compatible with de-macro. From its documentation: "Only newcommand, renewcommand, newenvironment, and renewenvironment are understood" Feb 17, 2019 at 12:28
  • 1
    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? Feb 17, 2019 at 12:30
  • 1
    TeX: The error comes from the fact that you wrote \usepackage{rmsmacros-private}, but the package is called testmacro-private.sty, so de-macro does not find your definitions. Rename your file! python: The code seems to be written for python 2.5, and thus raises a string as an exception, which was removed from python 2.6+. But as long as there is no exception is to be raised, you are good with python 2.7... Feb 18, 2019 at 11:43

1 Answer 1

6

The documentation of de-macro states that

Only newcommand, renewcommand, newenvironment, and renewenvironment are understood

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.

1
  • Thanks, just found that de-macro is no more part of TeX Live. I downloaded the latest version from https://ctan.org/pkg/de-macro, which was luckily made compatible with Python 2.7 and 3. However, under Ubuntu 20.04, I had to manually install it, i.e. to copy the altered Python file calling python3 into /usr/bin.
    – Mario
    Dec 4, 2020 at 12:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .