7

When I try to compile this:

\documentclass{article}
\usepackage{amsmath}
\usepackage{nath}
\DeclareMathOperator{\argmin}{arg\,min}
\begin{document}
    \begin{equation}
        \argmin \log(\sum_{x=1}^2 x^2)
    \end{equation}
\end{document}

I get:

Test.tex:7: Limit controls must follow a math operator
Test.tex:7: Limit controls must follow a math operator

What exactly does this mean and how can I fix it?

4
  • Drop the nath package. Or rather, why are you using it? – Werner Dec 6 '13 at 4:32
  • @Werner: Oh, I'm trying to use it to auto-size parentheses. Is there a problem with using nath? – user541686 Dec 6 '13 at 4:41
  • You're already auto-sizing parentheses using \left...\right. Auto-sizing is not always the best... use the \big-family rather (also supplied by amsmath). – Werner Dec 6 '13 at 4:56
  • @Werner: Sorry I didn't mean to include the \left and \right, that was left over from my testing... will remove. – user541686 Dec 6 '13 at 4:57
9

In order for the automatic resizing of delimiters to work, nath redefines a lot of TeX internals. amsmath also defines a lot of TeX internals. Neither nath nor amsmath take into consideration that some other package might redefine the internal macros, and hence the error.

By default, \log is defined as follows:

> \log=macro:
->\mathop {\operator@font log}\nolimits .
l.3 \show\log

But, after loading amsopn (which is loaded by amsmath), we get

> \log=macro:
->\qopname \relax o{log}.
l.5 \show\log

This is the reason that the following minimal document fails:

\documentclass{article}
\usepackage{nath}
\usepackage{amsopn}

\begin{document}
$\log$
\end{document}

So, you must choose between loading amsmath and nath. For example, your minimal example can be processes without loading amsmath:

\documentclass{article}
\usepackage{nath}
\makeatletter
\def\argmin{\mathop{\operator@font arg\,min}\nolimits}
\makeatother

\begin{document}
\begin{equation}
  \argmin \log( \sum_{i=1}^2 x^2)
\end{equation}
\end{document}

Another option is to save and restore the meaning of operators like \log, \max,\arg, \sin, etc.

\documentclass{article}
\let\normallog \log
\usepackage{amsmath,nath}
\let\log \normallog
\makeatletter
\def\argmin{\mathop{\operator@font arg\,min}\nolimits}
\makeatother

\begin{document}
\begin{equation}
  \argmin \log( \sum_{i=1}^2 x^2)
\end{equation}
\end{document}

nath provides some macros for display math (\wall .. \return); some of the other packages that are part of amsmath bundle (amsgen, amstext, amsfonts) work with nath.

EDIT: It seems that nath is at fault here. nath redefines \mathop. Quoting from nath.sty:

\mathop is redefined to stop misinterpretation of following Bins as unary operators (cf. TeXbook, p. 170).

The following definition determines spacing between Op and Bin. (According to [TeXBook, p. 170], ``such case never arises, so plain TeX leaves it undefined, making the Bin into unary.'')

If you simply restore the definition of \mathop, then everything works fine:

\documentclass{article}
\usepackage{amsmath,nath}
\makeatletter
\let\mathop\o@mathop
\makeatother
\DeclareMathOperator{\argmin}{arg\,min}
\begin{document}
    \begin{equation}
        \argmin \log(\sum_{x=1}^2 x^2)
    \end{equation}
\end{document}
5
  • Hmm, so it's impossible to use log correctly if we include both amsmath and nath? – user541686 Dec 6 '13 at 4:55
  • You could always save and restore the meaning of macros: \let\normallog\log \usepackage{amsmath} \let\log\normallog, etc. – Aditya Dec 6 '13 at 4:56
  • Right, but the definition becomes corrupted as-is, right? +1 – user541686 Dec 6 '13 at 4:57
  • @Mehrdad: See edited solution. – Aditya Dec 6 '13 at 5:17
  • @Mehrdad: Do keep in mind that nath does not play well with many package: tex.stackexchange.com/q/104532/323. Sometimes the workarounds are easy, sometimes not. – Aditya Dec 6 '13 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.