2

The integers modulo n, given by

\mathbb{Z}/n\mathbb{Z}

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

\newcommand{\Z[character]}{\mathbb{Z}/[character]\mathbb{Z}}

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 Nov 4 '11 at 4:06
9
\newcommand\Z[1]{\mathbb{Z}/#1\mathbb{Z}}
  • And use it as $\Z{n}$. – Leo Liu Nov 4 '11 at 2:26
9

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

\newcommand{\Z}[1]{\ensuremath{\mathbb{Z}/#1\mathbb{Z}}}
  • Eek, sorry. This is nearly a duplicate of Leo's. That'll learn me to refresh... – qubyte Nov 4 '11 at 2:57
  • 3
    It's fine. This question is trivial for all experienced LaTeX users, but fewer ones know \ensuremath. – Leo Liu Nov 4 '11 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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