I've been using Herbert's answer in Check for empty macro argument to check if an argument is empty. I was wondering if it is possible to expand Herbert's solution to also detect if a macro argument is \empty. Failing this, I was hoping to learn a way to set a macro in so that \ifempty will behave like I want. The following code shows that \ifempty correctly detects an empty macro argument, but does not consider \empty to be an empty argument. Then, I give a couple of unsuccessful attempts to define an empty macro.
\documentclass{article}
\makeatletter
\def\ifempty#1{%
\if\relax\detokenize{#1}\relax%
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\makeatother
\begin{document}
\ifempty{}{1. empty}{1. nonempty}
\ifempty{\empty}{2. empty}{2. nonempty}
\def\z%
\ifempty{\z}{3. empty}{3. nonempty}
\def\z{}%
\ifempty{\z}{4. empty}{4. nonempty}
\end{document}
\def\a{\b}\def\b{}\ifempty{\b}yield? Can we assume one token in the input for a command? Is\def\a#1{stuff}\ifempty{\a}a danger? – Joseph Wright Dec 26 '13 at 09:39\ifemptymacro within commands, and it has met my needs. Recently I wanted to test if a string option fromkvoptionswas empty. According to the documentation, "The initial contents of the macro can be given by the first optional argument\@empty, and I would like to be able to test this. For my particular needs, the command does not need to be particularly robust, and a simple elaboration to the the case I just described would be nice.\def\z<???>that will make\ztrigger the\ifemptymacro. – Stirling Dec 26 '13 at 19:26