不需要的行分割多列

不需要的行分割多列

当我编译以下代码时,我发现在 ax、bx、cx 和 dx 下的通用寄存器的多列中出现了一行奇怪的行。

\documentclass[11pt,a5paper,footinclude=true,headinclude=true]{scrbook} % KOMA-Script book
\usepackage[T2A]{fontenc}                
\usepackage{multirow}

\begin{document}

\begin{center}
    \begin{tabular}{|c|c|c|c|}
        \hline
        Type & \multicolumn{2}{c|}{Register} & Purpose \\\hline\hline
        \multirow{16}{*}{General Purpose} & \multirow{2}{*}{ax} & ah & \multirow{2}{*}{Arithmetic} \\
                                        \cline{3-3}
                                        & & al & \\
                                        \cline{2-4}
                                        & \multirow{2}{*}{bx} & bh & \multirow{2}{*}{Base} \\
                                        \cline{3-3}
                                        & & bl & \\
                                        \cline{2-4}
                                        & \multirow{2}{*}{cx} & ch & \multirow{2}{*}{Counter} \\
                                        \cline{3-3}
                                        & & cl & \\
                                        \cline{2-4}
                                        & \multirow{2}{*}{dx} & dh & \multirow{2}{*}{Data} \\
                                        \cline{3-3}
                                        & & dl & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{sp}} & \multirow{2}{*}{Stack Pointer} \\
                                        & & & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{bp}} & \multirow{2}{*}{Base Pointer} \\
                                        & & & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{si}} & \multirow{2}{*}{Source Index} \\
                                        & & & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{di}} & \multirow{2}{*}{Destination Index} \\
                                        & & & \\
        \hline
        \multirow{6}{*}{Segment}        & \multicolumn{2}{c|}{ss} & Stack Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{cs} & Code Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{ds} & Data Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{es} & Extra Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{fs} & Extra Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{gs} & Extra Segment \\
        \hline
    \end{tabular}
\end{center}

\end{document}

奇怪的线条

我在多列/行中做错了什么吗

答案1

下面两列sp应该di替换为:

\multicolumn{2}{c|}{}

去掉垂直线。

完整示例:

\documentclass[11pt,a5paper,footinclude=true,headinclude=true]{scrbook} % KOMA-Script book
\usepackage{multirow}

\begin{document}

\begin{center}
    \begin{tabular}{|c|c|c|c|}
        \hline
        Type & \multicolumn{2}{c|}{Register} & Purpose \\\hline\hline
        \multirow{16}{*}{General Purpose} & \multirow{2}{*}{ax} & ah & \multirow{2}{*}{Arithmetic} \\
                                        \cline{3-3}
                                        & & al & \\
                                        \cline{2-4}
                                        & \multirow{2}{*}{bx} & bh & \multirow{2}{*}{Base} \\
                                        \cline{3-3}
                                        & & bl & \\
                                        \cline{2-4}
                                        & \multirow{2}{*}{cx} & ch & \multirow{2}{*}{Counter} \\
                                        \cline{3-3}
                                        & & cl & \\
                                        \cline{2-4}
                                        & \multirow{2}{*}{dx} & dh & \multirow{2}{*}{Data} \\
                                        \cline{3-3}
                                        & & dl & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{sp}} & \multirow{2}{*}{Stack Pointer} \\
                                        & \multicolumn{2}{c|}{} & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{bp}} & \multirow{2}{*}{Base Pointer} \\
                                        & \multicolumn{2}{c|}{} & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{si}} & \multirow{2}{*}{Source Index} \\
                                        & \multicolumn{2}{c|}{} & \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{\multirow{2}{*}{di}} & \multirow{2}{*}{Destination Index} \\
                                        & \multicolumn{2}{c|}{} & \\
        \hline
        \multirow{6}{*}{Segment}        & \multicolumn{2}{c|}{ss} & Stack Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{cs} & Code Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{ds} & Data Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{es} & Extra Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{fs} & Extra Segment \\
                                        \cline{2-4}
                                        & \multicolumn{2}{c|}{gs} & Extra Segment \\
        \hline
    \end{tabular}
\end{center}

\end{document}

结果

还有一个没有垂直线和较少水平线的版本,带有包装规则booktabs

\documentclass{article}
\usepackage{booktabs}
\begin{document}
  \begin{center}
    \begin{tabular}{llll}
      \toprule
      Type & \multicolumn{2}{l}{Register} & Purpose \\
      \midrule
      General Purpose & ax & ah & Arithmetic \\
      & & al & \\
      \addlinespace % \cmidrule{2-4}
      & bx & bh & Base \\
      &  & bl & \\
      \addlinespace
      & cx & ch & Counter \\
      & & cl & \\
      \addlinespace
      & dx & dh & Data \\
      & & dl & \\
      \cmidrule{2-4}
      & \multicolumn{2}{l}{sp} & Stack Pointer \\
      & \multicolumn{2}{l}{bp} & Base Pointer \\
      & \multicolumn{2}{l}{si} & Source Index \\
      & \multicolumn{2}{l}{di} & Destination Index \\
      \midrule
      Segment & \multicolumn{2}{l}{ss} & Stack Segment \\
      & \multicolumn{2}{l}{cs} & Code Segment \\
      & \multicolumn{2}{l}{ds} & Data Segment \\
      & \multicolumn{2}{l}{es} & Extra Segment \\
      & \multicolumn{2}{l}{fs} & Extra Segment \\
      & \multicolumn{2}{l}{gs} & Extra Segment \\
      \bottomrule
    \end{tabular}
  \end{center}
\end{document}

结果

相关内容