TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
\newcommand{\@director}{\@latex@warning@no@line{No \noexpand\director given}}
    \renewcommand{\and}{\unskip, }
    \renewcommand{\andnext}{\unskip, }
  {\@bspredirector \@director \@bspostdirector}%
  \large \lineskip .5em%

        \ifx\test\@empty Director\else Directors\fi%
        \protected\def\and{and }%
        \large \testdirector\par}

\title{A Title}
\author{An Author \and Another Author}
%\director{My Director \and My other Director}
%\director{My Director}


share|improve this question
up vote 2 down vote accepted

Since \director seems to be optional, say


instead of

\newcommand{\@director}{\@latex@warning@no@line{No \noexpand\director given}}

Then try

  \else{\@bspredirector \@director \@bspostdirector}%

So, if a \director command has not been issued, the test will be true and the \else part will be skipped.

share|improve this answer
Thank you, it worked! But could you explain me why you solution with \let and \ifx...\@empty works while David Carlisle's one with \newcommand doesn't? I imagin there is some difference between \@empty and 'nothing' (see David's answer) but I don't know it. – Ignasi Jun 29 '12 at 12:44
@Ignasi It would work if you said \newcommand*{\@director}{} (note the *): \newcommand{\@director}{} is equivalent to \long\def\@director{}, while \@empty is a non-\long macro. Besides, \let is more efficient. – egreg Jun 29 '12 at 12:49

If \director is optional then you don't want

 \newcommand{\@director}{\@latex@warning@no@line{No \noexpand\director given}}

you just want


Then (more or less) you don't need to test anything, just use \@director and it will be the author supplied name or nothing. You may need to make it a bit more complicated depending what you want to do pre and post director in the default (empty) case. I wasn't clear on that. But you could for example make all three internal commands empty and make director define the pre and post commands to use some spacing. So again, no testing is needed.

share|improve this answer
Thank you for your help. But I didn't worked as expected. I need to test that \@director is 'nothing' in order to avoid executing \predirector which pints 'Director (or Directors)'. How can I test this 'nothing'? – Ignasi Jun 29 '12 at 12:49
Tou could use \ifx\@empty as in @egreg's answer but as I say you don't need to test. You can define \@predirector to be empty {} and define \director to define \@directpr to the supplied name and \@predirector to "director or directors: " then \@predirector\@director does the right thing in both cases – David Carlisle Jun 29 '12 at 13:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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