I'd like to test the value of counters (preferably as vanilla TeX as it gets).
\documentclass{article}
\newcounter{counterA}
\newcounter{counterB}
\setcounter{counterA}{2}
\setcounter{counterB}{2}
\newcommand\maccommand{
\ifx\the\value{counterA}=\the\value{counterB}
Just so you know, counterA (= \the\value{counterA}) holds the same value as counterB (= \the\value{counterB}).
\else
Sorry, but the counterA (= \the\value{counterA}) is not equal to counterB (= \the\value{counterB}).
\fi
Yet in TeX you can write:
\ifx\counterA>2
Just so you know, counterA is greater to than 2.
\else
Just so you know, counterA is not greater than 2.
\fi
}
Why can't you write
\ifx\counterA=2
Just so you know, counterA is equal to 2.
\else
Just so you know, counterA is not equal to 2.
\fi
}
OR
\ifx\counterA=\counterB
Just so you know, counterA is equal to counterB.
\else
Just so you know, counterA is not equal to counterB.
\fi
}
Best Answer
\thecounterA
works only if the counter wasn't redefined:The TeX way:
Internally
\c@counterA
holds the value and\thecounterA
is the representation. On LaTeX level\c@counterA
shouldn't be used.