如何使用標籤格式化多行語句

如何使用標籤格式化多行語句

我正在嘗試使用標籤格式化多行語句。

\documentclass{article}

\usepackage{amsmath}
\usepackage[showframe,pass]{geometry}

\begin{document}

Let $P(n)$ denote the statement that
\begin{equation}
\text{The sum of the natural numbers less than or equal to $n$ is given by the formula }
0 + 1 + \cdots + n = \frac{n(n+1)}{2}.
\tag{P(n)}
\end{equation}

\end{document}

程式碼輸出

不幸的是,該語句超出了右邊距。我認為使用align,multlinegather環境不合適,因為水平對齊不正確。我應該如何格式化數學陳述?

我想要的東西:

  • 我希望該聲明能夠像環境中一樣縮排quote
  • 我希望標籤為“P(n)”而不是當前輸出中的“(P(n))”

答案1

這是文本,因此應按如下方式處理:

\documentclass{article}

\usepackage{amsmath}
\usepackage[showframe,pass]{geometry}
\usepackage{lipsum}

\begin{document}

\lipsum[2]

Let $P(n)$ denote the statement that
\[
\begin{minipage}{0.75\textwidth}
The sum of the natural numbers less than or equal to $n$ is given by the formula
$0 + 1 + \cdots + n = \frac{n(n+1)}{2}$.
\end{minipage}
\tag{$P(n)$}
\]
\lipsum[3]

\end{document}

在此輸入影像描述

如果您使用\tag*{$P(n)$}(無論如何,請注意數學模式),您將獲得不含括號的標籤:

在此輸入影像描述

答案2

您可以使用環境gathered內部的環境equation,如下所示

Let $P(n)$ denote the statement that
\begin{equation}
  \begin{gathered}
    \text{The sum of the natural numbers less than or equal to $n$}\\
      \text{is given by the formula $0 + 1 + \cdots + n = \frac{n(n+1)}{2}$.}
  \end{gathered}
  \tag*{P(n)}
\end{equation}

在此輸入影像描述

相關內容