# nested array with alignment

I am trying to generate latex output as given below.

However, the types is not coming properly aligned. It looks like it subscribes to the previous array environment. Could you please point out the error?

My code is as follows -

\documentclass{article}
\usepackage{amssymb,amsmath}

\def    \R      {\mathbb{R}}

\begin{document}

$$M_2=\left\{ \begin{array}{r} variables : \left\{ \begin{array}{r} inputs : x \\ outputs : y \end{array} \right.\\ types : x,y \in \R \\ behaviors : y = e^x \\ \end{array} \right.$$
\end{document}


Here is what you need:

\documentclass{article}
\usepackage{amssymb,amsmath}

\def\R{\mathbb{R}}

\begin{document}

$$M_2=\left\{ \begin{array}{rl} \text{variables :} & \left\{ \begin{array}{r} \text{inputs :} x \\ \text{outputs :} y \end{array} \right.\\ \text{types :} & x,y \in \R \\ \text{behaviors :} & y = e^x \\ \end{array} \right.$$
\end{document}


And the output is here:

Similarly to the tabular environment, you can define multiple columns in the array and separate them by &.

Additionally you can put some text in \text{} to typeset it in roman.

• @MarcvanDongen Yes, I know, I realized it right after I posted the answer and edited it. Thanks anyway. Sep 29, 2014 at 11:31

I would use cases here:

% arara: pdflatex

\documentclass{article}
\usepackage{amssymb,mathtools}
\newcommand*\R{\mathbb{R}}

\begin{document}
$$M_2 = \begin{cases} \text{variables:} &\begin{cases} \text{inputs:} &x\\ \text{outputs:} &y \end{cases}\\ \text{types:} &x,y \in \R\\ \text{behaviors:} &y = e^x \end{cases}$$
\end{document}