我正在尝试用 LaTeX 编写一个很长的 LP 问题,大约 5-7 行。我尝试使用多行,但由于某种原因它无法编译。
这是我的代码:
\begin{multline}
Min \quad Z = 111x_{11} + 111x_{12} + 109.25x_{13} + 111x_{14} + 113x_{15}\\
+107.25x_{21} + 119.5x_{22} + 107.7x_{23} + 103.75x_{24} + 109.7x_{25}\\
+ x_{13} + x_{23} + x_{33} + x_{34} + x_{35}\\
+ x_{14} + x_{24} + x_{34} + x_{44} + x_{45]\\
+ x_{15} + x_{25} + x_{35} + x_{45} + x_{55}\\
+ x_{16} + x_{26} + x_{36} + x_{46} + x_{56}\\
+ x_{17} + x_{27} + x_{37} + x_{47} + x_{57}\\
\end{multline}
如果我把目标函数写到 x_{35} 为止,它就会编译,但如果我要完成它,它就不会编译。
答案1
除了用 替换之外x_{45]
,x_{45}
您可能还想考虑multline
用嵌套的equation
/aligned
环境替换环境。
另外,除非你被某些(糟糕且非常特殊的印刷惯例)强迫这样做,否则不要写Min
;而是写\min
。
\documentclass{article}
\usepackage{amsmath} % for 'aligned' env.
\begin{document}
\noindent
Combined \texttt{equation}/\texttt{aligned} solution:
\begin{equation}\begin{aligned}[b]
\min Z &= 111x_{11} + 111x_{12} + 109.25x_{13} + 111x_{14} + 113x_{15}\\
&\quad +107.25x_{21} + 119.5x_{22} + 107.7x_{23} + 103.75x_{24} + 109.7x_{25}\\
&\quad + x_{13} + x_{23} + x_{33} + x_{34} + x_{35}\\
&\quad + x_{14} + x_{24} + x_{34} + x_{44} + x_{45}\\
&\quad + x_{15} + x_{25} + x_{35} + x_{45} + x_{55}\\
&\quad + x_{16} + x_{26} + x_{36} + x_{46} + x_{56}\\
&\quad + x_{17} + x_{27} + x_{37} + x_{47} + x_{57}
\end{aligned}\end{equation}
\bigskip\noindent
\texttt{multline} solution:
\begin{multline}
\min Z = 111x_{11} + 111x_{12} + 109.25x_{13} + 111x_{14} + 113x_{15}\\
+107.25x_{21} + 119.5x_{22} + 107.7x_{23} + 103.75x_{24} + 109.7x_{25}\\
+ x_{13} + x_{23} + x_{33} + x_{34} + x_{35}\\
+ x_{14} + x_{24} + x_{34} + x_{44} + x_{45}\\
+ x_{15} + x_{25} + x_{35} + x_{45} + x_{55}\\
+ x_{16} + x_{26} + x_{36} + x_{46} + x_{56}\\
+ x_{17} + x_{27} + x_{37} + x_{47} + x_{57}
\end{multline}
\end{document}
附录满足 OP 的后续要求,即让所有七行中的条目“更加对齐”。这当然可能的要做到这一点,比如借助环境array
——见下文。IMNSHO,不过,你不是用这样的符号来表示对读者来说是一件好事。如果这是我的论文,我会使用\sum
指令来表示要对 25 个变量进行简单的求和。
(请注意,为了与 OP 在后续请求中的写作保持一致,以下代码中的下标排序与原始答案中使用的下标排序有很大不同。)
\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\newcolumntype{C}{>{{}}c<{{}}}
\begin{document}
\noindent
Combined \texttt{equation}/\texttt{aligned} solution:
\begin{equation}\begin{aligned}[b]
\min Z &= 111x_{11} + 111x_{12} + 109.25x_{13} + 111x_{14} + 113x_{15}\\
&\quad +107.25x_{21} + 119.5x_{22} + 107.7x_{23} + 103.75x_{24} + 109.7x_{25}\\
&\quad + x_{13} + x_{23} + x_{33} + x_{34} + x_{35}\\
&\quad + x_{14} + x_{24} + x_{34} + x_{44} + x_{45}\\
&\quad + x_{15} + x_{25} + x_{35} + x_{45} + x_{55}\\
&\quad + x_{16} + x_{26} + x_{36} + x_{46} + x_{56}\\
&\quad + x_{17} + x_{27} + x_{37} + x_{47} + x_{57}
\end{aligned}\end{equation}
\bigskip\noindent
``even more aligned'': combined \texttt{equation}, \texttt{aligned}, and \texttt{array}
\begin{equation}\begin{aligned}[b]
\setlength{\arraycolsep}{0pt}
\begin{array}[b]{@{} r*{6}{Cr} @{}}
\min Z &=& 111x_{11} &+& 111x_{12} &+& 109.25x_{13} &+& 111x_{14} &+& 113x_{15}\\
&+&107.25x_{21} &+& 119.5x_{22} &+& 107.7x_{23} &+& 103.75x_{24} &+& 109.7x_{25}\\
&+& x_{31} &+& x_{32} &+& x_{33} &+& x_{34} &+& x_{35}\\
&+& x_{31} &+& x_{42} &+& x_{43} &+& x_{44} &+& x_{45}\\
&+& x_{51} &+& x_{52} &+& x_{53} &+& x_{54} &+& x_{55}\\
&+& x_{61} &+& x_{62} &+& x_{63} &+& x_{64} &+& x_{65}\\
&+& x_{71} &+& x_{72} &+& x_{73} &+& x_{74} &+& x_{75}\\
\end{array}
\end{aligned}\end{equation}
\bigskip\noindent
\verb+\sum+ notation to replace rows 3 to 7:
\begin{equation}\begin{aligned}[b]
\min Z &= 111x_{11} + 111x_{12} + 109.25x_{13} + 111x_{14} + 113x_{15}\\
&\quad +107.25x_{21} + 119.5x_{22} + 107.7x_{23} + 103.75x_{24} + 109.7x_{25}\\
&\quad+ \smashoperator{\sum_{\substack{i=3,\dots,7;\\j=1,\dots,5}}} x_{ij}
\end{aligned}\end{equation}
\end{document}