Take the 2-minute tour ×
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.

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?

share|improve this question
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
add comment

2 Answers

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

Your Answer

 
discard

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.