# \def\Command#1{\def\command{#1}} - Why?

I am dealing with a proprietary .cls file, which has a lot of constructions that work like this: a capitalized Macro (made-up, not existing in the packages loaded) is def'ed to be the lower-case version of this macro(also made up). This macro is then later used to def or (re)newcommand other stuff, relating to packages or simply for layout. - My question is threefold:

• Why does the syntax \def\MyCoverText#1 work at all? - I read this description of \def, and it does not seem to allow for a non-braces-encapsulated first argument, so i'd have thought it would need to be \def\MyCoverText[#1]
• What is the upside of the \def\C#1{\def\c{#1}} construct? I tentatively replaced it by a direct def of command, and it seems to work like before.
• Is there a name for C->c, or for the practice of saying C#1 instead of C[#1]?

.cls file:

\ProvidesClass{myclass}[My class]
\def\MyCoverText#1{\def\mycovertext{#1}}
\MyCoverText{Hello World}
% i replaced the two above lines by:
% \def\mycovertext{Hello World}
% to no obvious ill effect
\newcommand{\mycover}{
\thispagestyle{empty}
\newpage\null\vskip 3em%
\begin{center}
\mycovertext
\end{center}%
}


.tex file:

\documentclass{../myclass}
\begin{document}
\mycover
\end{document}


EDIT: pertaining to my confusion about \def, spurred by David Carlisles comments on it, i found this, which offers a host of different \def syntax versions and what they do. Really usefull stuff

• \def\C#1{\def\c{#1}}  The usual use is something like \def\title#1{\def\@title{#1}} which allows the author to use \title{my title} and have it internally saved in \@title for use by \maketitle (your use of camelcase for the user level command doesn't really follow latex naming guidelines) Apr 30, 2020 at 9:41
• \def\foo#1{} \nd \def\foo[#1]{} define completely different syntax, so it depends which you need. Apr 30, 2020 at 9:42
• Eek! Somewhat off-topic, but exceedingly important: Don't redefine \c! That is the canonical command for a cedilla. (You have no idea what consternation it produces among a journal's editorial staff when suddenly a French name is corrupted by such a thoughtless substitution.) Don't (re)define one-letter control sequences, Ever. Please. Apr 30, 2020 at 14:33
• On the naming convention see tex.stackexchange.com/questions/48195/… Apr 30, 2020 at 15:21
• @barbarabeeton thanks for the advice, but i just used c as a shorthand in describing this. the actual macros have ReallyLongAndImprobableNames, so editorial staff can sleep soundly tonight ;-) Apr 30, 2020 at 20:43

The most common use of this pattern is something like:

\def\Title#1{\def\title{#1}}


Now \Title{This is a title} defines \title to be "This is a title". That is, you have a command that expands to the document title, which I am sure you will agree is a useful thing. It is important to note that LaTeX is case sensitive, so \Title and \title are completely different commands, even though their names might suggest otherwise.

The \MyCoverText, \mycovertext and \mycover triple in the OP are similar. The initial \MyCoverText{Hello World} defines \mycovertext to be "Hello World" so that \mycover now expands to:

\thispagestyle{empty}
\newpage\null\vskip 3em%
\begin{center}
Hello World
\end{center}%


If you like, the \MyCoverText is a "setter" command and the \mycovertext" is a "getter" command - and \mycover is a getter with some additional formatting.

[In the LaTeX internals what normally happens is more like \def\title#1{\def\@title{#1} after which \@title expands to the title. This is slightly better because command names that contain the @ character are protected: if you use them without "escaping" them you will get an error.]

• Sorry if I just overwrote your edit accidentally. Apr 30, 2020 at 9:45
• @StevenB.Segletes Thanks for trying to correct my typos:)
– user30471
Apr 30, 2020 at 9:47
• So the style has no deeper relevance than sparing the user a \def later on? Apr 30, 2020 at 10:03
• .. In that i then only have to write \C{something} instead of \def\c{something} - in the non-protected version at least? Apr 30, 2020 at 10:09
• The point of these paired commands is not so much to save the user from using a \def.... later but, rather, to give the class/style a straightforward way to access the data. Continuing the example above, you often want to use the title in different parts of the document. Having setter and getter commands for this information allows you to set a default, using the setter, and then use the getter command safe in the knowledge that the code will continue to work if the user changes the title.
– user30471
Apr 30, 2020 at 18:22