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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply