4

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.

\documentclass{MyResume}

\name{Your Name}
\phone{281038901}
\email{xyz@example.com}

\begin{document}
 \maketitlebox
\end{document}

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.

Marco Daniel
  • 95,681
rs_
  • 175
  • 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 09:20
  • See also here: http://tex.stackexchange.com/questions/10130/use-the-values-of-title-author-and-date-on-a-custom-title-page – Marco Daniel Jun 23 '13 at 09:43

1 Answers1

5

The trick generally used is to say in the class file

\newcommand{\name}[1]{\gdef\rajvi@name{#1}}

and then using \rajvi@name where needed.

You should supplement this with a default definition, such as

\def\rajvi@name{%
  \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.

egreg
  • 1,121,712