如何通过文本拆分方程式?

如何通过文本拆分方程式?
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{float}
\usepackage{framed}
\usepackage[hang,flushmargin]{footmisc}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}[section]

\begin{document}
\noindent \newline A \textbf{Hamiltonian path} is a directed path that goes through every node exactly once. Consider the problem of testing whether a directed graph contains a Hamiltonian path that connects two specified nodes. Let: 
\begin{multline}
\nonumber HAMPATH = \{\langle G, s, t \rangle| G \text{ is a directed graph with a Hamiltonian path from } s \text{ to } t.\}
\end{multline}

\end{document}

我有上述 LaTeX 代码,并且我在 TeX SE 和 Google 上查找了如何拆分方程式。我尝试使用multline以及split尝试拆分方程式,使其适合边距。到目前为止,我尝试过的所有方法都没有奏效,所以我不知道该怎么做。

我想要的最终结果是下面的图像,但是整个东西(不包括环境中的东西)\text{}被格式化为方程式,而不是纯文本:

在此处输入图片描述

答案1

也许

在此处输入图片描述

   \documentclass[12pt]{report}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{amsthm}
    \usepackage{tikz}
    \usepackage{graphicx}
    \usepackage{float}
    \usepackage{framed}
    \usepackage[hang,flushmargin]{footmisc}

    \newtheorem{theorem}{Theorem}[section]
    \newtheorem{corollary}{Corollary}[theorem]
    \newtheorem{lemma}[theorem]{Lemma}
    \newtheorem{definition}{Definition}[section]

    \begin{document}

    A \textbf{Hamiltonian path} is a directed path that goes through
    every node exactly once. Consider the problem of testing whether a
    directed graph contains a Hamiltonian path that connects two
    specified nodes. Let:
    \begin{align*}
    \nonumber \mathit{HAMPATH} &= \{\langle G, s, t \rangle\\
&\quad{} \mid  G \text{ is a directed graph with a Hamiltonian path from }\\
&\qquad s \text{ to } t.\}
    \end{align*}

    \end{document}

或者根据评论判断也许你想要一个内联设置

在此处输入图片描述

\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{float}
\usepackage{framed}
\usepackage[hang,flushmargin]{footmisc}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}[section]

\begin{document}

A \textbf{Hamiltonian path} is a directed path that goes through
every node exactly once. Consider the problem of testing whether a
directed graph contains a Hamiltonian path that connects two
specified nodes. Let:
$\mathit{HAMPATH} = \{\langle G, s, t \rangle
\mid  G $ is a directed graph with a Hamiltonian path from 
 $s$ to $t$.$\}$


\end{document}

答案2

许多可能性,一是与之合作,align\MoveEqLeft随之而来mathtools

\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}[section]

\begin{document}
A \textbf{Hamiltonian path} is a directed path that goes through every node exactly once. Consider the problem of testing whether a directed graph contains a Hamiltonian path that connects two specified nodes. Let: 
\begin{align}
 \text{HAMPATH} &= \\
 \MoveEqLeft[4] \{\langle G, s, t \rangle| G \text{ is a directed graph with a Hamiltonian path from } s 
 \text{ to } t.\}\notag
\end{align}
\end{document}

在此处输入图片描述

答案3

multline你可以使用以下方式获得类似的效果minipage

\documentclass[12pt]{report}
\usepackage{amsmath}

\begin{document}
A \emph{Hamiltonian path} is a directed path that goes through
every node exactly once. Consider the problem of testing whether
a directed graph contains a Hamiltonian path that connects
two specified nodes. Let
\[
\begin{minipage}{0.8\displaywidth}
  \leftskip=0pt plus 1fil
  \rightskip=0pt plus 1fill
  \parfillskip=0pt plus -1fill
  $\mathrm{HAMPATH} = \{\langle G, s, t \rangle\mid G$
  is a directed graph with \\ a Hamiltonian path from $s$ to $t\}$.
\end{minipage}
\]

\end{document}

设置为\leftskip\rightskip\parfillskip确保顶行左对齐(在分配的空间内)和底行右对齐。

在此处输入图片描述

相关内容