從定理記下單字

從定理記下單字

我有一個這樣的定理:

\documentclass[12pt]{book} 

\begin{document}

\newtheorem{definition}{Definition}[section]

\begin{definition}[Integers]
Integers are positive and negative whole numbers, including 0.\\
e.g. $..., -3, -2, -1, 0, 1, 2, 3, 4, ...$
\end{definition}

\end{document}

定義

我如何將「整數是正數和負數......」這句話寫成一行?

我已經嘗試過 \\ 但這會產生無行結束錯誤,也不會降低「整數是正數和負數...」。

謝謝你!

答案1

您可以使用amsthm和定義自己的定理樣式。

\documentclass[12pt]{book}
\usepackage{amsthm,amsmath}

\newtheoremstyle{breakthm}
  {\topsep}%   Space above
  {\topsep}%   Space below
  {\itshape}%  Body font
  {}%          Indent amount (empty = no indent, \parindent = para indent)
  {\bfseries}% Thm head font
  {.}%         Punctuation after thm head
  {\newline}%  Space after thm head: " " = normal interword space;
  {}%          Thm head spec (can be left empty, meaning `normal')
\newtheoremstyle{breakdef}
  {\topsep}%   Space above
  {\topsep}%   Space below
  {\upshape}%  Body font
  {}%          Indent amount (empty = no indent, \parindent = para indent)
  {\bfseries}% Thm head font
  {.}%         Punctuation after thm head
  {\newline}%  Space after thm head: " " = normal interword space;
  {}%          Thm head spec (can be left empty, meaning `normal')

\theoremstyle{breakthm}
\newtheorem{theorem}{Theorem}[section]

\theoremstyle{breakdef}
\newtheorem{definition}[theorem]{Definition}

\begin{document}

\begin{definition}[Integers]
Integers are positive and negative whole numbers, including $0$,
e.g.
\[
\dots, -3, -2, -1, 0, 1, 2, 3, 4,\dotsc
\]
\end{definition}

\begin{theorem}
The integers are useful.
\end{theorem}

\end{document}

在此輸入影像描述

但在我看來,這只是浪費空間。

請注意,這amsthm提供了更好的客製化可能性。使用theorem(或更好的ntheorem),如果您想讓定義中的正文字體保持直立,則必須定義新的定理樣式(這是慣例)。

另一種可能性是使用thmtools,這使得定義新的定理樣式變得非常容易。與之前相同,可以獲得

\documentclass[12pt]{book}
\usepackage{amsmath,amsthm,thmtools}

\declaretheoremstyle[
  postheadspace=\newline,
  bodyfont=\itshape,
]{breakthm}% main style

\declaretheoremstyle[
  style=breakthm,
  bodyfont=\normalfont,
]{breakdef}% override the bodyfont

\declaretheorem[
  name=Theorem,
  style=breakthm,
  numberwithin=section,
]{theorem}

\declaretheorem[
  name=Definition,
  style=breakdef,
  numberlike=theorem,
]{definition}

\begin{document}

\begin{definition}[Integers]
Integers are positive and negative whole numbers, including $0$,
e.g.
\[
\dots, -3, -2, -1, 0, 1, 2, 3, 4,\dotsc
\]
\end{definition}

\begin{theorem}
The integers are useful.
\end{theorem}

\end{document}

答案2

有許多用於自訂定理的包,包括theorem在核心 Latex 發行版中:

\documentclass[12pt]{book}
\usepackage{theorem}
\theoremstyle{break}
\newtheorem{definition}{Definition}[section]
 \begin{document} 
 \begin{definition}[Integers]
 Integers are positive and negative whole numbers, including 0.\\
e.g. $..., -3, -2, -1, 0, 1, 2, 3, 4, ...$ 
\end{definition}
 \end{document} 

相關內容