TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am defining a new command and a flag with:



Calling the command as following with


results in compilation error Missing = inserted for \ifnum as if the parameter given to \ifnum is not an integer. What am I missing here ?

share|improve this question
Note you should have a % at the end of every line that ends with { or } (but not 1) otherwise use of this command will generate white space in the printed output. – David Carlisle Sep 2 '14 at 13:20
The {} trick should be used only when you want to ensure that following spaces are not gobbled, so usually for commands that do typesetting. – egreg Sep 2 '14 at 13:38

You shouldn't have the empty braces after \flag.

     \typeout{NOT ONE!}



Here I have disabled the two macros whose definition I do not have, and used \typeout to display a message in the terminal, to show that the modified code works.

The problem with the original version is that #1 expands to the number 0 followed by an empty group. This combination is not a number, so it breaks the syntax for \ifnum. You could get away with \flag{} if you did


because then the expansion would yield \ifnum1=0{} which is ok.

share|improve this answer
Thanks ! Can you please explain why in this particular case I shouldn't use the empty braces ? – Manuel Selva Sep 2 '14 at 13:06
@ManuelSelva with the braces it is \ifnum0{}=1 which is a syntax error. – David Carlisle Sep 2 '14 at 13:18
@ManuelSelva --- I have edited my answer. – Ian Thompson Sep 2 '14 at 13:24
With \ifnum#1=1 the space token caused by the end-of-line is ignored. With \ifnum1=#1 it wouldn't when #1 is \flag{}. To cope with this you should have \ifnum 1=#1\relax – egreg Sep 2 '14 at 13:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.