# compare a value from \newcounter to value from \newcount

I searched for this topic, but I didn't find anything, so I hope this isn't a duplicate.

I've got the following code:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}

\begin{document}

\newcount\testA
\testA=1

\newcounter{testB}
\setcounter{testB}{1}

\ifnum\testA=\testB
TRUE
\else
FALSE
\fi


That is not working. It gets an error message. I also tried:

\newcount\testA
\testA=1

\newcounter{testB}
\setcounter{testB}{1}

\ifnum\testA=\value{\testB} %edit: solution is \value{testB}
TRUE
\else
FALSE
\fi


This works neither and gets an error message "undefined".

The workaround worked:

\newcount\testA
\testA=1

\newcounter{testB}
\setcounter{testB}{1}

\newcounter{temp}
\setcounter{temp}{\testA}

\arabic{temp}

\ifnum\temp=\testB
TRUE
\else
FALSE
\fi


How can I get this to work without the workaround? Is there a direct way.

• it's \ifnum\testA=\value{testB} Apr 15, 2016 at 6:37
• Of course. I supposed, that it is simple like that. Didn't see it though. Would you like to post this as an answer? Apr 15, 2016 at 6:40

The name of the internal counter is \c@testB. And \value will work if you remove the backslash.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}

\begin{document}

\newcount\testA
\testA=1

\newcounter{testB}
\setcounter{testB}{1}

\makeatletter
\ifnum\testA=\c@testB
TRUE
\else
FALSE
\fi
\makeatother

\ifnum\testA=\value{testB}
TRUE
\else
FALSE
\fi
\end{document}


The solution is to use

\ifnum\testA=\value{testB}