February 20, 2005

LaTeX mod spacing

In my modern algebra class, we've been working extensively with congruence modulo n. LaTeX has several options for typesetting these statements in the amsmath package. Here you can see what they look like:

LaTeX mod samples

Statements 1 and 2 were rendered using "1 \equiv 4 \mod{3}" and "-1 \equiv 2 \bmod{3}" respectively. Generally the methods using parenthesis are preferred. We also have two standard versions of those. Statement 3 uses "\pmod" and Statement 4 uses "\pod". I prefer the way "\pmod" renders however, despite claiming to reduce the spacing before the parenthesis in non-display mode, it stills leaves too big a gap for my taste.

I thought i would share this trick i found in a guide on the Dartmouth College website. It suggested defining a new command to reduce the amount of space and make everything look better. Statement 5 is rendered using this new "\imod" command. Here's the defintion:

\makeatletter
\def\imod#1{\allowbreak\mkern10mu({\operator@font mod}\,\,#1)}
\makeatother

Posted by Matthew at February 20, 2005 05:58 PM
Comments

This post nearly perfectly expresses my frustration with TeX, and TeX-based dialects (LaTeX, ConTeXt).

Posted by: William Clifford at February 22, 2005 07:40 AM

Hey, thanx for this nice hint. Helped me a lot (:

Posted by: Andreas Hermann at May 10, 2007 11:38 AM