从表中删除某些行

从表中删除某些行

我用 LaTeX 制作了以下表格:

\begin{table}[hbt]
                    \begin{center}
                        \begin{tabular}{|l|l|l|l|}
                            \hline & \multicolumn{3}{c|}{Examples}\\
                            \cline{2-4}
                            & description & $M$ & \textbf{u}\\
                            \hline translation & through vector $\begin{pmatrix}6\\7\end{pmatrix}$ & $\begin{pmatrix}
                                1 & 0 \\ 0 & 1
                            \end{pmatrix}$ & $\begin{pmatrix}6\\7\end{pmatrix}$\\
                            \hline reflection & in line $x=2$ & $\begin{pmatrix}
                            -1 & 0 \\ 0 & 1
                            \end{pmatrix}$ & $\begin{pmatrix}4\\0\end{pmatrix}$\\
                            \hline rotation & about \textbf{0} through $\pi$ radians & $\begin{pmatrix}
                            -1 & 0 \\ 0 & -1
                            \end{pmatrix}$ & $\begin{pmatrix}0\\0\end{pmatrix}$\\
                            \hline glide reflection & in line $y=x$, then through $\begin{pmatrix}1\\1\end{pmatrix}$ & $\begin{pmatrix}
                            0 & 1 \\ 1 & 0
                            \end{pmatrix}$ & $\begin{pmatrix}1\\1\end{pmatrix}$\\
                            \hline
                            \end{tabular}
                            \caption{Examples of Euclidean Transformations} \label{tab1}
                    \end{center}
                    \end{table}

如何删除左上角空单元格的两条外部线条?我只想要其他部分周围的线条。

而且它看起来有点拥挤,有什么办法可以让它看起来更美观吗?

答案1

稍微修改一下 Mico 的回答:

  • setspace添加了用于在最后两列单元格内容周围垂直空间的包
  • amsmath改为mathtools,其pmatrix*可以是pmatrix列右对齐

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools, array, cellspace}% changed package, new package

\begin{document}
\begin{table}[hbt]
\setlength\cellspacetoplimit{3pt}    % add vertical space above cell content
\setlength\cellspacebottomlimit{3pt} % add vertical space below cell content
\renewcommand\arraystretch{1.3} % for a slightly more open look
\setlength\arraycolsep{3pt}     % for smaller distances between pmatrix columns
    \centering
    \begin{tabular}{|l|l|*{2}{>{$}Sc<{$}|}} % changed column types for last two columns
\cline{2-4}
\multicolumn{1}{l|}{} & \multicolumn{3}{c|}{Examples}\\
\cline{2-4}
\multicolumn{1}{l|}{} & Description &  M  &  \mathbf{u} \\
\hline
Translation & through vector $\begin{pmatrix}6\\7\end{pmatrix}$
            &  \displaystyle\begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}
            &  \begin{pmatrix}6\\7\end{pmatrix} \\
\hline
Reflection  & in line $x=2$
            &  \begin{pmatrix*}[r] -1 & 0 \\ 0 & 1 \end{pmatrix*}
            &  \begin{pmatrix}4\\0\end{pmatrix} \\
\hline
Rotation    & about $\mathbf{0}$ through $\pi$ radians
            &  \begin{pmatrix*}[r] -1 & 0 \\ 0 & -1 \end{pmatrix*}% right align columns in pmatrix
            &  \begin{pmatrix}0\\0\end{pmatrix} \\
\hline
Glide reflection & in line $y=x$, then through $\begin{pmatrix}1\\1\end{pmatrix}$
            & \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}
            & \begin{pmatrix}1\\1\end{pmatrix} \\
\hline
    \end{tabular}
\caption{Examples of Euclidean Transformations}
    \label{tab1}
\end{table}
\end{document}

答案2

您需要更换标题行

\hline & \multicolumn{3}{c|}{Examples}\\
\cline{2-4}
& description & $M$ & \textbf{u}\\

\cline{2-4} 
\multicolumn{1}{l|}{} & \multicolumn{3}{c|}{Examples}\\
\cline{2-4}
\multicolumn{1}{l|}{} & description & $M$ & $\mathbf{u}$\\

完整的 MWE:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
\begin{table}[hbt]
\setlength\extrarowheight{2pt}  % for a slightly more open look
\centering
\begin{tabular}{|l|l|c|c|}
        \cline{2-4}
        \multicolumn{1}{l|}{} & \multicolumn{3}{c|}{Examples}\\
        \cline{2-4}
        \multicolumn{1}{l|}{} & Description & $M$ & $\mathbf{u}$\\
        \hline
        Translation & through vector $\begin{pmatrix}6\\7\end{pmatrix}$
                    & $\begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}$
                    & $\begin{pmatrix}6\\7\end{pmatrix}$\\
        \hline
        Reflection  & in line $x=2$
                    & $\begin{pmatrix} -1 & 0 \\ 0 & 1 \end{pmatrix}$
                    & $\begin{pmatrix}4\\0\end{pmatrix}$\\
        \hline
        Rotation    & about $\mathbf{0}$ through $\pi$ radians
                    & $\begin{pmatrix} -1 & 0 \\ 0 & -1 \end{pmatrix}$
                    & $\begin{pmatrix}0\\0\end{pmatrix}$\\
        \hline
        Glide reflection & in line $y=x$, then through $\begin{pmatrix}1\\1\end{pmatrix}$
                    & $\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$
                    & $\begin{pmatrix}1\\1\end{pmatrix}$\\
        \hline
\end{tabular}
\caption{Examples of Euclidean Transformations}
\label{tab1}
\end{table}
\end{document} 

答案3

为了改善表格的整体外观,您可能还会对booktabs包装感兴趣。在这种情况下不需要垂直规则。正如您所观察到的,由于包装增加了额外的垂直空间,表格现在不那么糟糕了。

\documentclass{article}
\usepackage{amsmath,booktabs}
\begin{document}
\begin{table}[hbt]
\centering
    \begin{tabular}{*4{l}}
        \toprule
        & \multicolumn{3}{c}{Examples}\\
        \cmidrule{2-4}
        & description & $M$ & \textbf{u}\\
        \midrule translation & through vector $\begin{pmatrix}6\\7\end{pmatrix}$ & $\begin{pmatrix}
        1 & 0 \\ 0 & 1
        \end{pmatrix}$ & $\begin{pmatrix}6\\7\end{pmatrix}$\\
        \midrule reflection & in line $x=2$ & $\begin{pmatrix}
        -1 & 0 \\ 0 & 1
        \end{pmatrix}$ & $\begin{pmatrix}4\\0\end{pmatrix}$\\
        \midrule rotation & about \textbf{0} through $\pi$ radians & $\begin{pmatrix}
        -1 & 0 \\ 0 & -1
        \end{pmatrix}$ & $\begin{pmatrix}0\\0\end{pmatrix}$\\
        \midrule glide reflection & in line $y=x$, then through $\begin{pmatrix}1\\1\end{pmatrix}$ & $\begin{pmatrix}
        0 & 1 \\ 1 & 0
        \end{pmatrix}$ & $\begin{pmatrix}1\\1\end{pmatrix}$\\
        \bottomrule
        \end{tabular}
        \caption{Examples of Euclidean Transformations}
\label{tab1}
\end{table}
\end{document} 

在此处输入图片描述

可能更好的版本(通过删除内部的\midrules 并按照@Mico 的建议为行添加一个小的垂直高度\\[8pt]):

\begin{tabular}{*4{l}}
    \toprule
    & \multicolumn{3}{c}{Examples}\\
    \cmidrule{2-4}
    & description & $M$ &  $\mathbf{u}$\\
    \midrule translation & through vector $\begin{pmatrix}6\\7\end{pmatrix}$ & $\begin{pmatrix}
    1 & 0 \\ 0 & 1
    \end{pmatrix}$ & $\begin{pmatrix}6\\7\end{pmatrix}$\\[8pt]
    reflection & in line $x=2$ & $\begin{pmatrix}
    -1 & 0 \\ 0 & 1
    \end{pmatrix}$ & $\begin{pmatrix}4\\0\end{pmatrix}$\\[8pt]
    rotation & about \textbf{0} through $\pi$ radians & $\begin{pmatrix}
    -1 & 0 \\ 0 & -1
    \end{pmatrix}$ & $\begin{pmatrix}0\\0\end{pmatrix}$\\[8pt]
    glide reflection & in line $y=x$, then through $\begin{pmatrix}1\\1\end{pmatrix}$ & $\begin{pmatrix}
    0 & 1 \\ 1 & 0
    \end{pmatrix}$ & $\begin{pmatrix}1\\1\end{pmatrix}$\\
    \bottomrule
\end{tabular}

在此处输入图片描述

答案4

环境{NiceTabular}nicematrix一个计算“空角”的键corners。因此,你只需要写:

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table}[hbt]
\centering
\begin{NiceTabular}{llcc}[cell-space-limits=5pt,hvlines,corners]
& \Block{1-3}{Examples}\\
& Description & $M$ & \textbf{u}\\
Translation & through vector $\begin{pmatrix}6\\7\end{pmatrix}$ & $\begin{pmatrix}
    1 & 0 \\ 0 & 1
\end{pmatrix}$ & $\begin{pmatrix}6\\7\end{pmatrix}$\\
Reflection & in line $x=2$ & $\begin{pmatrix}
-1 & 0 \\ 0 & 1
\end{pmatrix}$ & $\begin{pmatrix}4\\0\end{pmatrix}$\\
Rotation & about \textbf{0} through $\pi$ radians & $\begin{pmatrix}
-1 & 0 \\ 0 & -1
\end{pmatrix}$ & $\begin{pmatrix}0\\0\end{pmatrix}$\\
Glide reflection & in line $y=x$, then through $\begin{pmatrix}1\\1\end{pmatrix}$ & $\begin{pmatrix}
0 & 1 \\ 1 & 0
\end{pmatrix}$ & $\begin{pmatrix}1\\1\end{pmatrix}$\\
\end{NiceTabular}
\caption{Examples of Euclidean Transformations} \label{tab1}
\end{table}

\end{document}

上述代码的输出

不过,我建议本着表格的精神booktabs(参见其他答案)。

相关内容