Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LateX - If condition

I have some problem with the if condition in LateX. Is anyone can tell me why it never print "OK" ?

\def \scaleGraphX{0,20,30,40,50,60,70,80,100}

\foreach \x [count=\xi] in \scaleGraphX{
    \if \x = 0
        {OK} 
    \else 
        {PAS OK}
    \fi
}

Normally I should find at least 1 "OK"

like image 951
simsim Avatar asked Oct 21 '25 07:10

simsim


1 Answers

You can use \ifnum for numerical if tests:

\documentclass{article}

\usepackage{pgffor}

\begin{document}

\def\scaleGraphX{0,20,30,40,50,60,70,80,100}

\foreach \x [count=\xi] in \scaleGraphX{
    \ifnum\x=0
        {OK} 
    \else 
        {PAS OK}
    \fi
}



\end{document}
like image 195
samcarter_is_at_topanswers.xyz Avatar answered Oct 24 '25 04:10

samcarter_is_at_topanswers.xyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!