# writing an array and group the contents using curly brackets

I want to write down the following equation:

my try is this:

\documentclass[preview, border=1pt, convert={outext=.png}]{standalone}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{braket}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{equation*}
n + m =^{def} \left\{\begin{array}{rl} n+n + \ldots + n & \text{se } m > 0 \\ 0 & \text{se } m = 0\end{array}\right.
\end{equation*}
\end{document}


I don't know how to group the elements using curl brackets.

PS: I'd like also the background to be transparent and not white. I'm compiling with this:

pdflatex --shell-escape formula.tex && convert -resize 50% formula.png formula.png

• What's the purpose of the square? – egreg Oct 21 '19 at 10:09
• it signifies end of definition – Michaelangelo Meucci Oct 21 '19 at 10:10
• I've never seen it used that way, – egreg Oct 21 '19 at 10:12

I suggest to use the ambient cases to write your "equation". Here you have a screenshot of my MWE.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
$n+m\stackrel{\text{def}}{=} \begin{cases} \underbrace{\sigma(\sigma(\ldots\sigma}_{m\text{ volte}}(n))) & \text{se m>0}\\ n & \text{se m=0}.\qquad \square \end{cases}$
\end{document}


Comment: Reading carefully the precious suggestions of the excellent users @egreg and @Mico my initial code has been modified.

• I think the case environment is better than my solution with \hspace. I didn't know this environment. Thank you. – NelDav Oct 21 '19 at 9:56
• It should be _{\text{$m$ volte}} (the fact it works also without braces around \text{...} is irrelevant. Alternatively, _{m\text{ volte}}. I'd also use \dotsm instead of \ldots. – egreg Oct 21 '19 at 10:03
• +1. In addition to incorporating @egreg's comment, you should also change \text{se } m>0 to \text{se $m>0$}, and \text{se } m=0. to '\text{se $m=0$}.. Why? Mostly for reasons of semantic consistency: The clauses se $m>0$ and se $m=0$ are two standalone linguistic particles, and hence (at least from a LaTeX point of view) it's preferable to encase them in \text directives. The fact that both linguistic particles contain a math formula -- $m>0$ and $m=0$, resp. -- does not change the fact that they are linguistic particles that shouldn't be broken up needlessly. – Mico Oct 21 '19 at 10:32
• @Ahrtaler Slowly and patiently you'll certainly be better at it than me. I wish it with all my heart. – Sebastiano Oct 21 '19 at 11:28

Your code didn't worked so I couldn't try. But this code should work:

\documentclass{standalone}

\usepackage{amsmath}

\begin{document}
$n + m \overset{\text{def}}{=} \left\{\begin{array}{l} \underbrace{\sigma(\sigma(\ldots\sigma}_\text{m \text{volte}}(n))) \hspace{5mm} \text{se } m > 0\\ n \hspace{24mm} \text{se } m = 0 \end{array} \right.$
\end{document}

• Instead of \left\{\begin{array}...\right., you can use \begin{cases}...\end{cases}`... – MadyYuvi Oct 21 '19 at 11:28