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 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
1
  • What's your issue? Fragile commands are relevant for writing to files. Mar 29, 2013 at 15:14

1 Answer 1

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
3
  • 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, 2013 at 16:37
  • @kromo why would it "blow up"? did you try it? I assume not. Mar 29, 2013 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, 2013 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .