I have seen the following definition in a class file (which we use internally):
\newcommand{\@TitleBackground}{default}
\newcommand{\titlebackground}{\renewcommand{\@TitleBackground}}
This provides \titlebackground
as a command for changing \@TitleBackground
, but how/why does it work?
I would understand it if the second line was
\newcommand{\titlebackground}[1]{\renewcommand{\@TitleBackground}{#1}}
but why does it work also without the argument, i.e, with \renewcommand
having onle one parameter?
And does the shorter version has some advantages or disadvantages over the longer one?
\titlebackground{something}
, TeX expands\titlebackground
to\renewcommand{\@TitleBackground}
and you have\renewcommand{\@TitleBackground}{something}
, which is slightly faster than grabbing the argument once, and passing it again to\renewcommand
(which is not wrong either).