I tried to use ifdef
command for that, but it doesn't work. It outputs text when it's passed and executes the true branch.
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\NewDocumentCommand\MainCommand{m}
{
\ifdef{#1}
{
I received a command! #1
}
{
It's not a command( #1
}
}
\newcommand\somecommand
{
Text
}
\MainCommand{\somecommand}
\MainCommand{some text}
\end{document}
\ifcsname
, then you just need to passfoo
instead of\foo
.\foreach
. Don't.{\acommand some text}
a command or not a command?, why would you want\foo
to act differently tosome text
if defined by\def\foo{some text}
?\let\letterA=A
- is\letterA
a command? The entire directive\newcommand\foo{\bar}
can also be considered a command. Probably you can check blankness of the 1st argument. If not blank, check for explicit leading category-1-character-token. If no leading category-1 token extract the args 1st token and apply\meaning
and analyze the result thereof.