[Tex/LaTex] `ntheorem` and `thmtools` seem incompatible

amsthmcleverefntheoremtheoremsthmtools

I am preparing the setup of the theorem environments for my thesis. I want to do this right before I have say 200 of those environments in my document, since changing them will likely break things at that stage.

What I want:

  • cleveref. To have uppercase/lowercase references, idem for plurals
  • thmtools. Since it provides an interface to cleveref for defining the plural names
  • Properly placed endmarks. So the endmark should appear on the same line as the last line of text (even if it is displaymath or an itemize/enumerate)

It seems that this is quite hard to do right. ntheorem is quite good at putting thmmarks in the right place, but I can not get ntheorem to work right with thmtools.


At the moment I have thmtools with amsthm as backend. This works nicely together with cleveref.

I have definitions like

\declaretheorem[sibling=equation,qed=\text{\guillemotleft}]{definition}

But when I end my definition with a list, the guillemet («) is put on new line. Clearly not what I want (-;

When I switch the backend to ntheorem I get compile errors of the form

\declaretheorem key `qed' not known.

Does anyone have a solution to this?


A MWE:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath, amssymb, amsfonts, amsthm}
\usepackage{thmtools}
\numberwithin{equation}{section}
\declaretheoremstyle[
         headformat={\makebox[0pt][r]{\NUMBER\quad}\NAME \NOTE}
]{theorem}
\declaretheoremstyle[
         headformat={\makebox[0pt][r]{\NUMBER\quad}\NAME \NOTE}
]{definition}
\declaretheorem[style=theorem,sibling=equation]{theorem}
\declaretheorem[style=theorem,sibling=equation]{proposition}
\declaretheorem[style=theorem,sibling=equation]{lemma}
\declaretheorem[style=definition,sibling=equation,qed=\text{\guillemotleft}]{definition}
\declaretheorem[style=definition,sibling=equation,qed=\text{\guillemotleft}]{exercise}
\declaretheorem[style=definition,sibling=equation,qed=\text{\guillemotleft}]{example}
\let\proof\relax
\declaretheorem[style=definition,numbered=no,qed=\qedsymbol]{proof}

%% Math macro stuff to make this compile
\DeclareMathOperator{\Spec}{Spec}       % Spectrum
\DeclareMathOperator{\M}{M}
\DeclareMathOperator{\Ga}{Ga}
\DeclareMathOperator{\GL}{GL}
\DeclareMathOperator{\Gm}{Gm}
\def\ol{\overline}

\begin{document}

\begin{definition}
A \emph{group variety over $k$} is an integral group scheme of finite type over $\Spec k$.
\end{definition}

\begin{example}
Let $k$ be a field and $R$ a commutative $k$-algebra.
\begin{itemize}
    \item The varieties $\Ga_{k} = \Spec k[x]$ and $\Gm_{k} = \Spec k[x,y]/(xy - 1)$ are group varieties. Indeed, $\Ga_{k}(R)$ is the additive group underlying $R$, and $\Gm_{k}(R) = R^*$ is the group of units in $R$.
    \item The variety $\M_{n,k} = \Spec k[(x_{ij})_{ij}]$ is a group variety. Also the closed sub variety $\GL_{n,k}$ defined by the polynomial $\det \left( (x_{ij})_{ij} \right) - 1$ is a group variety. The $R$-valued points are the $n \times n$-matrices $\M_{n,k}(R)$ with coefficients in $R$, and $\GL_{n,k}(R)$ consists of the invertible matrices respectively. Observe that $\Gm_{k} = \GL_{1,k}$.
    \item The variety $\mu_{n,k} = \Spec k[x]/(x^n -1)$ is a group variety, and $\mu_{n,k}(R)$ consists of the group of $n$-th roots of unity in $R$.
    \item An elliptic curve over $k$ is defined as a proper variety $E/k$ that is smooth of relative dimension $1$, of which the geometric fibre $E_{\ol{k}}$ has genus $1$, together with a given point $0 \in E(k)$. It can be shown that every elliptic curve is a group variety. Actually they form an important class of objects in the study of abelian varieties.
\end{itemize}
\end{example}

\end{document}

Note that the endmark of the definition is fine, but the endmark of the example is on a line of itself.

Best Answer

If you want to use ntheorem instead of amsthm as the back-end, then you will have to resign to some of the formatting features that were available with amsthm and some other changes will have to be made:

  1. The commands \NAME, \NUMBER, and \NOTE will no longer be available.

  2. To simulate the desired head formatting, you can use the headformat=swapnumber option instead, but then you loose the flexibility to change the head format.

  3. The option qed=\text{\guillemotleft} will have to be used in \declaretheoremstyle instead of in \declaretheorem (which, in any case, makes sense).

  4. Your proof environment will have to be defined separately.

Here's an example of how your definitions would look like using ntheorem:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage[thmmarks,amsmath]{ntheorem}
\usepackage{thmtools}

\numberwithin{equation}{section}

\declaretheoremstyle[headformat=swapnumber,bodyfont=\normalfont]{theorem}
\declaretheoremstyle[headformat=swapnumber,bodyfont=\normalfont
,qed=\text{\guillemotleft}]{mydefinition}

\declaretheorem[style=theorem,sibling=equation]{theorem}
\declaretheorem[style=theorem,sibling=equation]{proposition}
\declaretheorem[style=theorem,sibling=equation]{lemma}
\declaretheorem[style=mydefinition,sibling=equation]{definition}
\declaretheorem[style=mydefinition,sibling=equation]{exercise}
\declaretheorem[style=mydefinition,sibling=equation]{example}

\newtheorem*{proof}{Proof}

%% Math macro stuff to make this compile
\DeclareMathOperator{\Spec}{Spec}       % Spectrum
\DeclareMathOperator{\M}{M}
\DeclareMathOperator{\Ga}{Ga}
\DeclareMathOperator{\GL}{GL}
\DeclareMathOperator{\Gm}{Gm}
\def\ol{\overline}

\begin{document}

\begin{definition}
A \emph{group variety over $k$} is an integral group scheme of finite type over $\Spec k$.
\end{definition}

\begin{proof}
Test
\end{proof}

\begin{example}
Let $k$ be a field and $R$ a commutative $k$-algebra.
\begin{itemize}
    \item The varieties $\Ga_{k} = \Spec k[x]$ and $\Gm_{k} = \Spec k[x,y]/(xy - 1)$ are group varieties. Indeed, $\Ga_{k}(R)$ is the additive group underlying $R$, and $\Gm_{k}(R) = R^*$ is the group of units in $R$.
    \item The variety $\M_{n,k} = \Spec k[(x_{ij})_{ij}]$ is a group variety. Also the closed sub variety $\GL_{n,k}$ defined by the polynomial $\det \left( (x_{ij})_{ij} \right) - 1$ is a group variety. The $R$-valued points are the $n \times n$-matrices $\M_{n,k}(R)$ with coefficients in $R$, and $\GL_{n,k}(R)$ consists of the invertible matrices respectively. Observe that $\Gm_{k} = \GL_{1,k}$.
    \item The variety $\mu_{n,k} = \Spec k[x]/(x^n -1)$ is a group variety, and $\mu_{n,k}(R)$ consists of the group of $n$-th roots of unity in $R$.
    \item An elliptic curve over $k$ is defined as a proper variety $E/k$ that is smooth of relative dimension $1$, of which the geometric fibre $E_{\ol{k}}$ has genus $1$, together with a given point $0 \in E(k)$. It can be shown that every elliptic curve is a group variety. Actually they form an important class of objects in the study of abelian varieties.
\end{itemize}
\end{example}

\end{document}

enter image description here

Related Question