Zentrieren der Gleichung in einer ausgerichteten mathematischen Umgebung

Zentrieren der Gleichung in einer ausgerichteten mathematischen Umgebung

Ich frage mich, wie man Teile von Gleichungen in einer ausgerichteten Umgebung zentrieren kann. Es soll so aussehen:
Bildbeschreibung hier eingeben
oder dieses:
Bildbeschreibung hier eingeben
derzeit sieht mein Code wie unten dargestellt aus, er liefert mir jedoch nicht das gewünschte Ergebnis:

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

Vielen Dank im Voraus!

Antwort1

Am besten definieren Sie Ihre eigene Umgebung durch Ändern 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}

$$Bitte aus keinem Grund in LaTeX verwenden .

Bildbeschreibung hier eingeben

Antwort2

Sie können arraystattdessen Folgendes verwenden:

\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

verwandte Informationen