8

I'm writing a math text in spanish and want to change the definition of the "\mod" command. However, this seems impossible, as the following MWE shows:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\renewcommand{\mod}{\operatorname{changed}}

\begin{document}
$a \equiv b \mod c$
\end{document}

This produces the following output:

enter image description here

However, if I comment the line

\usepackage[spanish]{babel}

in the above code, the result I get is

enter image description here

as I would expect.

The same phenomenon happens with other math operators that carry accents in spanish, like for example "\max" or "\lim", but it works for such that don't have accents, like "\sin".

1 Answers1

14

I guess that your aim is to use the standard unaccented operator names.

The trick is explained it the manual for babel-spanish, section 5.5.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}

% no accents in math operators
\unaccentedoperators

\begin{document}

$a \equiv b \mod{c}$

$\lim_{x\to c}f(x)$

$\arcsin t$

$\max A-\min A$

\end{document}

enter image description here

Beware that \mod is not defined with \operatorname and your proposed redefinition would be bad anyway.

Anyway, here's a correct way to proceed:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}

%\unaccentedoperators

\makeatletter
\addto\mathspanish{\renewcommand{\mod}{\operatorname{m\es@op@ac od}}}
\makeatother

\begin{document}

$a \equiv b \mod c$

\end{document}

enter image description here

If you don't want the accent irrespective of \accentedoperators or \unaccentedoperators, remove the \es@op@ac command.

In general, I don't recommend redefining some standard command to do different things (apart from printing just a different symbol). Better defining \omod or whatever name you prefer.

egreg
  • 1,121,712
  • 2
    +1: Is \unaccentedoperators part of babel then? – Dr. Manuel Kuehner Nov 23 '18 at 10:05
  • 1
    @Dr.ManuelKuehner Yes, see babel-manual.pdf section 27 (which is about the Spanish language options). – alephzero Nov 23 '18 at 11:40
  • Actually I do want to use the accented versions because they seem to be quite standard in spanish math texts, and I do want \mod to behave like an operator (as this fits my mathematical needs better). For the same reason I want to redefine \lim to denote categorical limits instead of analytic ones, so in any case this wouldn't solve my issue. – Michael Fütterer Nov 23 '18 at 17:11
  • @MichaelFütterer I added a different version. I'm not sure where categorical limit notation is different from analytic notation. – egreg Nov 23 '18 at 18:11
  • Thanks, with that I'll be able to solve the problem! For the categorical limit I just realized that a solution is already described here https://tex.stackexchange.com/questions/342037/varprojl%c3%adm-and-varinjl%c3%adm – Michael Fütterer Nov 23 '18 at 18:45