我在使用内联数学模式时遇到了一些问题,我想找到一种方法来避免这种情况。我注意到,如果内联数学模式太靠近编译时显示的行的最右边缘,它会扩展到下一行。以下是 MWE 的代码选择,以说明我的意思:
\documentclass[12pt]{report}
\usepackage{amsmath, amsthm}
\DeclareMathOperator{\lin}{lin}
\begin{document}
\begin{proof}
Our aim is to show that any sequence of functions in $\lin\{\psi(\cdot)x;x\in H,\psi\in D\}$ can be approximated by some function in $S(\mu;H)$ under $\|\cdot\|_{L_2(\mu;H)}$. If true, we would then have
\end{proof}
\end{document}
在第一行和第二行,$\lin\{\psi(\cdot)x;x\in H,\psi\in D\}$
并$\|\cdot\|_{L_2(\mu;H)}$
扩展到后续行。虽然没有在这个 MWE 中显示,但我也注意到有时这可能会导致内联数学表达式超出边距边界。
有没有办法强制 TeX 将这些数学模式表达式放到下一行,以避免它们跨越两行,同时增加前一行中单词之间的空白,以填充行中的空格,否则该空格将由数学模式表达式的移位部分填充(并避免使用时会出现尴尬的空白\newline
)? 有没有可以应用于整个文档而不仅仅是段落的解决方案?
答案1
构造中间的换行符\|\cdot\|
是因为 TeX 不知道第一个符号\|
是“打开”类型的符号,第二个符号是“关闭”类型的符号。您应该使用 来告诉 TeX \lVert...\rVert
,或者最好定义一个宏\norm{...}
来处理这个问题。这并不能解决所有问题,因为内联数学总是会使换行变得复杂。您可以尝试\linebreak
手动插入 s 或\allowbreak
,但最终还是要由人眼来判断,在许多情况下,重新措辞是最好的选择。此外,我会避免使用较长的内联数学表达式。
\documentclass[12pt,draft]{report}
\usepackage{mathtools}% loads amsmath
\usepackage{amsthm}
\DeclareMathOperator{\lin}{lin}
\DeclarePairedDelimiter{\norm}{\Vert}{\Vert}
\newcommand*{\blank}{{\:\cdot\:}}
\setlength{\parindent}{0pt}
\begin{document}
\textbf{Your version:}
\begin{proof}
Our aim is to show that any sequence of functions in $\lin\{\psi(\cdot)x;x\in H,\psi\in D\}$
can be approximated by some function in $S(\mu;H)$ under $\|\cdot\|_{L_2(\mu;H)}$.
If true, we would then have\ldots
\end{proof}
\textbf{What you seem to be looking for:}
\begin{proof}
Our aim is to show that any sequence of functions in $\lin\{\psi(\cdot)x;x\in H,\psi\in D\}$
can be approximated by some function in $S(\mu;H)$ under\linebreak$\|\cdot\|_{L_2(\mu;H)}$.
If true, we would then have\ldots
\end{proof}
\textbf{Better tell \LaTeX\ what $\|$ is}
\begin{proof}
Our aim is to show that any sequence of functions in $\lin\{\psi(\cdot)x;x\in H,\psi\in D\}$
can be approximated by some function in $S(\mu;H)$ under $\lVert\blank\rVert_{L_2(\mu;H)}$.
If true, we would then have\ldots
\end{proof}
\textbf{Even better, let \texttt{mathtools} do it}
\begin{proof}
Our aim is to show that any sequence of functions in $\lin\{\psi(\cdot)x;x\in H,\psi\in D\}$
can be approximated by some function in $S(\mu;H)$ under $\norm{\blank}_{L_2(\mu;H)}$.
If true, we would then have\ldots
\end{proof}
\textbf{Isn't this much more readable?}
\begin{proof}
Our aim is to show that any sequence of functions in
\[
\lin\{\psi(\cdot)x; x\in H, \psi\in D\}
\]
can be approximated by some function in $S(\mu;H)$ under $\norm{\blank}_{L_2(\mu;H)}$.
If true, we would then have\ldots
\end{proof}
\end{document}