18

When trying to use the mod function that LaTeX offers, I always meet a problem: it seems to have a space or two in front of it that I can't delete without \hspace. Why is that and how can I fix it?

What shows up: $(\mod n)$

Enter image description here

What I want: $(\hspace{-0.3cm}\mod n)$

Enter image description here

1 Answer 1

39

See section 5.2 of the amsmath manual for the details of \mod and related commands (\mod, \pmod, \bmod, \pod) but the short version is that if you want parens around it, you should use \pmod:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
  1+1 \equiv 0 \pmod{2}
\end{equation*}
\end{document}

enter image description here

enter image description here (Taken from Version 2.1)

6
  • 1
    +1: I took the liberty to modify your answer. Jul 6, 2021 at 3:30
  • 1
    Ohhh do I have to import amsmath every time? Is it supported natively in LaTeX? btw why this TeX community doesn't support LaTeX in the questions and answers :/
    – CELLSecret
    Jul 6, 2021 at 5:23
  • 7
    @CELLSecret any latex document with a serious amount of math should load amsmath, it is the core latex math support, part of the "required" package distribution, that said, as it says in the quote above, \pmod`` is defined in the format, not in amsmath`. We don't support mathjax on this site because this is about TeX, see tex.meta.stackexchange.com/questions/1272/… Jul 6, 2021 at 5:57
  • \pmod, \bmod etc. macros are defined in plain TeX too. We need not LaTeX.
    – wipet
    Jul 6, 2021 at 16:04
  • 1
    @DavidCarlisle I think you put the ` in the wrong place lol
    – CELLSecret
    Jul 7, 2021 at 0:10

You must log in to answer this question.

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