當表中有數組時,如何在表行中添加更多填充?

當表中有數組時,如何在表行中添加更多填充?

我發現在表格行之間添加更多間距的解決方案是使用\arraystretch

但這對我不起作用。我的桌子\begin{array}裡面有。並且\arraystretch拉伸表內的數組,而不是在顯示的向量底部和表行之間添加更多空間,這就是我想要的。

請注意array:我無法將最後一列中用於排版向量的程式碼變更為其他內容。因為該程式碼是自動產生的。

我可以更改表中的其他任何內容,但必須保持程式碼array不變。我沒有辦法改變這一點。

例子將有助於解釋。

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{center}
\bgroup
\renewcommand{\arraystretch}{2}
\begin{tabular}{|c|c|c|c|c|}\hline
eigenvalue & {\footnotesize algebraic multiplicity $m$}&  {\footnotesize geometric multiplicty $k$}& {\small defective?}& eigenvectors \\ \hline 
$3 i$&$1$&$1$&No&$\left[\begin{array}{c}i \\1 \\\end{array}\right]$ \\ \hline
$-3 i$&$1$&$1$&No&$\left[\begin{array}{c}-i \\1 \\\end{array}\right]$ \\ \hline
\end{tabular}
\egroup
\end{center}                       
\end{document}

使用 lualatex 編譯時,這是輸出

在此輸入影像描述

更改\renewcommand{\arraystretch}{2}\renewcommand{\arraystretch}{5}還會拉伸內部向量,保持向量底部和表格邊緣之間的空間相同,這不是我想要的。

這是結果5

在此輸入影像描述

解決這個問題的正確方法是什麼?我只需要顯示的向量的頂部/底部與分隔行的線之間有更多的空間。其餘的單元格都正常。

TL 2020

參考:

背頁

答案1

您可以使用 套件\makegapedcells中定義的巨集為儲存格內容添加一些垂直空間makecell。由於您的表格太寬,可以適合文字寬度,因此我建議重新制定第二列和第三列的列標題:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{makecell}

\begin{document}
    \begin{center}
    \setcellgapes{5pt}
    \makegapedcells
\begin{tabular}{|*{5}{c|} }
    \hline
    &   \multicolumn{2}{c|}{ multiplicity}
            &   &                   \\
    \cline{2-3}
eigenvalue 
    &   algebraic $m$
        &   multiplicty $k$
            &   defective?
                &   eigenvectors    \\ 
    \hline
$3i$    & 1 & 1 &   No  & $\begin{bmatrix} i \\1 \end{bmatrix}$     \\ 
    \hline
$-3i$   & 1 & 1 &   No  & $\begin{bmatrix} -i \\1 \end{bmatrix}$     \\ 
    \hline
\end{tabular}
    \end{center}
\end{document}

在此輸入影像描述

編輯:

如果您出於某種原因使用矩陣程式碼,那麼只需將簡短而優雅的程式碼​​ using 替換bmatrix為您的程式碼array

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{makecell}

\begin{document}
    \begin{center}
    \setcellgapes{5pt}
    \makegapedcells
\begin{tabular}{|*{5}{c|} }
    \hline
    &   \multicolumn{2}{c|}{ multiplicity}
            &   &                   \\
    \cline{2-3}
eigenvalue 
    &   algebraic $m$
        &   multiplicty $k$
            &   defective?
                &   eigenvectors    \\ 
    \hline
$3i$    & 1 & 1 &   No  & $\left[\begin{array}{c} i \\1 \end{array}\right]$     \\ 
    \hline
$-3i$   & 1 & 1 &   No  & $\left[\begin{array}{c} -i \\1 \end{array}\right]$     \\ 
    \hline
\end{tabular}
    \end{center}
\end{document}

上述解決方案的結果與之前相同...

答案2

cellspace包使您能夠定義最小的列中單元格頂部和底部的垂直填充,說明符以字母為前綴S(或者C如果您加載siunitx,並且該math選項對於矩陣環境執行相同的操作amsmath 。獨立於這個問題,我冒昧地通過替換為來簡化您的\left[\begin{array}[c}...\end{array}\right]代碼越簡單\begin{bmatrix} ... \end{bmatrix}

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[math]{cellspace}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}

\begin{document}

\begin{center}
\begin{tabular}{|*{5}{Sc|}}\hline
eigenvalue & {\footnotesize algebraic multiplicity $m$}& {\footnotesize geometric multiplicty $k$}& {\small defective?}& eigenvectors \\ \hline
$3 i$&$1$&$1$&No&$\begin{bmatrix}i \\ \,1\, \end{bmatrix}$ \\ \hline
$-3 i$&$1$&$1$&No&$\begin{bmatrix} -i \\1 \\\end{bmatrix}$ \\ \hline
\end{tabular}
\end{center}

\end{document}

在此輸入影像描述

相關內容