所以我有这个等式
\[f\left(x\right) = \begin{cases}
x & 0 < x \le h \\
-\frac{1}{2}\left(x - \left(h + 1\right)\right)^2 + \left(h + \frac{1}{2}\right) & h < x \le h + 4 \\
-\left(x - \left(h + 5\right)\right)^3 + \left(h - 5\right) & h + 4 < x \le h + 6 \\
\frac{3}{\pi}\sin \left(\pi \left(x - h - 1\right)\right) + \left(h - 6\right) & h + 6 < x \le h + 14 \\
-\ln \left(x - \left(h + \frac{41}{3}\right)\right) + \left(\left(h - 6\right) + \ln \left(\frac{1}{3}\right)\right) & h + 14 < x \\
\end{cases}\]
但我希望域名像这样对齐
并且域的左侧在块内左对齐,如下所示:
答案1
一种方法是使用array
有三l
列的 而不是cases
。
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\[
f\left(x\right) =
\left\{\!\begin{array}{ll@{}>{{}}l}
x & 0 & < x \le h \\
-\frac{1}{2}\left(x - \left(h + 1\right)\right)^2 + \left(h + \frac{1}{2}\right) & h & < x \le h + 4 \\
-\left(x - \left(h + 5\right)\right)^3 + \left(h - 5\right) & h + 4 & < x \le h + 6 \\
\frac{3}{\pi}\sin \left(\pi \left(x - h - 1\right)\right) + \left(h - 6\right) & h + 6 & < x \le h + 14 \\
-\ln \left(x - \left(h + \frac{41}{3}\right)\right) + \left(\left(h - 6\right) + \ln \left(\frac{1}{3}\right)\right) & h + 14 & < x \\
\end{array}\right.
\]
\end{document}
答案2
下面\eqmakebox[<tag>][<align>]{<stuff>}
确保所有类似的<tag>
内容具有相同的宽度和l
长度<align>
:
\documentclass{article}
\usepackage{amsmath,eqparbox}
\begin{document}
\[
f(x) = \begin{cases}
x & \eqmakebox[lhs][l]{$0$} < x \leq h \\
-\frac{1}{2} \bigl( x - (h + 1) \bigr)^2 + (h + \frac{1}{2}) & \eqmakebox[lhs][l]{$h$} < x \leq h + 4 \\
-\bigl( x - (h + 5) \bigr)^3 + (h - 5) & \eqmakebox[lhs][l]{$h + 4$} < x \leq h + 6 \\
\frac{3}{\pi} \sin \bigl( \pi (x - h - 1) \bigr) + (h - 6) & \eqmakebox[lhs][l]{$h + 6$} < x \leq h + 14 \\
-\ln \bigl(x - (h + \frac{41}{3}) \bigr) + \bigl( (h - 6) + \ln (\frac{1}{3}) \bigr) & \eqmakebox[lhs][l]{$h + 14$} < x
\end{cases}
\]
\end{document}