长等式怎么写

长等式怎么写

我想以能够右对齐的方式编写以下等式。没错,大多数元素都在同一列。这里左对齐已完成。

\begin{eqnarray*}
y_{0}&= &(r_{73} + 1)r_{9} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{73} + 1)r_{93} + \\
      &  &r_{73} + 1)r_{98} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})\\
      &  &r_{115} + r_{73} + 1)r_{85} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} \\
      &  & + 1)r_{93} +((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115} \\
      &  &+ r_{68} + 1)r_{131} +r_{73} + 1)r_{88} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} + ((r_{68}r_{73} + r_{68})\\
      &  &r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115} + \\
      &  &r_{68} + 1)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} \\
      &  &+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} \\
      &  &+ r_{7} + r_{9})r_{93} + r_{73}r_{9} + 1)r_{115} +((r_{73} + 1)r_{9} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}  \\
      &  &+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1)r_{93} +r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} \\
      &  &+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}\\ 
\end{eqnarray*}

答案1

我还建议您使用该align环境,但建议您:

  • 如果可能的话,不要在括号中换行
  • 在需要在括号内断开的情况下,以某种方式直观地表明这一点。在这里,我使用了稍大的括号,但也许更大的括号或方括号会更好,以便轻松找到匹配的括号。在这种情况下,我还添加了额外的缩进

在此处输入图片描述

笔记:

  • 你的括号不匹配。我在代码中有一个注释来指示位置,并将其保留原样。
  • [showframe]包的选项用于geometry显示边距的位置。因此,代码适合类的默认宽度article。这可能需要根据您的文本宽度尺寸进行调整。

代码:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{amsmath}

\begin{document}
\begin{align*}
y_{0}
&= (r_{73} + 1)r_{9} 
+ ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} 
+ ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110}\\
&\quad+ ((r_{73} + 1)r_{93} + r_{73} + 1)r_{98}
+ ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123}\\
&\quad+ ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} + 1)r_{85}\\
% This is a long expression
&\quad+ \big((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} 
 + ((r_{68} + 1)r_{73} + r_{68}+ 1)r_{93} \\
&\quad\qquad+((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115}\\
&\quad\qquad+ r_{68} + 1)r_{131}
+r_{73} + 1\big)r_{88} \\
% -------------------------------------
&\quad+ ((r_{68} + 1)r_{73} % Not sure where this opening ( is supposed to close
+ ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} \\
% Another long expression:
&\quad+ \big((r_{68}r_{73} + r_{68}
r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} \\
&\quad\qquad+ (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115} + r_{68} + 1 \big)r_{131}\\
% ----------------------
&\quad+ (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} \\
%
% Another long expression:
&\quad+ \big((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110}
+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} \\
&\quad\qquad+ (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + r_{9})r_{93} \\
&\quad\qquad+ r_{73}r_{9} + 1\big)r_{115} \\
% -----------------------------------------------
% Another long expression:
&\quad+ \big((r_{73} + 1)r_{9} 
+ (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}
+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1\big)r_{93}\\
% -----------------------------------------------
% Rest are single terms so we can break them anywhere
&\quad+r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15}
+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}\\
&\quad+ r_{7} + r_{90}
\end{align*}
\end{document}

答案2

align从包装中使用amsmath

\documentclass{minimal}
\usepackage{amsmath}

\begin{document}
\begin{align*}
y_{0}=(r_{73} + 1)r_{9} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{73} + 1)r_{93}& + \\
      r_{73} + 1)r_{98} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})&\\
      r_{115} + r_{73} + 1)r_{85} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} &\\
       + 1)r_{93} +((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115} &\\
      + r_{68} + 1)r_{131} +r_{73} + 1)r_{88} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} + ((r_{68}r_{73} + r_{68})&\\
      r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115}& + \\
      r_{68} + 1)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} &\\
      + (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} &\\
      + r_{7} + r_{9})r_{93} + r_{73}r_{9} + 1)r_{115} +((r_{73} + 1)r_{9} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}  &\\
      + r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1)r_{93} +r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} &\\
      + r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}&
\end{align*}
\end{document}

如果您希望所有内容都紧贴边距,只需替换eqnarrayflalign,同样来自amsmath

\documentclass{minimal}
\usepackage{amsmath}

\begin{document}
\begin{flalign*}
y_{0}=&& (r_{73} + 1)r_{9} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{73} + 1)r_{93} &+ \\
      &  &r_{73} + 1)r_{98} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})\\
      &  &r_{115} + r_{73} + 1)r_{85} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} \\
      &  & + 1)r_{93} +((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115} \\
      &  &+ r_{68} + 1)r_{131} +r_{73} + 1)r_{88} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} + ((r_{68}r_{73} + r_{68})\\
      &  &r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115} &+ \\
      &  &r_{68} + 1)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} \\
      &  &+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} \\
      &  &+ r_{7} + r_{9})r_{93} + r_{73}r_{9} + 1)r_{115} +((r_{73} + 1)r_{9} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}  \\
      &  &+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1)r_{93} +r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} \\
      &  &+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}\\ 
\end{flalign*}
\end{document}

答案3

无需太多人工干预(我只是为了避免最严重的中断而替换+1\plusone

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}

\newenvironment{verylongequation}[1]
 {\begin{equation}\setupverylongequation{#1}}
 {\stopverylongequation\end{equation}}
\newenvironment{verylongequation*}[1]
 {\begin{equation*}\setupverylongequation{#1}}
 {\stopverylongequation\end{equation*}}

\makeatletter

\newcommand{\plusone}{+\nobreak 1}
\newcommand{\setupverylongequation}[1]{%
  \begin{minipage}{.8\linewidth}
  \medmuskip=1\medmuskip % no stretching or shrinking
  \raggedright
  \settowidth{\dimen@}{$#1={}$}%
  \setlength{\leftskip}{\dimen@}%
  \setlength{\parindent}{-\dimen@}%
  $#1=
}
\newcommand{\stopverylongequation}{$\end{minipage}}
\makeatother

\begin{document}

\lipsum*[2]
\begin{verylongequation*}{y_{0}}
(r_{73} \plusone)r_{9} + ((r_{73} \plusone)r_{93} + r_{73} \plusone)r_{108} + ((r_{73} \plusone)r_{93} 
+ r_{73} \plusone)r_{110} + ((r_{73} \plusone)r_{93} + r_{73} \plusone)r_{98} + ((r_{73} 
\plusone)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} \plusone)r_{123} + ((r_{73} \plusone)r_{93} + (r_{73} + 
r_{93}) r_{115} + r_{73} \plusone)r_{85} + ((r_{73} \plusone)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} 
\plusone)r_{73} + ((r_{68} \plusone)r_{73} + r_{68} \plusone)r_{93} +((r_{73} \plusone)r_{93} + r_{73} 
\plusone)r_{110} + ((r_{68} \plusone)r_{73} + (r_{68} \plusone)r_{93} + (r_{73} + 
r_{93})r_{110})r_{115} + r_{68} \plusone)r_{131} +r_{73} \plusone)r_{88} + ((r_{68} \plusone)r_{73} + 
((r_{68} \plusone)r_{73} + r_{68} \plusone)r_{93} + ((r_{68}r_{73} + r_{68}) r_{93} + r_{68}r_{73} 
+r_{68})r_{110} + ((r_{68} \plusone)r_{73} + (r_{68} \plusone)r_{93} + (r_{68}r_{73} + 
r_{68}r_{93})r_{110})r_{115} + r_{68} \plusone)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + 
r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} + (r_{73} + r_{93})r_{98} + (r_{15} 
+r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 
r_{9})r_{93} + r_{73}r_{9} \plusone)r_{115} +((r_{73} \plusone)r_{9} + (r_{15} + r_{36} + r_{48} + 
r_{6} + r_{61} + r_{7})r_{73} + r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} \plusone)r_{93} 
+r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} + r_{20} + r_{36} + r_{41} + r_{48} + 
r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}
\end{verylongequation*}

\end{document}

在此处输入图片描述

答案4

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mathtools}
\usepackage{braket}
\newcommand*{\myStrut}{\vphantom{1}}

 \pi_{ij}=n\left(n-1\right)p_{i}p_{j}\left[1+\left(p_{i}p_{j}\sum\limits_{j\in\,s}
p^{2}_{j}\right)+\left(2\left(p^{2}_{i}+p^{2}_{j}\right)-2\sum\limits_{j\in\,s}p^{3}_{j}-\left(n-2\right)p_{i}p_{j}+\left(n-3\right)\left(p_{i}+p_{j}
\right)\sum\limits_{j\in\,s}p^{2}_{j}-\left(n-3\right)\left(\sum\limits_{j\in\,s}
p^{2}_{j}\right)^{2}\right)\right]

这是我得到的解决方案,最后一个括号缺失

相关内容