
このMWEを、ケース環境における条件の調整:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
f(x) = \left\{\begin{alignedat}{3}
& mx^2 +nx +1, &\text{if } & x \le -1 \\
& 2m e^{|x|-1} + \sin \pi x - 3n, \qquad &\text{if } -1 < {}&x < 1 \\
& 3x^2 - (m+n)x, &\text{otherwise} &
\end{alignedat}\right.
\]
\end{document}
結果は次のようになります:
if
s と の両方otherwise
を揃え、 s を揃えたいと思いますx
。
それは で実行できますか{aligned}
? もしそうなら、どこが間違っているのでしょうか?
答え1
&&
条件を左揃えにするには を使用する必要があります。x
も揃えるには、この場合は を使用することをお勧めします\hphantom
。
ノート:
- 2 番目のケースでは、 が二項演算子ではなく単項演算子として扱われる
{-1}
ように、を使用する必要があります。-
コメントからのご質問にお答えします:
- それぞれが左右の位置合わせポイント
&
を提供します。つまり、テキストr
l
前には&
右揃えで、テキストは後は揃えられ&
ますl
。したがって、最初の はを右に&
揃えf(x) = {
、後続の式を左に揃えます。次に、後続のテキスト (条件の先頭) を揃える必要がありますl
。つまり、 が必要です&&
。最初の はight の揃え&
になりr
、2 番目の はeft の&
揃えが確保されますl
。 - を使用すると
\hphantom
、目的の配置を簡単に得ることができます。 もちろん を使用してもかまいませんが、テキストのために、ある種のマクロ&
を使用する必要がありました。 不等式がテキストと重なっていることに注意してください。\lap
otherwise
otherwise
他の 2 つのアプローチの結果は次のとおりです。
コード:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent
Recommended approach: use a \verb|\hphantom{}|:
\[
f(x) = \left\{\begin{alignedat}{3}
& mx^2 +nx +1, &&\text{if } \hphantom{-1 <{}} x \le -1 \\
& 2m e^{|x|-1} + \sin \pi x - 3n, \qquad &&\text{if } {-1} < x < 1 \\
& 3x^2 - (m+n)x, &&\text{otherwise}
\end{alignedat}\right.
\]
Use additional \verb|&| instead of \verb|\hphantom{}|:
\[
f(x) = \left\{\begin{alignedat}{4}
& mx^2 +nx +1, &&\text{if } & && &x \le -1 \\
& 2m e^{|x|-1} + \sin \pi x - 3n, \qquad &&\text{if } & {-1} &&{}< {}&x < 1 \\
& 3x^2 - (m+n)x, &&\text{otherwise}
\end{alignedat}\right.
\]
With \verb|mathllap|:
\[
f(x) = \left\{\begin{alignedat}{4}
& mx^2 +nx +1, &&\text{if } & && &x \le -1 \\
& 2m e^{|x|-1} + \sin \pi x - 3n, \qquad &&\text{if } & {-1} &&{}< {}&x < 1 \\
& 3x^2 - (m+n)x, &&\text{\rlap{otherwise}}
\end{alignedat}\right.
\]
\end{document}
答え2
代替案としては、環境を使用することですcases
。ここでは、配置を犠牲にしてアンパサンドが少なくて済みますx
が、個人的には、その方がエレガントだと思います。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
f(x) = \begin{cases}
mx^2 +nx +1, &\text{if } x \le -1 \\
2m e^{|x|-1} + \sin \pi x - 3n, &\text{if } -1 < x < 1 \\
3x^2 - (m+n)x, &\text{otherwise}
\end{cases}
\]
\end{document}
答え3
これを使えば
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
f(x) = \left\{\begin{alignedat}{3}
& mx^2 +nx +1, &&\text{if } & & x \le -1 \\
& 2m e^{|x|-1} + \sin \pi x - 3n, \qquad &&\text{if } &-1< & x < 1 \\
& 3x^2 - (m+n)x, &&\text{otherwise} &&
\end{alignedat}\right.
\]
\end{document}
編集: 画像:
編集(bbeeton による): 調整された画像:
ここでの違いは、2 行目の左側の<
記号の周りのスペースにあります。これは、次の 2 つの方法のいずれかで実現できます。
... &-1<{} & x < 1
という事実を利用してバツ両方の行の幅は同じで、次のように入力します。
& mx^2 +nx +1, &&\text{if } & x &\le -1 \\ & 2m e^{|x|-1} + \sin \pi x - 3n, \qquad &&\text{if } & -1< x &< 1 \\
&
演算および関係の記号の周囲の適切な間隔は、記号の前に揃える場合にのみ保証されます 。