6

I would like to say a congruence holds modulo a fairly large expression, THING, to be enclosed parenthetically.

\left( \mod{THING}\right)

seems to result in a large space between the open paren and the "mod," and

\pmod{THING}

produces parentheses too small for my taste. Is there an option less hacky than just using an \mbox?

0

3 Answers 3

5

Using the amsmath definition seems better; I'll also use mathtools for the growing parentheses.

\documentclass{article}
\usepackage{mathtools}

% Here's how amsmath defines \pmod
% \newcommand{\pod}[1]{\allowbreak
%   \if@display\mkern18mu\else\mkern8mu\fi(#1)}
% \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}

\makeatletter
\DeclarePairedDelimiterX{\pmodx}[1]{(}{)}{{\operator@font mod}\mkern6mu#1}
\renewcommand{\pmod}{%
  \allowbreak
  \if@display\mkern18mu\else\mkern8mu\fi
  \pmodx
}
\makeatother

\begin{document}
\begin{align*}
a &\equiv b \pmod{n}\\
a &\equiv b \pmod[\big]{n}\\
a &\equiv b \pmod[\Big]{\frac{n}{2}}\\
a &\equiv b \pmod[\bigg]{\sum_{k=1}^n k^2}\\
a &\equiv b \pmod*{\sqrt{\sum_{k=1}^n k^3}\,}
\end{align*}
\end{document}

It would be easy to define also \pod with the same idea.

enter image description here

It's not a good idea to use \mod, which is defined to be like \pmod but without parentheses.

5

The commands \mod and pmod are intended to be used like

 x\equiv y\pmod b \qquad x\equiv y\mod c

enter image description here

and not in the way you are using them.

You probably want a new operator like this:

\DeclareMathOperator{\mymod}{mod\,}

and then use Bigl and Bigr or similar to have larger parenthesis:

\documentclass{article}

\usepackage{amsmath}

\DeclareMathOperator{\mymod}{mod\,}

\begin{document}
\[
\Bigl(\mymod\text{THING}\Bigr)
\]
\end{document} 

Output:

enter image description here

3

The command \mod introduces some hard coded kerning which you see here. You can just define a new command with the kerning you like. However, \pmod keeps this kerning in front of the parentheses. If you want to stick to that, you should do the second approach.

Personally, I do not like to use \left(\right) as it makes more harm then help. Therefore, I would define some simpler \mod-command for my uses and use the best matching brackets manually.

% arara: lualatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{lua-visual-debug}
\makeatletter
\newcommand{\myMod}[1]{\allowbreak \if@display \mkern 18mu \else \mkern 0mu\fi {\operator@font mod}\,\,#1} % 0mu was 12mu for the math mode in the orignial defintion
\newcommand{\myPMod}[1]{\allowbreak \if@display \mkern 18mu\else \mkern 8mu\fi \left({{\operator@font mod}\mkern 6mu #1}\right)} % replaced () by \left(\right) in respect to the original definiont
\makeatother    

\begin{document}
% The original \mod 
$\mod{Thing}$

% \mod redefined in order to kick out the math style kerning
$\left(\myMod{Thing}\right)$

% The original \pmod
$\pmod{Thing}$

% \pmod redefined with \left(\right) instead of normal parantheses
$\myPMod{Thing_{g_{g_g}}}$
\end{document}

enter image description here

You must log in to answer this question.

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