2

The following MCE points out ntheorem's fleqn and thmmarks options break \if@display: e.g., as soon as thmmarks is uncommented, the 1st "equation" contains "Non-display math".

Do you see what's going on?

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage[
  amsmath,
  fleqn,
  % thmmarks
]{ntheorem}
%
\makeatletter
\newcommand\testdisplaymath{%
  \if@display
  \text{Display math}
  \else
  \text{Non-display math}
  \fi
}
\makeatother
%
\begin{document}
\[
  \testdisplaymath
\]
$\testdisplaymath$
\end{document}

Edit

Anyway, I discovered meanwhile that a better way to discriminate between display and non-display math would be to rely on \mathchoice and, as shown by the following MWE, this macro (unlike \if@display) isn't broken by ntheorem's fleqn and thmmarks options:

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage[
  amsmath,
  fleqn,
  thmmarks
]{ntheorem}
%
\makeatletter
\newcommand\testdisplaymath{%
  \mathchoice{%
    \text{Display math}%
  }{%
    \text{Non-display math}%
  }{%
    \text{Non-display math}%
  }{%
    \text{Non-display math}%
  }
}
\makeatother
%
\begin{document}
\[
  \testdisplaymath
\]
$\testdisplaymath$
\end{document}
Denis Bitouzé
  • 9,652
  • 4
  • 27
  • 85

2 Answers2

5

When you load the thmmarks option, ntheorem does

\gdef\[{%
  <code adding to the corresponding in the LaTeX kernel>
}
\gdef\]{%
  <code adding to the corresponding in the LaTeX kernel>
}

but amsmath had one

\DeclareRobustCommand{\[}{\begin{equation*}}
\DeclareRobustCommand{\]}{\end{equation*}}

Since the LaTeX kernel code has no provision for \if@display, you get no support for it using \[ and \], unless you redo the latter declarations. However, see also https://tex.stackexchange.com/a/329209/4427

Personal comment: the thmmarks option does so many changes in order to do something that simply requires \qedhere when needed and whose usage can be avoided by not ending a proof with a display or an enumerated list (of course with amsthm and not ntheorem).

egreg
  • 1,121,712
0

It's another problem with the compatibility of amsmath. amsmath compatibility is an issue since the early beginnings. Mails to amsmath people in the early stage of development (suggested by Frank Mittelbach at that time) were simply not answered by them.

Personally, I suggest not to use amsmath. This is also due to a bad experience with backwards version compatibility of amsmath.

Wolfgang (still partially active developer of ntheorem)

  • 3
    Seriously? amsmath and, based on it, mathtools provide so many, so nice features when one has to typeset maths that these packages are widely used nowadays. – Denis Bitouzé Nov 21 '17 at 13:18
  • 2
    Sorry, but a choice between ntheorem and amsmath is definitely for the latter. – egreg Nov 21 '17 at 13:25
  • amsmath is part of latex/required and any math document should include it. The only reason that it isn't included by default in the format is the memory constraints of emtex on a 540K PC. – David Carlisle Nov 21 '17 at 13:25
  • So people using it should hope that they by now care for backward compatibility. – Wolfgang May Nov 21 '17 at 13:31
  • The responsibility for maintenance of amsmath was transferred to the latex team in 2016. – Ulrike Fischer Nov 21 '17 at 14:27
  • By the way, you may want to see https://tex.stackexchange.com/a/328973/4427 – egreg Nov 21 '17 at 14:43