I'm trying to learn how to write latex classes and am using my resume as a toy example. I am trying to separate style from content as much as possible so I am trying to define data fields such as \name \address \university, similar to those that I have seen in \maketitle. Some of the fields of each of these are to be optional. I have a working example but since this is my first attempt at writing a latex class, I wanted to ask how I should be defining the class's metadata.
My attempt so far is like so (optional second line for the address):
\RequirePackage{xkeyval} % for keyval
\newif\ifAddressLineTwo\AddressLineTwofalse
\newcommand{\@address@firstline}{}
\newcommand{\@address@secondline}{}
\newcommand{\@address@town}{}
\newcommand{\@address@postcode}{}
\define@key{address}{first_line}[none]{%
\renewcommand{\@address@firstline}{#1}%
}
\define@key{address}{second_line}[none]{%
\AddressLineTwotrue
\renewcommand{\@address@secondline}{#1}%
}
\define@key{address}{town}[none]{%
\renewcommand{\@address@town}{#1}%
}
\define@key{address}{postcode}[none]{%
\renewcommand{\@address@postcode}{#1}%
}
\newcommand\address[2][]{%
\setkeys{address}{#2}%
}
\newcommand{\makeCV}{%
\@address@firstline\\%
\ifAddressLineTwo
\@address@secondline\\%
\fi
\@address@town\\%
\@address@postcode%
}
This works okay for me, I can type
\address
{
first_line= my road
%second_line=my county,
town=my city,
postcode=my post code
}
\makeCV
but it the class seems a little verbose? In particular, having to define all those \newcommand{...}{} and all the various \newif 's seems a little verbose.
My question is how should I be doing this task properly?