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 using etoolbox and ntheorem packages to have a custom numbering of theorems and equations. Everything works but these side errors occur:

  • \qedhere command is unknown (EDIT: following some suggestions I worked something out, so the \qedhere issue is somehow solved)
  • theorems title (the optional argument) is typeset in bold

As a MWE, the following code

\documentclass{book}  
\usepackage{amsmath}  
\usepackage{etoolbox}  
\usepackage[amsmath,amsthm,framed,thmmarks]{ntheorem}  
%  
\renewcommand{\theequation}{\thechapter.\arabic{equation}}  
\setcounter{equation}{0}  
\newcounter{tempcounter}  
\newtheorem{thm}{Theorem}[chapter]  
%  
\BeforeBeginEnvironment{thm}{\setcounter{tempcounter}{\arabic{equation}}}  
\AtBeginEnvironment{thm}  
{\setcounter{thm}{\thetempcounter}\subequations}  
\AtEndEnvironment{thm}{\endsubequations}  
%  
\begin{document}  
\chapter{This is a chapter}  
\begin{equation}\label{Eq:A}  
2+2=4  
\end{equation}  
\begin{thm}[First Theorem]\label{Thm:First}  
\begin{equation}\label{Eq:B}  
1+1=2  
\end{equation}  
\begin{proof}  
If equation \ref{Eq:A} was trivial, equation \ref{Eq:B} in Theorem \ref{Thm:First} is even more \qedhere \\  
trivial.  
\end{proof}  
\end{thm}  
\end{document}

results in this output:

Output of the above MWE

The \qedhere command is unknown and therefore ignored. I think that the problem is a conflict between the amsthm option in ntheorem package and the amsthm package. However, if I add \usepackage{amsthm} in the preamble I get errors like

! LaTeX Error: Command \theoremstyle already defined.

and many more.

I would like either to solve the two problems listed above, or to have an alternative code in order to have:

  • theorems and equations following the same numbering, resetting at each chapter
  • equations in theorem environments subnumbered as shown in the above MWE's output.

Any other suggestion is highly appreciated.

share|improve this question
1  
\qedhere is not among the "supported" features from amsmath. the ntheorem documentation states that "some features of amsthm have been incorporated into option [amsthm]". the operative word here is "some". if you would like to have \qedhere supported, i suggest writing to the authors of ntheorem. –  barbara beeton Dec 9 '12 at 15:16
    
@barbara-beeton Thank you for the suggestion, I sent an email to the author. I am leaving the question open to other suggestions anyway. –  AndreasT Dec 9 '12 at 20:52
1  
since you wish to use ntheorem, not amsthm (except for some features), the suggestion to ask the authors of ntheorem to add \qedhere wasn't intended as a real answer. however, this tex file (which does depend on amsthm) offers some suggestions intended to enable the setting of a qed-type symbol outside of proof environments that may give you some ideas of how to handle the problem temporarily with manual adjustments. –  barbara beeton Dec 9 '12 at 21:16
    
As I outlined in the last EDIT, thanks to these suggestions I worked something out for the \qedhere issue. Now the question shrinks to the bold theorem title problem. –  AndreasT Dec 10 '12 at 10:43
add comment

1 Answer

up vote 4 down vote accepted

The ntheorem package covers the \qedhere in different ways. Here's an example on which you can elaborate. The "normal font attribution" is easily obtained by (re)defining the theorem style.

\documentclass{book}  
\usepackage{amsmath,amssymb}  
\usepackage{etoolbox}  
\usepackage[amsmath,framed,thmmarks]{ntheorem}  
%  
\numberwithin{equation}{chapter}
\newcommand{\qedhere}{\ifmmode\qed\else\hfill\proofSymbol\fi}

\makeatletter
\renewtheoremstyle{plain}
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ {\normalfont(##3)}\theorem@separator]}
\makeatother
\theoremstyle{plain}

\newtheorem{thm}{Theorem}[chapter]

\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\normalfont}
\theoremsymbol{\ensuremath{\square}}
\newtheorem{proof}{Proof}
\qedsymbol{\ensuremath{\square}}

\newcounter{tempcounter}
\BeforeBeginEnvironment{thm}{\setcounter{tempcounter}{\arabic{equation}}}  
\AtBeginEnvironment{thm}  
{\setcounter{thm}{\thetempcounter}\subequations}  
\AtEndEnvironment{thm}{\endsubequations}  
%  
\begin{document}  
\chapter{This is a chapter}  
\begin{equation}\label{Eq:A}  
2+2=4  
\end{equation}  
\begin{thm}[First Theorem]\label{Thm:First}  
\begin{equation}\label{Eq:B}  
1+1=2  
\end{equation}  
\begin{proof}  
If equation \ref{Eq:A} was trivial, equation \ref{Eq:B} in Theorem \ref{Thm:First} is even more
trivial.
\[ 0+0=0 \qedhere\]
\end{proof}  
\end{thm}  

\begin{thm}[Second Theorem]\label{Thm:Second}  
\begin{equation}\label{Eq:C}  
1+1=2  
\end{equation}  
\begin{proof}  
If equation \ref{Eq:A} was trivial, equation \ref{Eq:C} in Theorem \ref{Thm:Second} is even more
trivial.
\end{proof}  
\end{thm}  

Let's see another proof.
\begin{proof}
\begin{itemize}
\item Fact one
\item Fact two
\item Fact three\qedhere
\end{itemize}
\end{proof}

\begin{proof}
Here the proof ends with an \texttt{align*} environment.
\begin{align*}
0&=0+0\\
1&=0+1\qedhere
\end{align*}
\end{proof}

\end{document}
share|improve this answer
    
This definitely solves everything but one thing: the \qedhere command does not suppress the default \qedsymbol at the end of the proof. Putting \qedhere before the end of the proof results in two hollow squares printed, the one called by \qedhere and the default one at the end. –  AndreasT Dec 10 '12 at 11:53
    
@AndreasT \qedhere should be used only in the last line, if it's not a normal paragraph, just like in the examples I showed. –  egreg Dec 10 '12 at 11:59
    
That's true, but the original \qedhere command can be put anywhere and the default hollow square is suppressed. I agree with what you say and in fact that is how I have always used \qedhere so far. The philosophy behind my previous comment was just trying to reestablish the original \qedhere command with all its features, but I guess some are quite useless. Thank you very much, the question is fully solved. –  AndreasT Dec 10 '12 at 12:16
    
@AndreasT While your request is understandable, one should plunge into the details of ntheorem and its QED mark placement in order to build the infrastructure: remember that \qedhere in amsmath uses a stack to cope with nested proof environments. And that apparently ntheorem checks whether the proof actually ends just after the inner environment (display or list) in order to decide if placing \qed or \proofSymbol. This seems more a feature request for ntheorem. –  egreg Dec 10 '12 at 12:52
add comment

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.