# Print macro content with condition

I would like something like the following:

\documentclass{article}
\newcommand{\acell}{}
\newcommand{\bcell}
\newccomand{\zcell}[1]{#1}
\ifx\acell{A}
\ifx\bcell{A}
\zcell{yes}
\else
\zcell{no}
\fi
\else
\fi
\begin{document}
\begin{tabular}{ccc}
\acell{A} & \bcell{A} & \zcell{} \\
\acell{A} & \bcell{B} & \zcell{} \\
\end{document}


But this code does not work. It does not print "yes" and "no" where the 'zcell' macro is. Is it possible to achieve this?

-
Yes, it is, but under which rules? Besides the errors pointed out by David Carlisle, the conditions aren’t even inside a command but just in the preamble (and \newccomand is mis-typed). Do you want to test both cells whether they are A? – Qrrbrbirlbel Jun 8 '13 at 1:00

Your question isn't very clear (and your example is very incomplete) but I think you want

\documentclass{article}
\newcommand{\acell}[1]{\gdef\acontent{#1}#1}
\newcommand{\bcell}[1]{\gdef\bcontent{#1}#1}
\def\atest{A}
\newcommand{\zcell}{%
\ifx\acontent\atest
\ifx\bcontent\atest
yes%
\else
no%
\fi
\else
no%
\fi}
\begin{document}
\begin{tabular}{ccc}
\acell{A} & \bcell{A} & \zcell \\
\acell{A} & \bcell{B} & \zcell
\end{tabular}
\end{document}


\newcommand{\acell}{}


defines \acell to take no arguments and expand to nothing but you were using it as if it took an argument.

\newcommand{\bcell}


is a syntax error (you haven't provided a definition at all)

\newccomand{\zcell}[1]{#1}


just defines \zcell to echo its argument.

\ifx\acell{A}


is not in any definition and compares the token \acell to the token { then skips to the matching \fi as those tokens are not equal.

-
You add a picture :-) -- Should I add one too. – Marco Daniel Jun 7 '13 at 23:05

You can do the following whereby I don't know what you want to achieve:

\documentclass[11pt]{article}
\makeatletter
\def\acell#1{\gdef\@acell{#1}}
\def\bcell#1{\gdef\@bcell{#1}}
\def\zcell{%
\ifx\@acell\@bcell
yes\acell{a}\bcell{b}%
\else
no
\fi%
}
\makeatother
\begin{document}
\begin{tabular}{ccc}
\acell{A} & \bcell{A} & \zcell{} \\
\acell{A} & \bcell{B} & \zcell{} \\
\end{tabular}
\end{document}


Some other hints:

-