I want to evaluate whether my variable \x (that comes from a foreach loop) is the same as my current section number. I tried
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{totcount}
\regtotcounter{section} % total amount of sections
\begin{document}
\begin{frame}
\section{This is the first section} \label{sec:this_is_the_first_section}
Some Text.
\section{This is the second section} \label{sec:this_is_the_second_section}
Some Text.
\section{This is the third section} \label{sec:this_is_the_third_section}
Some Text.
\foreach \x in {1,...,\totvalue{section}}{
\arabic{section} = \x
\ifx\x\value{section}
check
\else
no
\fi}
\end{frame}
\end{document}
but this always returns a "no" where in the last case it should return a "check". Do I have to use a different form of the "if"-case (i tried
\ifnum{\value{\x}}={\value{section}}
but that didnt even compile) or am I trying to compare different variable types that can't be compared like that? What would be the correct commandline to compare the values?

\ifnum\x=\value{section}is more correct (with a space at the end). (Note this doesn't answer any part of the question, it's just a suggestion.) – Manuel Sep 07 '17 at 15:48\ifnum\x=\thesection, works fine with beamer, see for example https://tex.stackexchange.com/a/313579/36296 for an application. – samcarter_is_at_topanswers.xyz Sep 07 '17 at 15:48\value{section}gives a TeX count register. So the space token is not swallowed by the\ifnumtest and depending on context may actually show in output. – Sep 07 '17 at 15:51\thesectioncan expand to something likeAorA.2etc. In this case\ifnumwould be useless with\thesection. Don't trust\the...macros expanding to literal numbers – Sep 07 '17 at 15:51\the...it will break somewhere for someone and the user will come back to this site and ask a questions you can answer. – samcarter_is_at_topanswers.xyz Sep 07 '17 at 16:00