Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
share|improve this question
    
What's your issue? Fragile commands are relevant for writing to files. –  Marco Daniel Mar 29 '13 at 15:14
add comment

1 Answer

up vote 8 down vote accepted

\@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
share|improve this answer
    
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)... –  kromo 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! –  kromo Mar 29 '13 at 17:34
add comment

Your Answer

 
discard

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.