2

A similar question has been already asked here, but has not been answered yet for fragile commands such as eg. \@author?

What would be the right way to get detect if \author has been called with a value:

\usepackage{ifthen}
\usepackage{xifthen}
\usepackage{etoolbox}

\makeatletter

\ifXXXXXX{\@author}%
{%  
    author set \par
}{%
    author not set at all \par
    or set to \{\} () \par
    or to {\textbackslash}empty
}%

\makeatother
  • What's your issue? Fragile commands are relevant for writing to files. – Marco Daniel Mar 29 '13 at 15:14
8

\@author isn't typically a fragile command (It depends on the Author's name I suppose) However testing its value is not related to fragile/robust distinctions.

Initialise the macro, say

\let\@author\@empty

then later test if it still has that value

\ifx\@author\@empty
    still empty
 \else
     author has been set
 \fi
  • I am trying to write a .sty file. Means the output is set outside my file. So if anyone comes up with the idea to use a set up like \autho{Name1 \and Name2} the conditional blows up. I would like to make it failsafe (as it can be)... – ViToni Mar 29 '13 at 16:37
  • @kromo why would it "blow up"? did you try it? I assume not. – David Carlisle Mar 29 '13 at 16:48
  • Works now. Don't know where the error came from. Only backdraw, my nice \@latex@warning don't work anymore (mine and the ones from \@author). ;-) Thanks! – ViToni Mar 29 '13 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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