케이스의 불평등 정렬
문맥
내가 사용하고 cases
수식을 표시하려면 R-마크 다운 문서 내부에 (내가 사용 Rmarkdown 도구는 공식 결국 조판 할 수있는 완전히 인식하지 나처럼 상황이). 그러나 궁극적으로 (IMHO) rmarkdown과는 아무런 관련이 없지만 순수한 LaTeX
문제입니다 (Rmarkdown 도구 체인의 일부가 아닌 외부 패키지 또는 명령을 추가하는 것이 더 어려워 질 수 있다는 점 외에도)
문제
나는 cases
환경 의 오른쪽에 불평등을 맞추고 싶다 . 문제는 코너 케이스의 경우 하한이 없으므로 부등식이 더 이상 정렬되지 않는다는 것입니다.
내가와의 격차를 채우기 위해 노력 \phantom
하지만 난 대체해야하기 때문에 \leq
, 간격이 정렬되지 않은 기호를 (내가 읽은 여기에 그 LaTeX
추가 \thickmuskip
불평등 연산자 후 나는이 누락 된 정확히 생각한다. 그러나, 나는 추가 할 수 없습니다 \thickmuskip
Rmarkdown에서) .
(NB 나는 그 부질이 말이되지 않는다는 것을 알고있다;)-그러나 그것은 분명히 요점이 아니다)
\begin{cases}
1, & \text{if}\ \phantom{{-1.0}<} x_i < -0.2\\ % too little space
2, & \text{if}\ {-0.2} \leq x_i < -0.1\\ % add brackets around to -0.2 to treat `-` as unary
3, & \text{if}\ {-0.1} \leq x_i < \phantom{-}0.1 \\
4, & \text{if}\ \phantom{{-}}0.1 \leq x_i < \phantom{-}0.5\\
5, & \text{if}\ \phantom{{-0.5}<1} x_i < \phantom{-}5.0 % too much space
\end{cases}
산출

답변
중위 이항 연산자 주변의 간격은 주변에 따라 달라 지므로 내부 수학 목록의 가장자리에 (중괄호 반대) 나타날 때 간격을 잃을 수 있습니다. 마이너스 기호가 unaray 마이너스 (음수)로 남아 있는지 확인하기 위해 이것을 사용했습니다. 좋은! (일부 경우에는 불필요하지만) 문제는 팬텀 끝에 오는 관계 기호와 함께 발생합니다.
\;
이를 보완하기 위해 명시 적 공백 ( )을 추가 하거나 이진 관계 처리를 복원하기 위해 무언가를 제공 할 수 있습니다.
\begin{cases}
1, & \text{if}\ \phantom{{-1.0}<{}} x_i < -0.2\\
2, & \text{if}\ {-0.2} \leq x_i < -0.1\\
3, & \text{if}\ {-0.1} \leq x_i < \phantom{-}0.1 \\
4, & \text{if}\ \phantom{{-}}0.1 \leq x_i < \phantom{-}0.5\\
5, & \text{if}\ \phantom{{-0.5}<{}} x_i < \phantom{-}5.0
\end{cases}
다음을 사용할 수 있습니다 array
.
\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
\begin{equation*}
\left\{
\renewcommand{\arraystretch}{1.2} % like cases does
\setlength{\arraycolsep}{0pt} % we don't want padding
\begin{array}{
l % value
@{\quad} % like cases does
>{$}l<{ $} % text column with trailing normal space
r % lower bound
>{{}}c<{{}} % relation
c % variable
>{{}}c<{{}} % relation
r % upper bound
}
1, & if & & & x_i & < & 0.2 \\
2, & if & -0.2 & \le & x_i & < & -0.1 \\
3, & if & -0.1 & \le & x_i & < & 0.1 \\
4, & if & 0.1 & \le & x_i & < & 0.5 \\
5, & if & 0.5 & \le & x_i
\end{array}
\right.
\end{equation*}
\end{document}
대신 \left\{\renewcommand{\arraystretch}{1.2}
과 \right.
당신은 사용할 수 \begin{cases}
및 \end{cases}
(전체 화면의 왼쪽에 약간의 변화의 비용.

또한 alignedat
중첩 된 케이스 로 더 간단한 가능성이 있습니다. <
표지판 을 정렬하는 것 외에도 줄 끝에 숫자를 정렬하는 것이 좋은 생각이 아닙니다 . 그래서이 empheq
최종 정렬없이 패키지를 사용하여 변형 코드를 추가했습니다 . 각 줄의 번호 또는 하위 번호에 가능성을 추가하여 일부 상황에서 유용 할 수 있습니다.
\documentclass[a4paper,12pt]{article}
\usepackage{array}
\usepackage{empheq}
\begin{document}
\[ \begin{cases}
\begin{alignedat}{3} &1, &\quad & \text{if} & x_i &< -0.2\\ &2, & &\text{if} & \quad -0.2 \leq x_i &< -0.1\\ &3, & &\text{if} &-0.1 \leq x_i & < \phantom{-}0.1 \\ &4, & &\text{if} & \phantom{{-}}0.1 \leq x_i &< \phantom{-}0.5\\ &5, & &\text{if} & x_i &< \phantom{-}5.0 % too much space \end{alignedat}
\end{cases} \]
\vspace{1cm}
\begin{subequations}
\begin{empheq}[left=\empheqlbrace]{alignat=3}
&1, &\quad & \text{if} & x_i &< -0.2\\
&2, & &\text{if} & \quad -0.2 \leq x_i &< -0.1\\
&3, & &\text{if} &-0.1 \leq x_i & < 0.1 \\
&4, & &\text{if} & \phantom{{-}}0.1 \leq x_i &< 0.5\\
&5, & &\text{if} & x_i &< 5.0 % too much space
\end{empheq}
\end{subequations}
\end{document}

방정식에 번호를 매기고 싶지 않다면 array
다른 답변에서 제안한대로를 사용합니다 . 당신이 방정식 번호를하려는 경우, 당신은 사용할 수 {DispWithArrow}
의 witharrows
:
\documentclass{article}
\usepackage{witharrows}
\usepackage{amsmath}
\begin{document}
\begin{DispWithArrows}<f(x_i)=>[format=lrrcccr]
1, & \quad \text{if } & & & x_i & {}<{} & 0.2 \\
2, & \text{if } & {-0.2} & {}\le{} & x_i & {}<{} & {-0.1} \\
3, & \text{if } & {-0.1} & {}\le{} & x_i & {}<{} & 0.1 \\
4, & \text{if } & 0.1 & {}\le{} & x_i & {}<{} & 0.5 \\
5, & \text{if } & 0.5 & {}\le{} & x_i
\end{DispWithArrows}
\end{document}

좋아, 분명히 나는 \thickmuskip
명령이 아니라 길이라는 것을 오해했다 . \;
다음을 추가해야합니다.
\begin{cases}
1, & \text{if}\ \phantom{{-1.0}<}\; x_i < -0.2\\
2, & \text{if}\ {-0.2} \leq x_i < -0.1\\
3, & \text{if}\ {-0.1} \leq x_i < \phantom{-}0.1 \\
4, & \text{if}\ \phantom{{-}}0.1 \leq x_i < \phantom{-}0.5\\
5, & \text{if}\ \phantom{{-0.5}<}\; x_i < \phantom{-}5.0
\end{cases}
