bobdu.cc

Follow me on GitHub

Arrays 数组


tags : latex


It is often easier to read tables formatted in MathJax rather than plain text or a fixed width font. Arrays and tables are created with the array environment. Just after \begin{array} the format of each column should be listed, use c for a center aligned column, r for right aligned, l for left aligned and a | for a vertical line. Just as with matrices, cells are separated with & and rows are broken using \\. A horizontal line spanning the array can be placed before the current line with \hline. 通常相比纯文本或固定宽度字体的表格,MathJax格式的表格是更易读的。 使用 array 环境来创建数组和表格。 在 \begin{array} 后列出每列的格式,使用 c 作为中心对齐列, r 为右对齐, l 为左对齐, | 为垂直线。 就像使用矩阵一样,单元格用 & 分隔,用 \\ 换行。 横跨整个数组的水平线可以在这行之前放 \hline

For example, 举个例子,

$$
\begin{array}{c|lcr}
n & \text{Left} & \text{Center} & \text{Right} \\
\hline
1 & 0.24 & 1 & 125 \\
2 & -1 & 189 & -8 \\
3 & -20 & 2000 & 1+10i
\end{array}
$$

Arrays can be nested to make an array of tables. 数组可以嵌套组成数组表。

For example, 举个例子,

$$
% outer vertical array of arrays
\begin{array}{c}
% inner horizontal array of arrays
    \begin{array}{cc}
    % inner array of minimum values
        \begin{array}{c|cccc}
            \text{min} & 0 & 1 & 2 & 3\\
            \hline
            0 & 0 & 0 & 0 & 0\\
            1 & 0 & 1 & 1 & 1\\
            2 & 0 & 1 & 2 & 2\\
            3 & 0 & 1 & 2 & 3
        \end{array}
        &
    % inner array of maximum values
        \begin{array}{c|cccc}
            \text{max}&0&1&2&3\\
            \hline
            0 & 0 & 1 & 2 & 3\\
            1 & 1 & 1 & 2 & 3\\
            2 & 2 & 2 & 2 & 3\\
            3 & 3 & 3 & 3 & 3
        \end{array}
    \end{array}
    \\
% inner array of delta values
    \begin{array}{c|cccc}
        \Delta&0&1&2&3\\
        \hline
        0 & 0 & 1 & 2 & 3\\
        1 & 1 & 0 & 1 & 2\\
        2 & 2 & 1 & 0 & 1\\
        3 & 3 & 2 & 1 & 0
    \end{array}
\end{array}
$$

本文由BobDu翻译修改自https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference