정렬된 수학 환경의 중심 방정식

정렬된 수학 환경의 중심 방정식

정렬된 환경에서 방정식의 일부를 중앙에 배치하는 방법이 궁금합니다. 나는 그것이 다음과 같이 보이기를 원합니다 :
여기에 이미지 설명을 입력하세요
아니면 이거:
여기에 이미지 설명을 입력하세요
현재 내 코드는 아래와 같지만 내가 원하는 결과를 제공하지 않습니다.

$$\lvert x \rvert = \left\{ \begin{aligned}
    &x,\quad & \text{for $x \geqslant 0$} \\
    -&x,\quad & \text{for $x < 0$.}
    \end{aligned} \right. $$

$$f(x) = \left\{ \begin{aligned}
    {\textstyle\frac{3}{2}}, &\text{for $ x > 0$} \\
    \text{undefined},\quad & \text{for $x=0$} \\
    {\textstyle\frac{2}{3}}, & \text{for $x < 0$}
    \end{aligned} \right.$$  

미리 감사드립니다!

답변1

다음을 수정하여 자신만의 환경을 정의하는 것이 가장 좋습니다 cases.

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter
\newenvironment{casescentered}
 {\let\@ifnextchar\new@ifnextchar
  \left\lbrace
  \def\arraystretch{1.2}%
  \array{@{}c@{\quad}l@{}}}
 {\endarray\right.}
\makeatother

\begin{document}

\begin{equation*}
\lvert x \rvert = 
\begin{casescentered}
  x, & \text{for $x \geqslant 0$} \\
  -x,& \text{for $x < 0$.}
\end{casescentered}
\end{equation*}

\begin{equation*}
f(x) = 
\begin{casescentered}
  \tfrac{3}{2},     & \text{for $ x > 0$} \\
  \text{undefined}, & \text{for $x=0$} \\
  \tfrac{2}{3},     & \text{for $x < 0$}
\end{casescentered}
\end{equation*}

\begin{equation*}
\lvert x \rvert = 
\begin{cases}
  x, & \text{for $x \geqslant 0$} \\
  -x,& \text{for $x < 0$.}
\end{cases}
\end{equation*}

\begin{equation*}
f(x) = 
\begin{cases}
  \tfrac{3}{2},     & \text{for $ x > 0$} \\
  \text{undefined}, & \text{for $x=0$} \\
  \tfrac{2}{3},     & \text{for $x < 0$}
\end{cases}
\end{equation*}

\end{document}

$$어떤 이유로든 LaTeX에서는 사용하지 마십시오 .

여기에 이미지 설명을 입력하세요

답변2

대신 다음 을 사용할 수 있습니다 array.

\documentclass{article} 
\usepackage{amsmath,amssymb}
\begin{document}

\[\lvert x \rvert = \left\{ \begin{array}{@{}c@{\quad}l}
     x,   & \text{for $x \geqslant 0$} \\
    -x,   & \text{for $x < 0$.}
    \end{array} \right. \]

\[f(x) = \left\{ \begin{array}{@{}c@{\quad}l}
    \tfrac{3}{2},     & \text{for $ x > 0$} \\
    \text{undefined}, & \text{for $x=0$} \\
    \tfrac{2}{3},     & \text{for $x < 0$}
    \end{array} \right. \]

\end{document}

[1]: https://i.stack.imgur.com/dY8cr.png

관련 정보