我有一个定理标题,其长度超过页面宽度。如何将标题分成两行?
\begin{theorem}[this title is to long for one line]
the theorem
\end{theorem}
答案1
您能否提供有关所使用的文档类和包的更多信息?例如,以下代码似乎可以处理长标题和描述,但可能无法解决您的问题:
\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}
如果你能提供类似的最小工作示例这表明了你的问题,这将帮助其他人比我在这里更有用地发表评论。
根据您的评论(并假设您的意思是scrbook
对于课程,那么使用amsthm
包可能就足够了,例如:
\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}
答案2
LaTeX默认定理环境的解决方案:
\makeatletter
\renewcommand*{\@opargbegintheorem}[3]{\trivlist
\item[\hskip \labelsep{\bfseries #1\ #2}] \textbf{(#3)}\ \itshape}
\makeatother
这里重新定义了宏\@opargbegintheorem
,它原本包含
\item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
因此,可选的定理标题已被移至标签之后,而不是在标签内,所以现在可以换行。
测试示例:
\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}
信息就这么多。我建议使用功能强大的定理包,例如amssthm
或,ntheorem
它可以扩展 LaTeX 的定理功能。
答案3
就像一些评论关于提供修复ntheorem
,我尝试提供一个。它似乎有效——至少在快速测试中——但我不确定它是否 100% 正确(例如,它可能会破坏某些软件包的一些内部约定)。
% 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
梅威瑟:
\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}