# Math-mode overrun in newtheorem

I would like to have a long math-mode "title" in a newtheorem environment:

\documentclass[twocolumn]{article}
\usepackage{amsthm}

\newtheorem{definition}{Definition}

\begin{document}
\begin{definition}
[$ABC \rightarrow DEF \rightarrow GHI \rightarrow JKL \rightarrow MNO \rightarrow PQR$]

Here's some text that runs over onto the next line, to show the overrun.
\end{definition}

\end{document}

However, although the text wraps properly if the title is text, an inline math-mode title doesn't seem to wrap. (It seems reasonable to expect it to wrap since it's not display math, but perhaps I'm wrong.)

The particular formula I've used here is illustrative: I would like something that works with an arbitrary (breakable) math formula.

There is some overlap with Overruns in newtheorem in latex. The "manual intervention" discussed there (formatting the name of the theorem yourself) certainly works, but I wondered if there was a better solution.

Also note that I am using amsthm.

in the absence of other suggestions, here are two somewhat hackish approaches:

• insert \allowbreak in an appropriate place in the math string; just before MNO seems best in this case.

• define a \newtheoremstyle without a final period, move the "optional" part into the main text where it's outside the scope of \trivlist (i really dislike the use of \trivlist for this kind of element!), and insert the ending punctuation yourself.

here's the code for the second approach:

\documentclass[twocolumn]{article}
\usepackage{amsthm}

\newtheorem{definition}{Definition}

\makeatletter
\newtheoremstyle{defnopunct}%
{\thm@preskip}{\thm@postskip}%
{\itshape}%  body font
{\z@}%       indent
{ }%         space after theorem head
{}%          "theorem head spec"; empty = "normal"
\makeatother

\theoremstyle{defnopunct}
\newtheorem{defnopunct}[definition]{Definition}

\begin{document}

\begin{defnopunct}
\textup{($ABC \rightarrow DEF \rightarrow GHI \rightarrow JKL \rightarrow MNO \rightarrow PQR$)}\textbf{.}

Here's some text that runs over onto the next line, to show the overrun.

\end{defnopunct}

\end{document}

curiously, if the long optional material had been ordinary text, this would not be a problem; that bug was trapped and exterminated in 1999, but nobody ever tried it out with a long math expression, or at least hasn't reported it before.

i've added it to the amsthm bugs list ...

• For now I'll try a manual \allowbreak. Currently I'm just moving the "optional" part into the main text, and dealing with the period being in the wrong place; your 'nopunct' idea would help with that. I'll accept this answer unless something better materialises over the next day or so. Thanks! – Roly Sep 5 '13 at 6:15

Adapting the definition of \* (from plain TeX) you could make an arrow that can be hyphenated using \discretionary{}{}{}.

\def\brkarrow{\discretionary{\enspace\the\textfont2\char33}{}{}}

\begin{definition}
[$ABC \rightarrow DEF \rightarrow GHI \rightarrow JKL \brkarrow MNO \rightarrow PQR$]
Here's some text that runs over onto the next line, to show the overrun.
\end{definition}

You can't put maths inside the discretionary but you can use a character from the maths font. In this case we use character number 33 from the maths symbol font. (See Appendix F of the TeX Book). But the trouble with this is that if there is no break then it produces nothing, because the third part of a discretionary has to be blank in math mode. So you may as well just put in an \allowbreak at the appropriate point.

\begin{definition}
[$ABC \rightarrow DEF \rightarrow GHI \rightarrow JKL \rightarrow \allowbreak MNO \rightarrow PQR$]
Here's some text that runs over onto the next line, to show the overrun.
\end{definition}

Either will get you this

but the second is probably simpler and you can put \allowbreak in as many times as you like. Or even define a tiny macro to expand to \rightarrow\allowbreak.

• Thanks. Clarified in my question that the arrow is only illustrative; I'd like a solution that works with arbitrary inline math. It looks like manual intervention via \allowbreak is the simplest solution... – Roly Sep 5 '13 at 6:11