1

I want to construct some theorem-type of environment by using package ntheorem. I have edited the following source codes:

\documentclass[A4paper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[amsmath,amsthm,thmmarks]{ntheorem} 
\theoremstyle{plain}
\theoremheaderfont{\normalfont}
\theoremseparator{.}
\theorembodyfont{\normalfont }
\theoremsymbol{\ensuremath{\Box}}
\newtheorem{Def}{\bf Definition}

\begin{document}
\begin{Def}
    Let $n$ be a positive integer and $\mathbb{K}$ a field. Let $SL_n(\mathbb{K})$ denote the set of special linear group, that is
    $$SL_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times n}\mid |M|=1\}.$$
\end{Def}

 \begin{Def}
        Let $n$ be a positive integer and $\mathbb{K}$ a field. Let $SL_n(\mathbb{K})$ denote the set of special linear group, that is
        $SL_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times n}\mid |M|=1\}.$
\end{Def}

\begin{Def}
            Let $n$ be a positive integer and $\mathbb{K}$ a field. Let $SL_n(\mathbb{K})$ denote the set of special linear group, that is
            $$SL_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times n}\mid |M|=1\}.$$
        \vspace{-10ex}
        \begin{gather*}
        \end{gather*}
        \end{Def}
\end{document}

The result is as follows: enter image description here

As you can see in Definition 1, the QED box dose not occur when the Def environment ends with the $$ ... $$. But when I ends the whole Def environment with just $...$, as in Definition 2, the QED box does occur.

And I tried many ways. Finally, I have found some method to remedy this. That is to modify the vertical space of QED box by the code:

\vspace{-10ex}
\begin{gather*}
\end{gather*}

added before the line of "end\Def". As in Definition 3, this method works. But it is very complex.

Is there any easy way to solve this problem?

5
  • If I leave an empty line after special linear group, that is and replace $$ with \[...\], I get the box.
    – user11232
    Aug 25, 2014 at 6:52
  • 3
    Welcome to TeX.SX! You should not use $$...$$ for display mathematics in latex but rather \[...\], see tex.stackexchange.com/q/503/15925 . With this change your example will work as expected. Aug 25, 2014 at 6:57
  • I don't have to add whatever to obtain the qed symbol, but simply compile only twice. The only restriction in the doc is precisely there must be no empty line at the end — actually no empty line after an end of input in paragraph mode.
    – Bernard
    Aug 25, 2014 at 8:56
  • @HarishKumar -- leaving a blank line before a display is a bad thing. aside from messing up the spacing around the display, it allows a page break, which shouldn't happen. Aug 25, 2014 at 14:31
  • @barbarabeeton: I am aware of that. It was an observation, not a suggestion (that is why a comment) :-) Thanks for the comment.
    – user11232
    Aug 25, 2014 at 22:58

1 Answer 1

3

You need to use \[...\], or some other LaTeX math display environment, instead of the plain TeX $$...$$. Many LaTeX packages rely on this, see also Why is \[ ... \] preferable to $$ ... $$?. In the case of ntheorem the marker will not get placed on displays with $$...$$. Consider the following document, close to yours:

\documentclass[a4paper]{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[amsmath,amsthm,thmmarks]{ntheorem} 

\theoremstyle{definition}
\theoremseparator{.}
\theoremsymbol{\ensuremath{\Box}}
\newtheorem{Def}{Definition}

\begin{document}

\begin{Def}
  Let $n$ be a positive integer and $\mathbb{K}$ a field. Let
  $\mathit{SL}_n(\mathbb{K})$ denote the set of special linear group, that is
  \[
  \text{displaymath}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times
  n}\mid |M|=1\}
  \]
  or
  \[
  \text{displaymath}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times
  n}\mid |M|=1\}
  \]
  or
  $$ \text{dollars}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times
  n}\mid |M|=1\}$$
  or
  $$ \text{dollars}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times
  n}\mid |M|=1\}$$
  or
  \[
  \text{displaymath}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times
  n}\mid |M|=1\}
  \]
  or
  $$ \text{dollars}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times
  n}\mid |M|=1\}$$
  or
  $$ \text{dollars}\ \mathit{SL}_n(\mathbb{K}):=\{M\in\mathbb{K}^{n\times n}\mid |M|=1\}.$$
\end{Def}


\end{document}

Examining the aux file we find that ntheorem outputs the line

\global\def\markiDefiii{\ensuremath {\Box }}

which comes from the third \[...\] pair, corresponding the roman numeral iii. The $$...$$ do not get counted and on the next run ntheorem places the qed mark at the end of the third \[...\] display:

Sample output

Note also you definition of the Def environment is bad. Font formatting should not be put in the label, instead you should use

\theoremheadfont{\normalfont\bfseries}

Perhaps the amsthm option was causing problems with setting these fonts, it is deprecated in the ntheorem documentation, however if you do use then there is a built in definition theoremstyle which I have used above.

You must log in to answer this question.

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