具有對齊方式的巢狀數組

具有對齊方式的巢狀數組

我正在嘗試生成乳膠輸出,如下所示。

在此輸入影像描述

然而,這些類型並沒有正確對齊。看起來它訂閱了之前的陣列環境。您能指出其中的錯誤嗎?

我的程式碼如下 -

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

\def    \R      {\mathbb{R}}

\begin{document}

\begin{equation}
    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{equation}
\end{document}

答案1

這是您需要的:

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

\def\R{\mathbb{R}}

\begin{document}

\begin{equation}
    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{equation}
\end{document}

輸出在這裡:

在此輸入影像描述

tabular環境類似,您可以在 中定義多個列,array並以 分隔它們&

此外,您還可以輸入一些文字\text{}以羅馬字體排版。

答案2

我會cases在這裡使用:

% arara: pdflatex

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

\begin{document}
    \begin{equation}
        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{equation}
\end{document}

在此輸入影像描述

相關內容