# How to select conditional text?

I've three variable statements :

• Statement1 = You are Great Student.
• Statement2 = You are average Student.
• Statement3 = You Need improvement on list of topics mentioned below.

In the report card for student, I want to show one of this statement based on marks scored by the student [I'm reading marks from external csv file as \markscore]

• If value of \markscore is greater than or equal to 90 i want to print Statement1
• If value of \markscore is greater than or equal to 80 but less than 90 i want to print Statement2
• Else I want to print Statement3 in the report card.

Can you please suggest latex package to print statements conditionally?

You don't need a package:

\ifnum\markscore>89
statement 1
\else
\ifnum\markscore>79
statement 2
\else
statement 3
\fi
\fi

• Well, the 'official' LaTeX way is to use ifthen, but you knew that ;-) – Joseph Wright Oct 2 '13 at 7:28
• Thank You Sir for reply. While excuting tex file using xelatex ; i'm getting warnings mentioned below: ! Missing = inserted for \ifnum. <to be read again> . l.334 } ? ! Missing number, treated as zero. <to be read again> . l.334 } ? ! Missing = inserted for \ifnum. <to be read again> . l.334 } ? ! Missing number, treated as zero. <to be read again> . l.334 } – Pawan Mude Oct 2 '13 at 8:38
• In that case \markscore does not expand to an integer. I had to guess as you did not provide a real example document. Joseph did the same, – David Carlisle Oct 2 '13 at 11:05
• Thank You Sir. I've updated my CSV to store only integers and now warning is gone. – Pawan Mude Oct 2 '13 at 11:39

The 'official' way to do this is to use a package: traditionally ifthen but perhaps now you might choose etoolbox instead. I'll use ifthen, which here works reasonably clearly:

\documentclass{article}
\usepackage{ifthen}
\newcommand{\markscore}{90} % For testing
\begin{document}

\ifthenelse{\markscore<80}
{You need improvement on list of topics mentioned below}
{%
\ifthenelse{\markscore<90}
{You are average student}
{You are great student}%
}%
\end{document}


You could of course use the same logic as in David's answer and have the flow of statements perhaps a little clearer.

• Tbh my first reaction to the OP was \ifnum. So i, personally, would stick to DCs answer. I guess you aimed at the \ifnumless macro by bringing etoolbox into play. Therewith tex.stackexchange.com/questions/36201/… maybe is intereresting here. – Ruben Oct 2 '13 at 7:50
• Thank you Joseph. Somehow I'm getting warning mentioned below (while executing using xelatex) : (similar to one without package)! Missing = inserted for \ifnum. <to be read again> . l.333 } ? ! Missing number, treated as zero. <to be read again> . l.333 } ? ! Missing = inserted for \ifnum. <to be read again> . l.333 } ? ! Missing number, treated as zero. <to be read again> . l.333 } ? – Pawan Mude Oct 2 '13 at 8:44
• @PawanMude Are you trying exactly what I've put? If not, please detail what you've changed: if it's a big change then a new linked question might be best. – Joseph Wright Oct 2 '13 at 9:32
• Thanks Joseph, for your comments and sharing linked post. Somehow after making few changes in my code option mentioned by David is working without warning. I'll analyze it further. – Pawan Mude Oct 2 '13 at 11:37