有没有更简洁的方法将所有方程式左对齐?
下面的代码生成这个等式:
其分割方程并非 100% 对齐。
\documentclass{article}
\usepackage{amsmath}
\usepackage{breqn}
\begin{document}
\begin{equation}
\begin{split}
&\text{minimize \quad} Z(w) \\
&\text{subject to\quad } f_1(w) \leq a_1\\
&\quad \quad \quad \quad \quad f_2(w) \leq a_2 \\
&\quad \quad \quad \quad \quad \quad \quad \vdots\\
&\quad \quad \quad \quad \quad f_m(w) \leq a_m,
\end{split}
\end{equation}
\end{document}
答案1
此解决方案使用数组。与表格一样,它在列之间添加固定空间。为了好玩,我还排列了不等式。
\documentclass{article}
\usepackage{mathtools}%for \vdotswithin
\usepackage{breqn}% I have no idea what this does
\begin{document}
\begin{equation}
\begin{array}{ll@{}l}
\text{minimize} &Z(w)\\
\text{subject to} &f_1(w) &{}\leq a_1\\
& f_2(w) &{}\leq a_2 \\
&&\vdotswithin{\leq} \\
&f_m(w) &{}\leq a_m,\\
\end{array}
\end{equation}
\end{document}
输出:
答案2
简单点,这&
是你的朋友,将文本移到另一边。
\documentclass{article}
\usepackage{amsmath}
\usepackage{breqn}
\begin{document}
\begin{equation}
\begin{split}
\text{minimize \quad}&Z(w) \\
\text{subject to\quad }&f_1(w) \leq a_1\\
&f_2(w) \leq a_2 \\
&\quad\quad \vdots\\
&f_m(w) \leq a_m,
\end{split}
\end{equation}
\end{document}
答案3
这是一个可能的解决方案:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{mathtools} % also loads amsmath
\begin{document}
Text before the equation
\begin{equation}
\begin{alignedat}{2}
& \text{Minimize } && Z(w) \\
& \text{subject to } && f_{1}(w)\le a_{1} \\
& && f_{2}(w)\le a_{2} \\
& && \hphantom{f_{2}(w)}\vdotswithin{\le} \\
& && f_{m}(w)\le a_{m} \\
\end{alignedat}
\label{eq:minimize}
\end{equation}
Text after the equation.
\end{document}
输出:
答案4
这里有堆栈:
\documentclass{article}
\usepackage{mathtools}%for \vdotswithin
\usepackage{tabstackengine}%
\setstackgap{L}{14pt}
\begin{document}
\begin{equation}
\stackText
\Longunderstack[l]{minimize\\subject to}
\quad\stackMath
\TABbinary
\tabbedLongunderstack[l]{
Z(w)&\\
f_1(w) &\leq a_1\\
f_2(w) &\leq a_2 \\
&\vdotswithin{\leq} \\
f_m(w) &\leq a_m,
}
\end{equation}
\end{document}
...这里有一个没有全部左对齐的:
\documentclass{article}
\usepackage{mathtools}%for \vdotswithin
\usepackage{tabstackengine}%
\setstackgap{L}{14pt}
\begin{document}
\begin{equation}
\stackText
\Longunderstack[l]{minimize\\subject to}
\quad\stackMath
\alignLongunderstack{
Z(w)\phantom{{}\le{}}&\\
f_1(w) \leq& a_1\\
f_2(w) \leq& a_2 \\
\vdotswithin{\leq}& \\
f_m(w) \leq& a_m,
}
\end{equation}
\end{document}