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
    Sep 17 '17 at 11:13
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
    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 tobi.oetiker.ch/lshort/lshort.pdf and more advanced about math in latex researchgate.net/publication/…
    – 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.