4
$\begingroup$

I'm surprised that $\pmod {a\over b}$ renders differently from $\pmod {{a\over b}}$

$\pmod {a\over b}$ vs $\pmod {{a\over b}}$ or as a bitmap: rendering

That seems to be a parsing bug. It gets worse:

$2^{p-3\over 2}\equiv\pm1\pmod{p-1\over2}\Longleftarrow{ p-1 \over 2 } \text{ prime}$

gives : $2^{p-3\over 2}\equiv\pm1\pmod{p-1\over2}\Longleftarrow{ p-1 \over 2 } \text{ prime}$ rather than: $2^{p-3\over 2}\equiv\pm1\pmod{{p-1\over2}}\Longleftarrow{ p-1 \over 2 } \text{ prime}$

$\endgroup$
3
  • 4
    $\begingroup$ I tested this in my regular LaTeX system. The output is similar. Therefore I am willing to declare that there is no bug in how MathJax handles this. It is rather about how LaTeX works. But, I'm afraid I cannot explain why TeX works this way. Somehow the scope of \over is surprisingly wide or something? My suggestion is that you can ask at TeX.SE for an explanation. Do search their site first! $\endgroup$ Commented Feb 28, 2018 at 9:04
  • 3
    $\begingroup$ Anyway, I want to declare this not-a-bug. A feature, if you prefer :-) $\endgroup$ Commented Feb 28, 2018 at 9:05
  • $\begingroup$ @JyrkiLahtonen, I agree, this is not a bug (in MathJax). $\endgroup$ Commented Mar 1, 2018 at 14:35

2 Answers 2

6
$\begingroup$

\pmod{\frac{p-1}2} gives $\pmod{\frac{p-1}2}$ as hoped. May be you should not use \over to typeset a fraction?

$\endgroup$
3
  • 3
    $\begingroup$ This thread in TeX.SE has more information. $\endgroup$ Commented Feb 28, 2018 at 9:14
  • 3
    $\begingroup$ Some other plain TeX features go bad when used in LaTeX. $\endgroup$
    – GEdgar
    Commented Feb 28, 2018 at 11:28
  • $\begingroup$ Very true, @GEdgar. I was surprised to learn that I'm not really supposed to use double-dollars in LaTeX.. Well, I learned TeX when typesetting my dissertation, and plainTeX was all we had at the time. $\endgroup$ Commented Feb 28, 2018 at 14:26
9
$\begingroup$

The reason for this is that \over takes as the numerator everything up to the preceding open group (usually {) and as denominator everything up to the following close group (usually }). But in your case, these aren't the ones that they appear to be. Because \pmod is a macro, the braces in {a\over b} are used to delimit the argument to \pmod, and are not part of that argument itself. That is, \pmod gets a\over b as its argument. In TeX, the definition of \pmod is

\def\pmod#1{\allowbreak \mkern 18mu({\rm mod}\,\,#1)}

so $\pmod {a\over b}$ becomes $\allowbreak \mkern 18mu({\rm mod}\,\,a\over b)$, and that produces the

$$\mkern 18mu({\rm mod}\,\,a\over b)$$

that you see because the preceding and following end groups are the beginning and ending of the math itself. That is also why \pmod {{a\over b}} produces the desired result, because the inner braces become part of the argument to \pmod, and so are retained in the macro substitution, and isolate the fraction as you expect.

This is how macros in TeX work, and it is the expected behavior of this definition. MathJax's definition for \pmod is similar, but without the \allowbreak (which isn't defined in MathJax).

$\endgroup$

You must log in to answer this question.

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