I'm designing a new LaTeX class, and trying to write a convenient helper command for declaring new 'variables' for use in the class.
Specifically, say I want to use a variable called \foo
. I'd like an author to be able to write \foo{bar}
, and then be able to use \@foo
in the class file (which would itself expand to bar
. This can be accomplished with the following code:
\let\@foo\relax
\def\foo#1{\def\@foo{#1}}
and the author can define it with \foo{bar}
. I want to create a helper command that allows the variable declaration to be done with a command like \DeclareAuthorVariable
, which I would use in the LaTeX class file to declare variables. For example, I would like to be able to write \DeclareAuthorVariable{foo}
in the class file instead of the ugly two line mess above. I've tried a number of different approaches, but I'm having trouble figuring out how to do this, since the commands that I'm trying to replace themselves involve arguments. I'm wondering if anyone knows how to do this or if it isn't possible? Thanks!
(Also, apologies, I'm very new to LaTeX class design!)