I want to define macros within a personal package for a few variables (I don't even know if I should be calling them "variables") that may or may not be defined by the user. My approach so far is this:
\newcommand\@varname{}
\newcommand\varname[1]{\renewcommand\@varname{#1}}
\newcommand\printvarname{%
\ifthenelse{\equal{\@varname}{}}{}{\@varname}}
The first command defines an empty \@<varname>
; the second command provides a user level \<varname>
that set \@<varname>
to the value determined by the user; and the third command checks if \@<varname>
is been defined by the user, and if so, prints it.
Since I have a lot of those "variables" to set, can I have a \NewResettableCommand{<varname>}
(whose argument probably need to be set without the \
) that does all of the above?
BTW: I used \newcommand
(instead of \providecommand
) because I'm running tests in a .tex
file before create the packages.