I am struggling with the use of conditionals, I have a basic example given below that will output the table included.
The code starts by defining \myletterA
as the A character, and an array called \test
as A,B,C. I have a function called \indenterer
that I call inside my table loop below.
\documentclass[12pt]{article}
\usepackage[a6paper,landscape]{geometry}
\usepackage{arrayjobx}
\usepackage{ifthen}
\def\tand{&}
\begin{document}
\newcommand{\myletterA}{}
\newcommand{\myletterwriter}[1]{\renewcommand\myletterA{#1}}
\myletterwriter{A}
\newarray\test
\newcommand{\indenterer}{%
\readarray{test}{A&B&C}%writes A,B,C to array test
\checktest(1)%reads the first value
\cachedata%returns the value last read by \checktest
\myletterA%returns the value stored i.e. A
\ifx\cachedata\myletterA%
a% \true case
\else%
b% false case
\fi%
}
\newcounter{it}
\begin{tabular}{ll}%
\hline%
\setcounter{it}{1}%
\whiledo{\theit<4}{%
{\indenterer} Y \tand z \\%
\stepcounter{it}%
}%
\end{tabular}
space
\checktest(1)
\cachedata
\myletterA
\end{document}
The output lines of the table should display \cachedata\myletterA_ Y Z
where the _ is either an a or b. So my question is why is this code always executing the false case (note the letter b instead of a) even though both \cashdata
and \myletterA
expand to give the same result?
\newcommand{\myletterwriter}[1]{\renewcommand*\myletterA{#1}}
? – egreg Jan 19 '16 at 20:21\indenterer
, just before\ifx
add\show\cachedata\show\myletterA
and you'll see\cachedata
is just a "macro", while\myletterA
is a "long macro". – Werner Jan 19 '16 at 20:35