I am a LaTeX user with moderate experience. However, I am trying to create my own .cls file for the first time. I would like to produce a header in a similar fashion to how title is produced in article class. Something along the following lines.


\name{Your Name}


I know the basics of how to use \newcommands to define these. But, I am not able to figure out how to access values of the fields like \name, \phone inside the definition of \headerbox.

  • 1
    Welcome to TeX.SX! One usually says \newcommand\name[1]{\gdef\rajvi@name{#1}} and then uses \rajvi@name when the actual name is needed; rajvi stands for the prefix you'll be using for the macros in your class. – egreg Jun 23 '13 at 9:20
  • See also here: tex.stackexchange.com/questions/10130/… – Marco Daniel Jun 23 '13 at 9:43

The trick generally used is to say in the class file


and then using \rajvi@name where needed.

You should supplement this with a default definition, such as

  \ClassWarningNoLine{rajvi}{No \protect\name\space supplied}%

so that the user will be warned about missing data and a pair of question marks will appear in the output. This might be made into an error, just choose the way you prefer.

With rajvi I mean the common prefix (often the class name) you use for avoiding macro conflicts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.