Related to my titular quest:

Reasons behind my interest (that may be relevant to finding what I'm looking for):

  • When collaborating and working on a single .tex file through online-file-sharing-programs (e.g. Dropbox), I do not want to insert my personally-defined macros (e.g. \newcommand{\infwrt}[2]{\inf\limits_{\scriptscriptstyle\mathclap{#2}}#1}), but I would still like to use the convenient macro, and then simply convert my .tex file accordingly to then copy-paste the standard-defined version of my write-up.
  • The above reason is what pushed me into looking for a solution, but a much older reason for me is that I prefer typing in a tex editor (e.g. TeXstudio) which has nice features such as autofill, and so when I peruse Math StackExchange, and find a question I want to answer, it can take awhile without the editor. With the editor, I can type up an answer quickly, and ideally convert the personally-defined macros into standard-defined commands.

I tried looking into "de-macro", and according to the CTAN page:


I need to use Python. So I downloaded Python 3.5.2, and am not sure what to do from here. Alternative solutions is what I'm seeking, but if you are proficient in how to use "de-macro" then a guide would be very helpful. Thanks in advanced!

  • Are you aware that Math SE does not use TeX but MathJax? An answer typed in your editor may use only the subset of TeX which MathJax emulates, but it may not. Also, are you sure you don't have Python already? Any sane OS will. (Not sure about Windows.) – cfr Sep 9 '16 at 0:49
  • I am aware of MathJax: I know that I won't be able to use every TeX command. I am, however, not familiar with computer languages such as Python, or how to use them. So I simply went to Google to find and downloaded it (EDIT: and install it). – Alberto Takase Sep 9 '16 at 0:56

The package expects your private macros will be in a separate file that you load via \usepackage and which ends -private.sty:

% mydefs-private.sty
\newcommand{\trythis}[3]{I'm juggling #1, #2, and #3}
\renewcommand{\trythis}[4]{I'm juggling #1, #2, and #3 --- no! and #4}

You then load that package into the .tex file in the normal way:

% original mytexfile.tex



Then you run the command de-macro:

de-macro mytexfile.tex

And this will produce a new file, called mytexfile-clean.tex, which looks like this:

% original mytexfile.tex


I'm juggling cats, dogs, and parrots --- no! and lizards


For basic uses it seems straightforward enough; but I've no doubt that you could easily construct macros that confound the program.

  • Hi! Thanks for responding. When you say "run the command" am I using command prompt? or is it the Python command line? Also shouldn't I have to specify the file location? I read in one of the related links that I have to "open a shell, and go to the directory with my file" I'm not sure what/how to do this. – Alberto Takase Sep 9 '16 at 2:51
  • I suppose it depends how you installed the program. With TeX Live 2016 (on Linux), it comes installed by default and can be run 'from' pretty much anywhere. So I ran the command in the directory where the .tex and .sty files were found. What OS are you using? I know on windows, you can open a DOS shell in the current directory in various ways; on Macs, it's pretty much the same as on *nix. – jon Sep 9 '16 at 3:01
  • Windows 10. The command prompt doesn't recognize the 'de-macro' command; is there a similar way to open python in the folder location? – Alberto Takase Sep 9 '16 at 3:07
  • I'm afraid I know next to nothing about Windows. How do you know the command is installed? And is "open[ing] python in the folder location" even something that could be done? If someone told me to do that on my system, I'd be surprised. – jon Sep 9 '16 at 3:29
  • Hmm, from the README, it sounds like this program may not work on Windows without modification.... – jon Sep 9 '16 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.