如何在直线上分解长方程?

发布于 2024-08-08 20:22:30 字数 392 浏览 4 评论 0原文

我正在尝试在新行中添加一个方程。问题是方程对于该行来说太长了,我需要手动打破它。否则,它只会重叠到右列或右边缘(并且看起来很难看......)。 有没有一种方法可以让 LaTeX 帮我打破方程,看起来不错?

我附上我的乳胶代码:

\begin{align*}
f(n)-f(0) &= A(n)-B(n)-C(n)-D(n)\cdot d-\left(A(0)-B(0)-C(0)-D(0)\cdot d\right) \\
          &= A(n)-0-X-D(n)\cdot d-\left(0-0-0-0\right) \\
          &= A(n)-X-D(n)\cdot d
\end{align*}

有问题的行是第一行,它太长了。

I am trying to add an equation in a new line. The problem is that the equation is too long for the line, and I need to break it manually. Otherwise, it just overlaps to the right column, or to the right margins (and looks ugly...).
Is there a way LaTeX can brake the equation for me, so it seems nice?

I'm attaching my latex code:

\begin{align*}
f(n)-f(0) &= A(n)-B(n)-C(n)-D(n)\cdot d-\left(A(0)-B(0)-C(0)-D(0)\cdot d\right) \\
          &= A(n)-0-X-D(n)\cdot d-\left(0-0-0-0\right) \\
          &= A(n)-X-D(n)\cdot d
\end{align*}

The problematic line is the first line, which is too long.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你另情深 2024-08-15 20:22:30

breqn 包旨在自动分割长方程。它在大多数情况下都工作得很好,但它不如 amsmath 包那么成熟。以下是编写示例方程的方法:

\documentclass{article}
\usepackage{breqn}
\begin{document}
\begin{dmath}
f(n)-f(0) = A(n)-B(n)-C(n)-D(n)\cdot d-\left(A(0)-B(0)-C(0)-D(0)\cdot d\right)
          = A(n)-0-X-D(n)\cdot d-\left(0-0-0-0\right)
          = A(n)-X-D(n)\cdot d
\end{dmath}
\end{document}

请注意,没有用于对齐或换行的标记,但输出看起来与使用 align 基本相同。

The breqn package is designed to split long equations automatically. It works very well in the majority of situations, but it's not as mature as the amsmath package. Here's how you'd write your example equation:

\documentclass{article}
\usepackage{breqn}
\begin{document}
\begin{dmath}
f(n)-f(0) = A(n)-B(n)-C(n)-D(n)\cdot d-\left(A(0)-B(0)-C(0)-D(0)\cdot d\right)
          = A(n)-0-X-D(n)\cdot d-\left(0-0-0-0\right)
          = A(n)-X-D(n)\cdot d
\end{dmath}
\end{document}

Note there is no markup for alignment or newlines, but the output looks essentially the same as if you used align.

夏有森光若流苏 2024-08-15 20:22:30

我通常更喜欢使用 amsmath 包和 split 结构来处理这个问题。其中有很多有用的结构用于跨行分割方程,但这通常是最简单的使用方式。

许多 TeX 安装已经包含该软件包,但您也可以从 AMS 网站 获取该软件包。

I usually prefer to handle this by using the amsmath package and using the split structure. There are a bunch of useful structures in there for splitting equations across lines, but that's usually the simplest to use.

Many TeX installations will already have the package, but you can also get it from the AMS website.

舟遥客 2024-08-15 20:22:30

我过去使用的标准方法是 eqnarray。例如,请参阅此页面

The standard approach I've used in the past is an eqnarray. See for example this page.

流绪微梦 2024-08-15 20:22:30

据我所知,这是不可能的。在显示器内部工作时,您需要负责换行。如何换行,以及如何在出现括号的情况下继续下一行,对于人类来说是一个棘手的问题(例如,检查 Grätzer 中的相关部分,“Math into LaTeX”),更不用说对于计算机了。

例子:
当您在 \left( 后断开第一行时,您需要在末尾添加 \right. ,并在下一行的开头添加 \left. (否则您会收到错误)。此外,您还需要开头下一行的位置比 \left( 生成的括号更右边

As far as I know, this is not possible. When working inside a display, you are responsible for line breaks. How to line break, and how to continue on the next line in case of brackets, is a tough question for humans (check, for instance, the relevant section in Grätzer, "Math into LaTeX"), let alone for a computer.

Example:
when you break the first line after \left(, you need a \right. at the end, and \left. at the beginning of the next line (otherwise you'll get an error). Moreover, you'd want the beginning of the next line to be further right than the bracket produced by \left(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文