1

I need to write this

enter image description here

So far I started my code this way:

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

 \begin{document}
\begin{equation*}
\begin{cases}
 u_t+2uu_x=0,              & x \in \mathbb{R}, t>0\\
 u(x,0)=g(x)=\begin{cases}
-1/2, & x<0,\\
1/2, & x>0.
\end{cases}
\end{cases}
\end{equation*}
\end{document}

I get a similar result, which is not really in the same format. The equation are not aligned according to the equal sign, and I have an extra open parenthesis which I don't know how to remove.

Zarko
  • 296,517
Kundera
  • 35

1 Answers1

2

enter image description here

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

\begin{document}
\begin{align*}
  u_t+2uu_x   & = 0 ,\quad          x \in \mathbb{R}, t>0\\
u(x,0) = g(x) & = \begin{cases}
                -1/2, & x<0,\\
                 1/2, & x>0.
                    \end{cases}
\end{align*}
\end{document}

or maybe (stole from Werner's answer):

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

\makeatletter
\newcases{mycases}{\quad}{%
  \hfil$\m@th\displaystyle{##}$}{$\m@th\displaystyle{##}$\hfil}{\lbrace}{.}
\makeatother

\begin{document}
\begin{align*}
  u_t+2uu_x   & = 0 ,\quad          x \in \mathbb{R}, t>0\\
u(x,0) = g(x) & = \begin{mycases}
                -1/2, & x<0,\\
                 1/2, & x>0.
                    \end{mycases}
\end{align*}
\end{document}

enter image description here

Zarko
  • 296,517
  • Very nice! I am not sure I understand the \quad though – Kundera Sep 17 '17 at 13:47
  • \quad determine space between variables or words in math environments (equations). I suggest you to read some introductory literature about latex, for example https://tobi.oetiker.ch/lshort/lshort.pdf and more advanced about math in latex https://www.researchgate.net/publication/295920492_More_Math_into_LaTeX_fifth_edition – Zarko Sep 17 '17 at 14:05
  • I would align left, by moving the & at the beginning of the lines. – egreg Sep 17 '17 at 15:28
  • i only follow to op wish :-) , however i agree with you. – Zarko Sep 17 '17 at 18:52