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:
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?
Best Answer
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 ofntheorem
the marker will not get placed on displays with$$...$$
. Consider the following document, close to yours:Examining the
aux
file we find thatntheorem
outputs the linewhich comes from the third
\[...\]
pair, corresponding the roman numeraliii
. The$$...$$
do not get counted and on the next runntheorem
places the qed mark at the end of the third\[...\]
display:Note also you definition of the
Def
environment is bad. Font formatting should not be put in the label, instead you should usePerhaps the
amsthm
option was causing problems with setting these fonts, it is deprecated in thentheorem
documentation, however if you do use then there is a built indefinition
theoremstyle which I have used above.