I want to modify \maketitle command in a new document class based in memoir. \maketitle command should include a new \director command similar to author. If this command is defined in text file, the word Director (or Directors) followed by director's name is included in title but if not defined, nothing should appear.
Next code is a combination of the answers in How to count the number of authors of a document? and
How to make a new command similar to \author.
With second answer project directors name is added to title with \maketitle command and with the first one, the word Director or Directors is selected according command \and appering in \director command.
The problem is how to test if command \director is not used in order to avoid 'Director'.
I know how to add a \newif\director but not where to set and use.
\documentclass{memoir}% http://ctan.org/pkg/memoir
\makeatletter
\newcommand{\director}[1]{\gdef\@director{#1}}%
\newcommand{\@director}{\@latex@warning@no@line{No \noexpand\director given}}
\addtoiargdef{\director}{%
\begingroup\let\footnote\@gobble}{%
\begingroup
\renewcommand{\thanks}[1]{}
\renewcommand{\and}{\unskip, }
\renewcommand{\andnext}{\unskip, }
\renewcommand{\thanksmark}[1]{}
\renewcommand{\thanksgap}[1]{}
\protected@xdef\thedirector{#1}
\endgroup\endgroup}
\newcommand{\predirector}[1]{\def\@bspredirector{#1}}
\newcommand{\postdirector}[1]{\def\@bspostdirector{#1}}
\renewcommand{\maketitlehookc}{%
{\@bspredirector \@director \@bspostdirector}%
}
\predirector{\begin{center}
\large \lineskip .5em%
\printdirector\par
\begin{tabular}[t]{c}}
\postdirector{\end{tabular}\par\end{center}}
\newcommand\testdirector{%
\expandafter\tst@dir\@director\and\nil%
}
\def\tst@dir#1\and#2\nil{%
\edef\test{#2}%
\ifx\test\@empty Director\else Directors\fi%
}
\newcommand\printdirector{%
{%
\protected\def\and{and }%
\large \testdirector\par}
}
\makeatother
\title{A Title}
\author{An Author \and Another Author}
%\director{My Director \and My other Director}
%\director{My Director}
\date{\today}
\begin{document}
\maketitle
\end{document}
\letand\ifx...\@emptyworks while David Carlisle's one with\newcommanddoesn't? I imagin there is some difference between\@emptyand 'nothing' (see David's answer) but I don't know it. – Ignasi Jun 29 '12 at 12:44\newcommand*{\@director}{}(note the*):\newcommand{\@director}{}is equivalent to\long\def\@director{}, while\@emptyis a non-\longmacro. Besides,\letis more efficient. – egreg Jun 29 '12 at 12:49