Text FormattingUsing macros in LaTeX but then removing them from source code for others?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
OGBond
Posts: 2
Joined: Mon Nov 14, 2022 11:45 pm

Using macros in LaTeX but then removing them from source code for others?

Post by OGBond »

I am currently using LyX for my mathematical typesetting, and I really like the macro functionality. However, I can imagine that the source code from such an output must be a pain for others to look at.

I am curious to know if there is a way of "flattening" any LaTeX output that arises from macros? Consider the following minimal example (with the preamble and document begin/end declarations removed):

\global\long\def\testMacroA#1{{\color{red}#1}}%
\global\long\def\testMacroB#1{\tilde{#1}}%
\global\long\def\testMacroC#1{\underrightarrow{#1}}%

$\testMacroA{\testMacroB{\testMacroC A}}$

Is there anything in LaTeX that can be used to remove any trace of the original macros and replace any instances of them with the code that they represent, so that when the source code is compiled, it simply gives

${\color{red}\tilde{\underrightarrow{A}}}$ ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Post Reply