I'm currently in the process of writing my first document class file (a personalized resume class), and I want to get a better understanding of what exactly I'm doing. So, right now I'm setting up commands that allow for values to be assigned to variables (not sure if that's really the word I should be using), through a structure like this:
\newcommand{\institution}[1]{\def\@institution{#1}}
\newcommand{\datesattended}[1]{\def\@datesattended{#1}}
\newcommand{\degree}[1]{\def\@degree{#1}}
So, in the .tex file, the user can use the command \institution{University of Whatever} to save the string "University of Whatever" to \@institution, which is then later called within the class file by another command.
All of this works as I want it to, but now I'm hoping to create some conditional expressions to control the output. Like, I have a command \education that when called in the document will format an education section for a resume given the institution name, dates attended, degree info, etc. that the user had already entered. I want to be able to set it up in the class file to check if these \@variable variables have been defined, and then format the output differently based on which are defined and which are empty.
Primarily, I think a lot of my problem is that I don't actually understand what the \@variable definitions are or the scope of what I can do with them.
A full example of what I'm trying to achieve would be along the lines of (in LaTeX/pseudo):
\newcommand{\showeducation}{%
\@institutionname -- \@degree
if \@datesattended is defined:
\newline \@datesattended
clear \@institutionname, \@datesattended, \@degree
}
So, if \@datesattended were defined, the formatting would change to accommodate it. Otherwise, the command would just pass over it, printing the information that was given.
\defis just the primitive underlying\newcommandso there is no difference in the type of construct defined\degreeand\@degreeare both just control sequences referring to macros defined in your document, the@is just a letter in this context, it does not denote a "variable". You could use\newcommand{\degree}[1]{\newcommand\@degree{#1}}or\def\degree#1{\def\@degree{#1}}– David Carlisle Apr 18 '15 at 18:31\@somenamemacros are 'considered' internal commands which are not to be applied by the 'ordinary' LaTeX user (thereby being kernel or somewhat critical commands controlling a lot of internal setups, which may be corrupted by an unexperienced user) – Apr 18 '15 at 18:36\ifdefined\somecommand ... \else... \fi. It's a primitive – Apr 18 '15 at 18:40