8

A previous question What is the difference between \def and \newcommand? has discussed the difference between \def and \newcommand at some length. However, I cannot find in that discussion an explanation of the following phenomenon.

This code prints Empty:

\documentclass{article}
\begin{document}
\def\foo{}
\ifx\foo\empty Empty\else Not empty\fi
\end{document}

This code prints Not empty:

\documentclass{article}
\begin{document}
\newcommand\foo{}
\ifx\foo\empty Empty\else Not empty\fi
\end{document}

The only difference is that one has \def and the other has \newcommand. What's going on?

0 Answers0