2

I don't understand why there is extra space before the mod in this formula. How can I force the m and the 0 to be aligned vertically?

enter image description here

Here is the LaTeX code I'm using.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align} f(x)&=\begin{cases} \mod(x , 3) &\text{; if } x \neq 0\ 0&\text{; if } x = 0 \end{cases} \end{align}

\end{document}

2 Answers2

2

For such usage you want to do

\DeclareMathOperator{\opmod}{mod}% mod as operator

Full example:

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator{\opmod}{mod}% mod as operator

\begin{document}

\begin{align} f(x)&=\begin{cases} \opmod(x, 3) &\text{; if } x \neq 0\ 0 &\text{; if } x = 0 \end{cases} \end{align}

\end{document}

enter image description here

I'd remove the semicolons.

Why not \bmod? Compare the result of

6\bmod(x,3)

with

6\opmod(x,3)

enter image description here

egreg
  • 1,121,712
1

Using \bmod does the trick. as pointed out by daleif, \mod assumes there is space before it.

Sebastiano
  • 54,118