大家好,
我想写出像附图一样的方程式。我尝试在下面写这段代码,但我无法从相同位置开始生成“Hp”。
我应该怎样写代码才能得到这样的图片。
\begin{eqnarray} \label{eq:5}
Se & = & \left\{
\begin{array}{ll}
\frac{1}{{[1+|\alpha H_{p}|^{n}]}^{m}} & \quad H_{p}<0\\
1 & \quad H_{p} \geq0
\end{array}
\right. \nonumber
\\
\theta & = & \left\{
\begin{array}{ll}
\theta_{r}+Se(\theta_{s}-\theta_{r}) & \quad H_{p}<0\\
\theta_{s} & \quad H_{p} \geq0
\end{array}
\right.
\\
C & = & \left\{
\begin{array}{ll}
\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})Se^{\frac{1}{m}}\left(1-Se^{\frac{1}{m}}\right)^{m} & \quad H_{p}<0\\
0 & \quad H_{p} \geq0
\end{array}
\right. \nonumber
\\
k_{r} & = & \left\{
\begin{array}{ll}
Se^{l}\left[1-\left(1-Se^{\frac{1}{m}}\right)^{m} \right]^2 & \quad H_{p}<0\\
1 & \quad H_{p} \geq0
\end{array}
\right. \nonumber
\end{eqnarray}
答案1
请不要使用eqnarray
!它已经弃用多年了。对于这样的东西,有cases
来自amsmath
或较新的mathtools
。只需将所有内容放在里面即可align
。对齐最右列的技巧是\hphantom
在此处使用。我希望,这就是你想要的。
% arara: pdflatex
\documentclass{article}
\usepackage{mathtools}
\newcommand{\Se}{\operatorname{\mathit{S\kern-.15em e}}}
\begin{document}
\begin{align*}
\theta &=
\begin{dcases}
\theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_{p}<0 \\
\mathrlap{\theta_{s}}\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}} & H_{p} \geq 0
\end{dcases}\\
\Se &=
\begin{dcases}
\frac{1}{{\bigl[1+\lvert\alpha H_{p}\rvert^{n}\bigr]}^{m}} & H_{p}<0 \\
\mathrlap{1}\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}} & H_{p} \geq 0
\end{dcases} \\
C &=
\begin{dcases}
\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} & H_{p}<0 \\
0 & H_{p} \geq 0
\end{dcases} \\
k_{r} &=
\begin{dcases}
\Se^{l}\Bigl[1-\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} \Bigr]^2 & H_{p}<0 \\
\mathrlap{1}\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}} & H_{p} \geq 0
\end{dcases}
\end{align*}
\end{document}
daleif 建议,你也可以定义某个宽度,并将下行mathmakebox
左对齐。如下所示:
\begin{align*}
\theta &=
\begin{dcases}
\theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_{p}<0 \\
\mathmakebox[5cm][l]{\theta_{s}} & H_{p} \geq 0
\end{dcases}\\
\Se &=
\begin{dcases}
\frac{1}{{\bigl[1+\lvert\alpha H_{p}\rvert^{n}\bigr]}^{m}} & H_{p}<0 \\
\mathmakebox[5cm][l]{1} & H_{p} \geq 0
\end{dcases} \\
C &=
\begin{dcases}
\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} & H_{p}<0 \\
\mathmakebox[5cm][l]{0} & H_{p} \geq 0
\end{dcases} \\
k_{r} &=
\begin{dcases}
\Se^{l}\Bigl[1-\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} \Bigr]^2 & H_{p}<0 \\
\mathmakebox[5cm][l]{1} & H_{p} \geq 0
\end{dcases}
\end{align*}
答案2
这是一个解决方案,它使用四个dcases
环境,放置在aligned
一个环境所包含的环境中equation
。我实际上不是不必费心为四对条件语句提供共同的对齐方式。相反,我会专注于 (a) 不要让某些单独的行变得太高,例如,通过书写...^{1/m}
而不是...^\frac{1}{m}
(b) 在四组子方程之间提供更多的垂直空白。
\documentclass{article}
\usepackage{mathtools} % for 'dcases' environment
\newcommand\Se{\textit{Se}}
\begin{document}
\begin{equation} \label{eq:5}
\begin{aligned}
\Se &= \begin{dcases}
\frac{1}{[1+\lvert\alpha H_p \rvert^{n}]^{m}} & H_p<0\\
1 & H_p\geq0
\end{dcases} \\[2ex]
\theta &= \begin{dcases}
\theta_{r}+\Se (\theta_{s}-\theta_{r}) & H_p<0\\
\theta_{s} & H_p\geq0
\end{dcases}\\[2ex]
C &= \begin{dcases}
\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se ^{1/m} \bigl(1-\Se ^{1/m}\bigr)^{m} & H_p<0\\
0 & H_p\geq0
\end{dcases}\\[2ex]
k_{r} &= \begin{dcases}
\Se^{l}\bigl[1-(1-\Se ^{1/m})^{m} \bigr]^2 & H_p<0\\
1 & H_p\geq0
\end{dcases}
\end{aligned}
\end{equation}
\end{document}
附录:如果您认为最好也对齐四个条件对,那么这里有一个实现此目标的直接方法:(a)将方程中最长的项保存到名为的宏中,\longestterm
并测量其宽度;(b)将子方程 1、2 和 4 各放置一个项,\parbox
其宽度为\longestterm
。
\documentclass{article}
\usepackage{mathtools} % for 'dcases' environment
\newcommand\Se{\textit{Se}}
\newlength\mylen
\newcommand\longestterm{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se ^{1/m} (1-\Se ^{1/m}) ^{m}}
\settowidth\mylen{$\displaystyle\longestterm$}
\begin{document}
\begin{equation} \label{eq:5}
\begin{aligned}
\Se &= \begin{dcases}
\frac{1}{[1+\lvert\alpha H_p\rvert^{n}]^{m}} & H_p<0\\
\parbox{\mylen}{$1$} & H_p\geq0
\end{dcases} \\[2ex]
\theta &= \begin{dcases}
\theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_p<0\\
\parbox{\mylen}{$\theta_{s}$} & H_p\geq0
\end{dcases}\\[2ex]
C &= \begin{dcases}
\longestterm & H_p<0\\
0 & H_p\geq0
\end{dcases}\\[2ex]
k_{r} &= \begin{dcases}
\Se^{l}\bigl[1-(1-\Se^{1/m})^{m} \bigr]^2 & H_p<0\\
\parbox{\mylen}{$1$} & H_p\geq0
\end{dcases}
\end{aligned}
\end{equation}
\end{document}
答案3
这只是对 LaRiFaRis 解决方案的补充,用更少的代码做同样的事情
\documentclass{article}
\usepackage{mathtools}
\newcommand{\Se}{\operatorname{\mathit{S\kern-.15em e}}}
\newcommand\mybox[1]{}
\begin{document}
% jsut to make this function for this patciluar case
\renewcommand\mybox[1]{
\mathrlap{#1}
\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}}
}
\begin{align*}
\theta &=
\begin{dcases}
\theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_{p}<0 \\
\mybox{\theta_{s}} & H_{p} \geq 0
\end{dcases}\\
\Se &=
\begin{dcases}
\frac{1}{{\bigl[1+\lvert\alpha H_{p}\rvert^{n}\bigr]}^{m}} & H_{p}<0 \\
\mybox{1} & H_{p} \geq 0
\end{dcases} \\
C &=
\begin{dcases}
\frac{\alpha
m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}
& H_{p}<0 \\
% this is the widest, so no need to do it here, but we do for
% completness
\mybox{0} & H_{p} \geq 0
\end{dcases} \\
k_{r} &=
\begin{dcases}
\Se^{l}\Bigl[1-\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} \Bigr]^2 & H_{p}<0 \\
\mybox{1} & H_{p} \geq 0
\end{dcases}
\end{align*}
\end{document}
答案4
一个简单的解决方案eqparbox
:我定义一个\eqmathbox
命令,使所有具有相同标签的命令的长度等于最长的内容(需要两次编译):
\documentclass{article}
\usepackage{mathtools} % for 'dcases' environment
\usepackage{eqparbox}
\newcommand\eqmathbox[2][M]{\eqmakebox[#1][l]{$\displaystyle#2$}}
\newcommand\Se{\textit{Se}}
\begin{document}
\begin{equation} \label{eq:5}
\begin{aligned}
\Se &= \begin{dcases}
\eqmathbox{\frac{1}{[1+\lvert\alpha H_p\rvert^{n}]^{m}}} & H_p<0\\
1 & H_p\geq0
\end{dcases} \\[2ex]
\theta &= \begin{dcases}
\eqmathbox{\theta_{r}+\Se(\theta_{s}-\theta_{r})}
& H_p<0\\
\theta_{s} & H_p\geq0
\end{dcases}\\[2ex]
C &= \begin{dcases}
\eqmathbox{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})Se^{\frac{1}{m}}\left(1-Se^{\frac{1}{m}}\right)^{m}} & H_p<0\\
0 & H_p\geq0
\end{dcases}\\[2ex]
k_{r} &= \begin{dcases}
\eqmathbox{\Se^{l}\bigl[1-(1-\Se^{1/m})^{m} \bigr]^2} & H_p<0\\
1 & H_p\geq0
\end{dcases}
\end{aligned}
\end{equation}
\end{document}