The integers modulo n, given by


is cumbersome to write. Accordingly, I would like to set up a new command that allows me to specify an input 'n'. Something like


But the above code is not right. Does anyone have any idea how this might be done?

  • 2
    This might be a little grumpy of me, but if you google "latex newcommand" you get all manner of links describing how it works, including this feature. The LaTeX wikibook (the first result) is a good source, by the way.
    – Ryan Reich
    Commented Nov 4, 2011 at 4:06

2 Answers 2

  • And use it as $\Z{n}$.
    – Leo Liu
    Commented Nov 4, 2011 at 2:26

If you want it to work in normal text mode too, i.e. without dollar signs:

  • Eek, sorry. This is nearly a duplicate of Leo's. That'll learn me to refresh...
    – qubyte
    Commented Nov 4, 2011 at 2:57
  • 3
    It's fine. This question is trivial for all experienced LaTeX users, but fewer ones know \ensuremath.
    – Leo Liu
    Commented Nov 4, 2011 at 3:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .