我正在尝试在最后两行添加方程编号。
代码如下:
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{array}
\begin{document}
\[\begin{array}{ll}
\max\limits_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1)\\
\max\limits_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1\\
{s.t.} &\\
p_1\le p_2 & \hfill(\text{when } a_1\le a_2)\\
x_1r_1 \le p_2 &\hfill (\text{when } a_2 < a_1)
\end{array}\]
\end{document}
答案1
我会用 来做这件事alignat
。我也建议使用subequations
环境,但如果你因为某种原因不想要它,只需将其删除即可。
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{array}
\begin{document}
\begin{subequations}
\begin{alignat}{2}
\max_{p_1} \pi_R &=(p_1-c_1) & & (a_1-b_1*p_1) \notag \\
\max_{p_2,x_1} \pi_C &=(p_2-c_2) & & (a_2-b_2*p_2)-x_1r_1 \notag \\
\text{s. t.\enspace}p_1 & \le p_2 & & (\text{when } a_1\le a_2) \\
x_1r_1 & \le p_2 & & (\text{when } a_2 < a_1)
\end{alignat}
\end{subequations}
\end{document}
答案2
注意数组使用内联数学不显示所以不适合显示方程式,您可以通过\limits
在上进行部分补偿\max
但它仍然使用垂直压缩布局和水平周围的过度空间&
。
我会做类似的事情
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{array}
\begin{document}
zzz
\begin{align*}
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1)\\
\max_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1
\end{align*}
s.t.
\begin{align}
p_1\le p_2 && (\text{when } a_1\le a_2)\\
x_1r_1 \le p_2 &&(\text{when } a_2 < a_1)
\end{align}
\end{document}
答案3
根据以上回复,我尝试了以下代码,输出如下:
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}
\begin{document}
\begin{flalign}
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1) \nonumber \\
\max_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1 \nonumber\\
\text{s.t.} \nonumber\\
p_1\le p_2 && (\text{when } a_1\le a_2)\\
x_1r_1 \le p_2 &&(\text{when } a_2 < a_1)
\end{flalign}
\begin{align}
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1) \nonumber \\
\max_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1 \nonumber\\
\text{s.t.} \nonumber\\
p_1\le p_2 && (\text{when } a_1\le a_2)\\
x_1r_1 \le p_2 &&(\text{when } a_2 < a_1)
\end{align}
\begin{subequations}
\begin{alignat}{2}
\max_{p_1} \pi_R &=(p_1-c_1) & & (a_1-b_1*p_1) \notag \\
\max_{p_2,x_1} \pi_C &=(p_2-c_2) & & (a_2-b_2*p_2)-x_1r_1 \notag \\
\text{s. t.\enspace} \notag \\
p_1 & \le p_2 & & (\text{when } a_1\le a_2) \\
x_1r_1 & \le p_2 & & (\text{when } a_2 < a_1)
\end{alignat}
\end{subequations}
\end{document}