# Very simple condition in macros

I try to define a macro in LaTeX. This macro should give a different output when I use condition true and false.

This does not work:

\documentclass{article}
\usepackage{lipsum}
\newif\ifABC
\ifABC
\newcommand{\abcdef}[1]{{Letters} #1}%
\else
\newcommand\abcdef[1]{}
\fi

\begin{document}
\ABCtrue
\abcdef{ABC}
\lipsum[2]

\end{document}%


How I should define conditional macro?

-
Welcome to TeX.SX! – egreg Dec 4 '13 at 12:05
I am very beginner in terms of macros in TeX. Thank you, @Ian, @egreg! – Ama Dec 4 '13 at 13:29

You need to check the conditional when the macro is executed, not when it is defined.

\documentclass{article}
\usepackage{lipsum}
\newif\ifABC
\newcommand{\abcdef}[1]{\ifABC{Letters} #1\fi}
\begin{document}
\ABCtrue
\abcdef{ABC}
\lipsum[2]
\end{document}%

-