I have a theorem title, which is longer then the page width. How do I get the title in two lines?
\begin{theorem}[this title is to long for one line]
the theorem
\end{theorem}
Can you provide more information on the document class and packages you are using? For example, the following code seems to cope with long titles and descriptions but may not be addressing your problem:
\documentclass{amsart}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[this theorem has a long title that extends well over a line but is handled without any manual intervention on the author's partand even this description goes over a line]
body of the theorem
\end{theorem}
\end{document}
If you could provide a similar Minimal Working Example that shows your problem this would help others to comment on it more usefully than I have here.
Following on from your comment (and assuming you mean scrbook
for the class then using the amsthm
package may suffice, e.g.:
\documentclass[11pt,a4paper,twoside ,fleqn,headsepline]{scrbook}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[this theorem has a long title that extends well over a line but is handled without any manual intervention on the author's part and even this description goes over a line]
Body of the theorem
\end{theorem}
\end{document}
\documentclass[11pt,a4paper,twoside ,fleqn,headsepline]{scrapbook}
but scrbook has the best layout I found
amsart
because that provides a base math setup and you didn't specify which class and styles you were using. I have added an example in the answer above to show one possible approach for a theorem in the class you've chosen.
amsthm
was accidentally removed through some refactorings that tried to get compatibility with some of Lamport's proof-related packages.
ieeeconf.cls
that conflicts with amsthm
? The suggestion by Stefan changes how theorems look (e.g., boldface), and I don't know whether there are other ways that it affects the definition of theorem style in ieeeconf.cls
. Is there some alternative?
A solution for LaTeX default theorem environment:
\makeatletter
\renewcommand*{\@opargbegintheorem}[3]{\trivlist
\item[\hskip \labelsep{\bfseries #1\ #2}] \textbf{(#3)}\ \itshape}
\makeatother
Here the macro \@opargbegintheorem
is redefined, which originally contains
\item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
so the optional theorem title has been moved to after the label instead if being within, so now line breaks are possible.
Test example:
\documentclass{book}
\newtheorem{theorem}{Theorem}
\makeatletter
\renewcommand*{\@opargbegintheorem}[3]{\trivlist
\item[\hskip \labelsep{\bfseries #1\ #2}] \textbf{(#3)}\ \itshape}
\makeatother
\begin{document}
\begin{theorem}[This theorem has a very long title which requires a line break]
text
\end{theorem}
\end{document}
So much for information. I recommend using a capable theorem package such as amssthm
or ntheorem
which extends LaTeX's theorem capabilities.
ntheorem
doesn't solve this "too long title" problem and that your hack won't work with it. On the other hand, amsthm
doesn't any problem at all with this kind of thing.
Commented
Sep 25, 2011 at 20:35
amsthm
, I assume it can be solved with ntheorem
as well. When I've got some time, I could add a fix as well. For now especially my recommendation of using a capable package stands, which is always better than a "hack", and I prefer amsthm
, as mentioned here.
As there have been some comments about providing a fix for ntheorem
, I tried to provide one. It seems to work – at least in a quick test – but I am not sure whether it is 100% correct (for example it may break some internal conventions of some packages).
% https://tex.stackexchange.com/a/179917:
\newcommand*{\NLS}{%
\par
\nobreak
\vspace{-\parskip}%
\noindent
\ignorespaces
}
\makeatletter
% From ‘ntheorem.sty’:
\newtheoremstyle{mybreak}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
{\item[\hskip\labelsep \theorem@headerfont%
##1\ ##2]\hspace*{-\labelsep}{\theorem@headerfont\ (##3)\theorem@separator}\NLS}
\makeatother
MWE:
\documentclass{book}
\usepackage[standard]{ntheorem}
% https://tex.stackexchange.com/a/179917:
\newcommand*{\NLS}{%
\par
\nobreak
\vspace{-\parskip}%
\noindent
\ignorespaces
}
\makeatletter
% From ‘ntheorem.sty’:
\newtheoremstyle{mybreak}%\newtheoremstyle{break}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
{\item[\hskip\labelsep \theorem@headerfont%{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2]\hspace*{-\labelsep}{\theorem@headerfont\ (##3)\theorem@separator}\NLS}%##1\ ##2]\hspace*{-\labelsep}{\theorem@headerfont\ (##3)\theorem@separator}\hfill\penalty\@endparpenalty%##1\ ##2\ (##3)\theorem@separator}\hbox{\strut}}}]}
\makeatother
\theoremstyle{mybreak}
\renewtheorem{Theorem}{Theorem}
\usepackage[all]{nowidow}
% For testing:
\usepackage[english]{babel}
\usepackage{blindtext}
\blindmathtrue
\begin{document}
\begin{Theorem}[This theorem has a very long title which requires a line break]
\blindtext\par
\blindtext
\end{Theorem}
\blindtext\par
\blindtext
\end{document}