1

Please consider the following MWE:

\documentclass{article}
\usepackage{siunitx, etoolbox}
\newcommand{\testa}{Some text}
\newcommand{\testb}{40}                                                                                                   
\begin{document}
\begin{itemize}
  \item Item 1
%  \ifnotnull{\testa}{\item This appears only if testa is not null}{\item Oh! testa is null}
  \ifnumgreater{\testb}{49}{\item This appears only if testb is greater than 49}{\item Oh! testb is lesser than 49} 
\end{itemize}
\end{document}

What command do I use in place of \ifnotnull to check if \testa is/ is not null?

deshmukh
  • 2,435
  • 1
  • 26
  • 46
  • Don't use numbers in command names. Also always make complete examples. Beside this try \ifnumequal{0\test}{0}... – Ulrike Fischer Feb 02 '15 at 10:53
  • see the various macros in etoolbox, hint \ifblank cannot test on macros. But is nice to test if say #1 is empty – daleif Feb 02 '15 at 11:17
  • @UlrikeFischer edited the question to include a MWE. Also, `\ifnumequal{0\testa}{0}did not work. – deshmukh Feb 02 '15 at 11:21
  • 2
    Well it did work with you previous example (where the commands contained only numbers). If the command can arbitrary text try \ifdefstring{\testa}{}.. – Ulrike Fischer Feb 02 '15 at 11:28
  • @UlrikeFischer I agree. It did work with numbers. Shows why is it important to have MWEs! And yes, \ifdefstring works as expected. Also, if you could please add that comment as an answer, I will accept it – deshmukh Feb 02 '15 at 11:31
  • @daleif did that --- texdoc etoolbox. Thanks for reminding to RTFM :) – deshmukh Feb 02 '15 at 11:33
  • See also here for a related issue: http://tex.stackexchange.com/questions/53068/how-to-check-if-a-macro-value-is-empty-or-will-not-create-text-with-plain-tex-co – Ubiquitous Feb 02 '15 at 13:13

0 Answers0