我想說的是,同餘式對一個相當大的表達式 進行模運算,THING
並用括號括起來。
\left( \mod{THING}\right)
似乎導致開放括號和“mod”之間有很大的空間,並且
\pmod{THING}
產生的括號對我來說太小了。有沒有比只使用 更簡單的選項\mbox
?
答案1
使用amsmath
定義似乎更好;我還將用於mathtools
增長的括號。
\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}
\pod
用同樣的想法也很容易定義。
使用 不是一個好主意\mod
,它被定義為類似\pmod
但不帶括號。
答案2
命令\mod
和pmod
的用途如下
x\equiv y\pmod b \qquad x\equiv y\mod c
而不是你使用它們的方式。
您可能想要一個像這樣的新運算子:
\DeclareMathOperator{\mymod}{mod\,}
然後使用Bigl
andBigr
或類似的符號來獲得更大的括號:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\mymod}{mod\,}
\begin{document}
\[
\Bigl(\mymod\text{THING}\Bigr)
\]
\end{document}
輸出:
答案3
該命令\mod
引入了一些硬編碼的字距調整,您可以在此處看到。您可以使用您喜歡的字距調整來定義新命令。但是,\pmod
將此字距調整保留在括號前面。如果你想堅持這一點,你應該採取第二種方法。
就我個人而言,我不喜歡使用,\left(\right)
因為它弊大於利。因此,我會\mod
為我的用途定義一些更簡單的命令,並手動使用最佳匹配的括號。
% 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}