[texhax] Macro that defines other macros

Niall Mansfield texhax at uit.co.uk
Mon Jul 9 16:41:44 CEST 2007

The macro below works, sort of.  We use it to define many (about 20)
"editorial marks" which show up in a draft manuscript.  E.g.

\defineedvis{CHANGEthis}{change this}

It's not perfect though: when e.g. \CHANGEthis{...}{...} is called,
it seems to swallow some stuff after the final curly bracket.
Is there an obvious mistake?  (As this is TeX code I suppose
I should sprinkle \relax's all over the place but why?)


%% Define a visible editorial mark, which shows MARGINTEXT as a note (in blue) in the margin,
%% and underlines the related text in the body.
%% \defineedvis{MACRONAME}{MARGINTEXT}
%% e.g. \defineedvis{TOBECHECKED}{not known} creates the macro:
%%		\TOBECHECKED{DATE}{Double-check this}
%% which we might use like
%% ... a big banana costs \TOBECHECKED{9-Jul-2007}{ten cents} from the local store
%% and then we get "9-Jul-2007 Double-check this" in the margin,
%% and "ten cents" underlined in the body text.

	\expandafter\def\csname #1\endcsname##1##2
		{\marginpar{\raggedleft\relsize{-3}\textcolor{blue}{\textbf{#2} ##1}}

More information about the texhax mailing list