1

I have the following code:

\begin{gather}
 u(x,t) = 0 \ \mathrm{ si\ } x = 0,  x = 1\\
\label{ex1bc}
\\
u(x,0) = \left\{
       \begin{array}{ll}
     2x,      & \mathrm{si\ } 0 \le x \le 1/2 \\
     2(1-x) & \mathrm{si\ } 1/2 \le x \le 1 \\
       \end{array}
     \right.
   \label{ex1inicial}
\end{gather}

That produces:

a

I would like to have that but without the blank equation 2.23. What am I doing wrong?

2
  • What you need is 2 equations with cases in the second one. – Sigur Feb 9 '16 at 1:43
  • Just remove the double-backslash after x = 0, x = 1. – Mico Feb 9 '16 at 1:45
5

You have a spurious extra \\ after the first equation. Remove it, and the extra line will disappear.

For the second equation, do consider using a cases environment; for one, the left-hand curly brace will be a bit larger.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'cases' env. and `\text` macro
\numberwithin{equation}{section} % just for this example
\setcounter{section}{2}          % just for this example
\setcounter{equation}{21}
\begin{document}
\begin{gather}
u(x,t) = 0 \text{ si } x = 0,  x = 1 \label{ex1bc}\\
u(x,0) = \begin{cases}
            2x     & \text{si } 0   \le x \le 1/2 \\
            2(1-x) & \text{si } 1/2 \le x \le 1 \\
         \end{cases} \label{ex1inicial}
\end{gather}
\end{document}
0

Load amsmath.

\begin{document}
\begin{equation}
u(x,t) = 0 \text{ si } x = 0,  x = 1\label{ex1bc}
\end{equation}
\begin{equation}
u(x,0)=\begin{cases}
x,      & \text{si  $0 \le x \le 1/2$}, \\
2(1-x),  & \text{si  $1/2 \le x \le 1$.} \\
\end{cases}
\end{equation}
\end{document}

enter image description here

3
  • Since the OP uses a gather environment, he must have loaded the amsmath package (or the mathtools package) already. – Mico Feb 9 '16 at 1:56
  • @Mico, yes, I agree. But in case someone simply read the answer... – Sigur Feb 9 '16 at 1:59
  • You may want to state explicitly somewhere that your solution to the OP's problem is to replace the gather environment with two consecutive equation environments. – Mico Feb 9 '16 at 2:01

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.