[Tex/LaTex] Overfull \hbox produced by ntheorem subtitles

line-breakingtheoremswarnings

I switched from using the standard AMS theorem package to ntheorem so I can put alternative end marks on theorem environments (I want my examples to have an end mark, but not the same one as proofs). However, this seems to be causing another problem.

Many of my examples have subtitles, by which I mean I start them with
\begin{example}[subtitle],
where the subtitle is some description of the example. Some of these subtitles are long enough that they need multiple lines, which works fine with the standard AMS environment. On the other hand ntheorem seems to try to set the subtitle all on one line, giving an overfull \hbox whenever it is long enough that it should span multiple lines (I'm not talking a character or two wider than it knows how to deal with like a usual overfull \hbox, I mean they go through the whole margin and off the page).

This can be reproduced by

\documentclass[12pt]{article}  
\usepackage{amsmath}
\usepackage[thmmarks,amsmath,amsthm,thref]{ntheorem}
\newtheorem{example}{Example}
\begin{document}
\begin{example}[blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah]
Content
\end{example}
\end{document}

Is this a bug in ntheorem or am I doing something wrong? Perhaps this is an abuse of the subtitle field. Is there a simple fix?

Best Answer

No; it's not a bug, although it could be considered a bad design choice; ntheorem uses the optional argument of \item to typeset the theorem header (name, number and annotation), and that causes the problem (I guess that the package author thought that an annotation shouldn't be too long). You can define your own style, imitating the existing plain style but modifying the undesired behaviour, so that you can now have annotations spanning several lines; the definition would be something along these lines, I used a checkmark (\Checkmark from bbding) as the endmark:

\documentclass[12pt]{article}
\usepackage{bbding}
\usepackage{amsmath}
\usepackage[thmmarks,amsmath,amsthm,thref]{ntheorem}

\makeatletter
\newtheoremstyle{Myplain}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2]\theorem@headerfont (##3)\theorem@separator\newline\normalfont\itshape}
\newtheoremstyle{nonumberMyplain}%
  {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
  {\item[\theorem@headerfont\hskip \labelsep ##1]\theorem@headerfont (##3)\theorem@separator\newline\normalfont\itshape}
\makeatother

\theoremstyle{Myplain}
\theoremsymbol{\Checkmark}
\newtheorem{example}{Example}

\begin{document}
\begin{example}[blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah]
Content
\end{example}

\end{document}

Another option would be to use the thmtools package which doesn't use \item to build its theorem-like structures, thus providing an easier solution (the same checkmark was used in this example):

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{bbding}
\declaretheoremstyle[
  spaceabove=6pt, spacebelow=6pt,
  headfont=\normalfont\bfseries,
  notefont=\mdseries\bfseries,
  qed=\Checkmark,
  notebraces={(}{)},
  bodyfont=\itshape,
]{mystyle}
\declaretheorem[style=mystyle]{Example}


\begin{document}
\begin{Example}[blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah]
Content
\end{Example}

\end{document}
Related Question