## LaTeX forum ⇒ Math & Science ⇒ Recommend an \ifnum introduction

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
LaTexLearner
Posts: 138
Joined: Tue Mar 10, 2015 11:06 am

### Recommend an \ifnum introduction

Can anybody recommend an introduction to the `\ifnum` commands?

I can't make sense of code that has them but I'd like to learn how they work.

Thanks!

Tags:

cgnieder
Site Moderator
Posts: 1985
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:
`\ifnum` is a TeX primitive conditional for comparing integers:

`\ifnum1=1   true\else   false\fi % yields true \ifnum1<2   true\else   false\fi % yields true \ifnum1>2   true\else   false\fi % yields false \bye`

`\ifnum` and all other primitives are explained in the TeX book or in TeX by topic: texbytopic.

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

Stefan Kottwitz
Posts: 8704
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Perhaps you may also be interested in the ifthen package.

Also, some modern packages such as pgf provide tools for comparing or calculating. More complex calculations could be done using LuaTeX. I use LuaTeX and binary math for calculating subnet IP addresses, for example.

Stefan