Equação de centralização em ambiente matemático alinhado

Equação de centralização em ambiente matemático alinhado

Estou me perguntando como centralizar partes de equações em um ambiente alinhado. Eu quero que fique assim:
insira a descrição da imagem aqui
ou isto:
insira a descrição da imagem aqui
atualmente meu código é mostrado abaixo, porém não está me dando o resultado que eu gostaria:

$$\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.$$  

Agradeço antecipadamente!

Responder1

É melhor definir seu próprio ambiente modificando 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}

Por favor, não use $$em LaTeX, por nenhum motivo.

insira a descrição da imagem aqui

Responder2

Você pode usar um arrayem vez disso:

\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

informação relacionada