![在段落中对齐长公式](https://linux22.com/image/455658/%E5%9C%A8%E6%AE%B5%E8%90%BD%E4%B8%AD%E5%AF%B9%E9%BD%90%E9%95%BF%E5%85%AC%E5%BC%8F.png)
我有包含长方程式的 Latex 文本。我希望方程式与文本对齐,并且不超过文本的右边框。
In graph theory, a Graph $G = (V,E)$ is defined over a set of vertices $V=V(G)$ and a set of edges $E=E(G)$. A path is a sequence ${x_1,x_2,...,x_n}$ such that $(x_1,x_2), (x_2,x_3), ..., (x_(n-1),x_n) \subseteq E(G)$ and the $x_i$ are distinct. A cycle is a subset of the $E(G)$ that forms a path such that the first node of the path corresponds to the last.
编译上述内容,我得到以下输出:
我如何强制$(x_1,x_2), (x_2,x_3), ..., (x_(n-1),x_n) \subseteq E(G)$
将部分内容与段落中的文本对齐?
答案1
你似乎正在\usepackage{palatino}
设置 13cm 的文本宽度。事实上,我可以用
\documentclass[a4paper]{article}
\usepackage{palatino}
\usepackage{geometry}
\geometry{
textwidth=13cm
}
\begin{document}
\noindent
In graph theory, a Graph $G = (V,E)$ is defined over a set of
vertices $V=V(G)$ and a set of edges $E=E(G)$. A path is a
sequence ${x_1,x_2,...,x_n}$ such that
$(x_1,x_2), (x_2,x_3), ..., (x_(n-1),x_n) \subseteq E(G)$
and the $x_i$ are distinct. A cycle is a subset of the $E(G)$
that forms a path such that the first node of the path
corresponds to the last.
\end{document}
在处理线路过满问题之前,有几件事需要注意。
执行
\usepackage{newpxtext,newpxmath}
或\usepackage{mathpazo}
获取匹配的数学字体。修复错误的下标:应该是
x_{n-1}
(带括号)而不是x_(n-1)
使用
\dots
代替...
,以及\usepackage{amsmath}
。
好吧,问题变得更糟了……
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{newpxtext,newpxmath}
\usepackage{geometry}
\geometry{
textwidth=13cm
}
\begin{document}
\noindent
In graph theory, a Graph $G = (V,E)$ is defined over a set of
vertices $V=V(G)$ and a set of edges $E=E(G)$. A path is a
sequence ${x_1,x_2,\dots,x_n}$ such that
$(x_1,x_2), (x_2,x_3), \dots, (x_{n-1},x_n) \subseteq E(G)$
and the $x_i$ are distinct. A cycle is a subset of the $E(G)$
that forms a path such that the first node of the path
corresponds to the last.
\end{document}
如何补救?首先要尝试的是重新措辞该段落。例如,我们看到符号\subseteq
应该是\in
,并且没有规定边应该是有序的顶点对。
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{newpxtext,newpxmath}
\usepackage{geometry}
\geometry{
textwidth=13cm
}
\linespread{1.04}% Palatino wants more room between lines
\begin{document}
\noindent
In graph theory, a \emph{graph} $G = (V,E)$ is defined over a set of
vertices $V=V(G)$ and a set of edges $E=E(G)$, which is a subset of $V\times V$.
A \emph{path} is a sequence of vertices ${x_1,x_2,\dots,x_n}$ such that
$(x_1,x_2), (x_2,x_3), \dots, (x_{n-1},x_n) \in E(G)$
and the $x_i$ are distinct, with the possible exception of $x_1$ and~$x_n$.
If $x_1=x_n$, the path is called a \emph{cycle}.
\end{document}
这并不总是有效,但在困难的情况下,您可以尝试\linebreak
在这些长序列中添加逗号。
数学笔记:我不认为你希望顶点路径中的边缘. 在这种情况下,文本可能为
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{newpxtext,newpxmath}
\usepackage{geometry}
\geometry{
textwidth=13cm
}
\linespread{1.04}% Palatino wants more room between lines
\begin{document}
\noindent
In graph theory, a \emph{graph} $G = (V,E)$ is defined over a set of
vertices $V=V(G)$ and a set of edges $E=E(G)$, which is a subset of $V\times V$.
A \emph{path} is a sequence of vertices ${x_1,x_2,\dots,x_n}$ such that
$(x_1,x_2), (x_2,x_3), \dots, (x_{n-1},x_n) \in E(G)$
and the edges are distinct. If $x_1=x_n$, the path is called a \emph{cycle}.
\end{document}