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.

1
  • 1
    Seems you want align* instead of an equation environment. Put & before the equal signs.
    – Johannes_B
    Commented Sep 17, 2017 at 11:13

1 Answer 1

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

4
  • Very nice! I am not sure I understand the \quad though
    – Kundera
    Commented Sep 17, 2017 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 tobi.oetiker.ch/lshort/lshort.pdf and more advanced about math in latex researchgate.net/publication/…
    – Zarko
    Commented Sep 17, 2017 at 14:05
  • I would align left, by moving the & at the beginning of the lines.
    – egreg
    Commented Sep 17, 2017 at 15:28
  • i only follow to op wish :-) , however i agree with you.
    – Zarko
    Commented Sep 17, 2017 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .