4

I am trying to generate the following equation: enter image description here

I am working with an old file (I have not written it) that already has the following code for this equation:

\begin{equation}
\delta(x)\equiv\left\{\all\begin{aligned}
0,\quad
\text{if}\;x\ne 0\\
\infty,\quad
\text{if}\; x=0
\end{aligned}\right\}\quad
\text{with}\quad\int_{-\infty}^{+\infty}\delta(x)\;dx=1.
\end{equation}   

But this code doesn't work. Do you know what is wrong with that?

1
  • 1
    After removing the \all in the second line, your code seems to produce the desired result
    – siracusa
    Commented Apr 26, 2019 at 0:38

5 Answers 5

3

You can compare four ways to get the result.

The alignment with the original code happens essentially by chance and needs visual formatting (additions of \quad and \;).

With Bmatrix the alignment is again by chance (the second column items have the same width).

With cases, adding \left. and \right., a bigger space after \equiv is used.

The best, in my opinion, is to use \left\{ and \right\}, with a nested aligned so you can clearly state the desired left alignment of both columns.

In any case, it should be \text{if $x=0$}, so no awkward explicit \; is needed (which is not a normal interword space). Also \, should precede dx, not \;.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\subsubsection*{Original without \texttt{\string\all}}
\begin{equation}
\delta(x)\equiv\left\{\begin{aligned}
0,\quad
\text{if}\;x\ne 0\\
\infty,\quad
\text{if}\; x=0
\end{aligned}\right\}\quad
\text{with}\quad\int_{-\infty}^{+\infty}\delta(x)\;dx=1.
\end{equation}  

\subsubsection*{With \texttt{Bmatrix}}
\begin{equation}
\delta(x)\equiv
\begin{Bmatrix}
0,      & \text{if $x\ne 0$} \\
\infty, & \text{if $x=0$}
\end{Bmatrix}
\quad\text{with}\quad
\int_{-\infty}^{+\infty}\delta(x)\,dx=1.
\end{equation}

\subsubsection*{With \texttt{cases}}
\begin{equation}
\delta(x)\equiv
\left.
\begin{cases}
0,      & \text{if $x\ne 0$} \\
\infty, & \text{if $x=0$}
\end{cases}\right\}
\quad\text{with}\quad
\int_{-\infty}^{+\infty}\delta(x)\,dx=1.
\end{equation}

\subsubsection*{With \texttt{aligned}}
\begin{equation}
\delta(x)\equiv
\left\{
\begin{aligned}
&0,      && \text{if $x\ne 0$} \\
&\infty, && \text{if $x=0$}
\end{aligned}
\right\}
\quad\text{with}\quad
\int_{-\infty}^{+\infty}\delta(x)\,dx=1.
\end{equation}

\end{document}

enter image description here

5

As @siracusa has already pointed out in a comment, the \all directive should be removed. The only other significant change I recommend making to your code is adding & alignment points inside the aligned environment. (After all, why employ an algin environment if no alignment is performed?)

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'aligned' environment
\begin{document}

\begin{equation}
\delta(x)\equiv
\left\{
\begin{aligned}
0,     \quad&\text{if $x\ne 0$}\\
\infty,\quad&\text{if $x=0$}
\end{aligned}
\right\}\,,
\qquad\text{with }
\int_{-\infty}^{+\infty}\! \delta(x)\,dx=1.
\end{equation}   
\end{document}
4

You can use cases to simplify it a little bit and, of course, remove \all as @siracusa said.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\delta(x)\equiv\left.\begin{cases}
0,      & \text{if } x \ne 0 \\
\infty, & \text{if } x = 0 
\end{cases}\right\}, \quad\text{with } \int_{-\infty}^{+\infty}\delta(x)\; dx = 1.
\end{equation}

\end{document}

enter image description here

2
  • Can you explain \left. please? I am guessing it is somehow affecting the size of the opening curly bracket?
    – Simd
    Commented Apr 26, 2019 at 6:17
  • 1
    The \left and \right in LaTeX must appear in pairs, each opening \left must have its closing \right the same as parentheses () in programming. In your case you only need the \right\} because cases inserts its own \left\{, so you must add a "virtual" \left. just to balance the closing \right\}.
    – AboAmmar
    Commented Apr 26, 2019 at 10:40
2

The simplest way is probably the Bmatrix environment.

Unrelated: I took the opportunity to improve the spacing in the integral.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{equation}
\delta(x)\equiv
\begin{Bmatrix}
0, & \text{if } x \ne 0 \\
\infty, & \text{if } x = 0
\end{Bmatrix},
\quad\text{with }\int_{-\infty}^{\mathrlap{+\infty}}\delta(x)\,dx = 1.
\end{equation}

\end{document} 

enter image description here

2

Using only array as another alternative with a basic syntax. I have also used double \!\! negative space, before and after to have the two bracket more closer. See the figure and the MWE.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for '\text' macro
\begin{document}
\[
\delta(x)\equiv
  \Biggl\{
  \begin{array}{@{}cl@{}}
      0,      & \text{ if $x \ne 0$}  \\
      \infty, & \text{ if $x = 0$} 
  \end{array}
  \Biggr\},
\quad\text{with}\quad
\int_{-\infty}^{+\infty}\delta(x)dx=1.
\]
\end{document}
1
  • 1
    @Mico Thank you very much for your preciuous suggestion. My always best regards. You are free to edit my answer if you prefer. :-) I have understood all :-)
    – Sebastiano
    Commented Apr 28, 2019 at 21:31

You must log in to answer this question.

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