Como formatar uma instrução multilinha com um rótulo

Como formatar uma instrução multilinha com um rótulo

Estou tentando formatar uma instrução de várias linhas com um rótulo.

\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}

saída de código

Infelizmente, a afirmação transborda a margem direita. Não creio que usar o align, multlineou os gatherambientes seria adequado porque o alinhamento horizontal não seria correto. Como devo formatar a declaração matemática?

Coisas que eu gostaria:

  • Gostaria que a declaração fosse recuada como no quotemeio ambiente.
  • Quero que o rótulo seja "P(n)" em vez de "(P(n))" como está atualmente na saída

Responder1

Este é um texto, portanto deve ser tratado como tal:

\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}

insira a descrição da imagem aqui

Se você usar \tag*{$P(n)$}(observe o modo matemático, em qualquer caso), obterá a tag sem parênteses:

insira a descrição da imagem aqui

Responder2

Você pode usar um gatheredambiente dentro do equationambiente, como em

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}

insira a descrição da imagem aqui

informação relacionada