I would like to be able to replace every single user-defined macro in papers written in TeX by its definition. That is, if TeXing is considered to be a function f and my standardizing script is function g I want fg(x)=f(x)for any TeX code x that can be TeXXed without errors.
From similar questions others have asked before it is clear that this will require some really hard work because TeX is extremely customizable. Well, I still want to do it.
I do want to know what I'm about to get into though.
Do I essentially need to almost create half of a TeX engine (i.e. the input processor and the expansion processor)?
Assuming that the work is actually finished. Will I have to keep updating my code for the rest of my life in order for it to remain compatible with latest packages even though Knuth's TeX engine itself permanently remains stable?
If the goal in 1 and 2 are indeed infeasible for one person to reach during leisure time, is it feasible for me to achieve something less ambitious, namely making sure that at least 50% of the actually existing papers on arXiv gets successfully standardized? The papers are almost always written in LaTeX often using one of the AMS packages. However they tend to include low-level code such as
\defand sometimes even\letwhich causesde-macroto be ineffective in standardizing them.
I'm reading Knuth's The TeXbook right now.
For example one person may use
– Ying Zhou Apr 18 '19 at 04:28\cataas a shortcut for\mathcal{A}using\newcommand{\cata}{\mathcal{A}}while someone else may use\caas a shortcut for\mathcal{A}using\def\ca{\mathcal{A}}.My goal is for both cases to be expanded into\mathcal{A}.tikz-cdoramsthm. My problems are with user-defined ones in the beginning of papers, namely that long list of\defs,\newcommands,\lets and\DeclareMathOperators. – Ying Zhou Apr 18 '19 at 04:33\makeatletterand\makeatother. – Ying Zhou Apr 18 '19 at 04:35\usepackage,\RequiresPackage,\docmentclassetc. and only demacrofies\let,\def,\newcommand,\renewcommand,\DeclareRobustCommand, etc. within the document itself. That would cover the most common cases. Alternatively, write a full TeX parser but only un-macrofy definitions within the main document, not any packages itincludes. I’m not sure why you need to do this, however. – Davislor Apr 18 '19 at 07:12\cataand a latex defined macro\mathcalthey are both simply macros that expand to a list of tokens, so at what point do you want to stop expanding? this is a completely undefined problem, and a duplicate. – David Carlisle Apr 18 '19 at 10:37Yeah I think I will just modify
– Ying Zhou Apr 18 '19 at 14:28de-macro.