Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 4 down vote accepted
+50

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

share|improve this answer
    
Wow, thanks! That looks promising. Is it possible to hang these thereom counters in the margin? –  jmc Apr 3 '12 at 15:58
    
@jmc: sure; simply use \declaretheoremstyle[headformat=swapnumber,bodyfont=\normalfont ,qed=\text{\guillemotleft}]{mydefinition} \declaretheorem[style=margin,sibling=equation]{theorem} \declaretheorem[style=margin,sibling=equation]{proposition} \declaretheorem[style=margin,sibling=equation]{lemma} \declaretheorem[style=margin,sibling=equation]{definition} \declaretheorem[style=margin,sibling=equation]{exercise} \declaretheorem[style=margin,sibling=equation]{example} –  Gonzalo Medina Apr 3 '12 at 16:07
    
| Right! Somehow that works, but I really don't understand why/how it combines style=margin with mydefinition. Still the result shows that it uses features of both. Can you clarify this to me? –  jmc Apr 3 '12 at 17:06
    
@jmc All the \declaretheorem declarations that appear right after a \declaretheoremstyle will inherit the specifications of this theorem style; it's the way that it's supposed to work. –  Gonzalo Medina Apr 3 '12 at 17:16
    
Aah, I thought you would have to use the style=xyz to assign a specific style to a theorem. Thanks for clearing this up. When time is due, I will award the bounty. –  jmc Apr 3 '12 at 17:21

er, this is a nonworking example.

first problem: \def\ol\overline causes a failure with "missing \begin{document}"; correct it with braces around \overline.

second problem: " Command \guillemotleft unavailable in encoding OT1".

in any event, the command \qedhere was developed in amsthm to address the "new line" problem when a proof ends with a display or a list; it is to be input just before the \end{...} command of the embedded element (equation and friends or itemize). as it happens, with thmtools this will work also for theorem-class objects, but if you want a symbol other than the predefined box, you must redefine \qedsymbol

i'm not really familiar with ntheorem, but know that it differs in some significant respects from amsthm, so if you want to use thmtools with ntheorem you need to refer to the thmtools manual.

share|improve this answer
    
Thanks for your reply. I know about the \qedhere command. However, one advantage of ntheorem over amsthm is that it is able to "figure out" where the \qedhere should be applied on itself. –  jmc Mar 24 '12 at 12:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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