# how to replace latex macros with their definitions (using latex)

Filed under:
|
##### substitution

How can I replace all occurrence of user defined latex macros with their definitions?

For example, given this file

old.tex

\newcommand{\blah}[2]{#1 \to #2}
...
foo \blah{egg}{spam} bar
...

how to generate the file below in an automatic way

new.tex

...
foo egg \to spam bar
...

Instead of reimplementing latex macro logic with perl, can I use latex or tex engine itself to do this?

© Stack Overflow or respective owner

• #### How to deal with configuration style warnings occuring from TexLive 2012 installation?

I followed the advice of izx on how to install TexLive 2012 using the texlive-backports PPA. Before I started I removed all TexLive-related packages. The installation finished and everything seems to work fine. The only thing I noticed are some warnings in the output of the installer. Here is an excerpt… >>> More

• #### Making the draft document option in LaTeX have extra text appear in LaTeX

as seen on Stack Overflow - Search for 'Stack Overflow'
Is there a way to get some text to appear only when the [draft] option is active. For example, when the draft option is active, I want some text to appear between my title and abstract: "draft: do not cite without permission" or some such. >>> More

• #### how to replace latex macros with their definitions (using latex)

as seen on Stack Overflow - Search for 'Stack Overflow'
How can I replace all occurrence of user defined latex macros with their definitions? For example, given this file old.tex \newcommand{\blah}[2]{#1 \to #2} ... foo \blah{egg}{spam} bar ... how to generate the file below in an automatic way new.tex ... foo egg \to spam bar ... Instead of reimplementing… >>> More

• #### write c++ in latex, noob latex question

as seen on Stack Overflow - Search for 'Stack Overflow'
maybe is a noob question but i can't find the solution in the web, i need to write C++ in Latex. I write C$++$ but the result is like crap, the signs are too big and there is too much space between C and the first plus sign. Previously i needed to write the sharp symbol for C#....c$\sharp$ it also… >>> More

• #### fresh installation of PGF/TikZ crashes, why?

as seen on Stack Overflow - Search for 'Stack Overflow'
I have a clean CentOS 5.5 machine with tetex installed. Next, I installed PGF/TikZ: wget http://media.texample.net/pgf/builds/pgfCVS2010-06-02_TDS.zip unzip pgfCVS2010-06-02_TDS.zip \cp -r tex /usr/share/texmf texhash I'm trying to compile a simple document and this is what I'm getting: \$ latex… >>> More

• #### Weird behavior of substitution in Mathematica.

as seen on Stack Overflow - Search for 'Stack Overflow'
My question is: why doesn't the following work, and how do I fix it? Plot[f[t], {t, 0, 2*Pi}] /. {{f -> Sin}, {f -> Cos}} The result is two blank graphs. By comparison, DummyFunction[f[t], {t, 0, 2*Pi}] /. {{f -> Sin}, {f -> Cos}} gives {DummyFunction[Sin[t], {t, 0, 2 *Pi}], DummyFunction[Cos[t]… >>> More

• #### Substitution till the end of the line in bash

as seen on Stack Overflow - Search for 'Stack Overflow'
Hi, I have a huge text file with lots of lines like: asdasdasdaasdasd_DATA_3424223423423423 gsgsdgsgs_DATA_6846343636 ..... I would like to do, for each line, to substitute from DATA_ .. to the end, with just empty space so I would get: asdasdasdaasdasd_DATA_ gsgsdgsgs_DATA_ ..... I know… >>> More

• #### Rewriting An URL With Regular Expression Substitution in Routes

as seen on Stack Overflow - Search for 'Stack Overflow'
In my Pylons app, some content is located at URLs that look like http://mysite/data/31415. Users can go to that URL directly, or search for "31415" via the search page. My constraints, however, mean that http://mysite/data/000031415 should go to the same page as the above, as should searches for… >>> More

• #### ASP .NET - Substitution and page output (donut) caching - How to pass custom argument to HttpRespons

as seen on Stack Overflow - Search for 'Stack Overflow'
I would like to use substitution feature of donut caching. public static string GetTime(HttpContext context) { return DateTime.Now.ToString("T"); } ... The cached time is: <%= DateTime.Now.ToString("T") %> <hr /> The substitution time is: <% Response.WriteSubstitution(GetTime);… >>> More

• #### C++ : Math library that solve system of equations using back substitution algorithm

as seen on Stack Overflow - Search for 'Stack Overflow'
If I have this: A * f = g; A: upper triangular matrix (n x n) f: (n x 1) g: (n x 1) Need to solve for f using back substitution algorithm. I would say that it not really that hard to write one myself, but oh well, if there is a library out there, then why not. >>> More