Latex表格:如何在多行单元格中删除水平线?

3

我对Latex非常陌生,正在尝试创建一个跨多行的表格。我要解决的问题是移除放置在跨行单元格上的水平线。这里链接了目前的情况截图:

1

我的代码如下。图片中用方框标出的区域表示跨行单元格有水平线覆盖。我尝试使用cline{}命令来移除水平线,但结果要么移除了不止一条线,要么根本没有移除任何线。我不认为我完全理解如何使用该命令。当未被注释时,我已将显示我所说内容的两个cline命令注释掉。

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage[margin=1in]{geometry}

\begin{document}
    \renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular}{c|c|c|c{3.5cm}}
        \hline
       \textbf{ Classification} & \textbf{Total Impulse} & \textbf{Total Impulse} & \textbf{Type/}\\
        & (Newton-Seconds) & (Pounds-Seconds) & \textbf{US Requirements}\\
        \hline
        %___________Micro____________
        1/8 A & 0—0.3125 \textbf{N·s} & 0 – 0.07 lbf·s & \multirow{1}{*}\textbf{Micro} \\%[.3cm]
        %\cline{3-4}
        %\cline{4-5}
        \hline
        %_________Low Power_________
        1/4 A & 0.3126 – 0.625 N·s & 0.071 – 0.14 lbf·s & \multirow{6}{*}{Low Power}\\
        \hline 
        1/2 A & 0.626 – 1.25 N·s & 0.141 – 0.28 lbf·s & \\
        \hline
        A & 0.626 – 1.25 N·s & 0.141 – 0.28 lbf·s & \\
        \hline
        B & 2.51 – 5.00 N·s & 0.561 – 1.12 lbf·s & \\
        \hline
        C & 5.01 – 10.0 N·s & 1.121 – 2.25 lbf·s & \\
        \hline 
        D & 10.01 – 20.0 N·s & 2.251 – 4.5 lbf·s & \\
        \hline
        %_______Mid Power__________
        E & 20.01 – 40.0 N·s & 4.51 – 8.99 lbf·s & \multirow{3}{*}{Mid Power}\\ 
        \hline
        F & 40.01 – 80.0 N·s & 8.991 – 18.0 lbf·s & \\
        \hline
        G & 80.01 – 160 N·s & 18.01 – 36.0 lbf·s & \\
        \hline
        %_____High Power | Level 1_________
        H & 160.01 – 320 N·s & 36.01 – 71.9 lbf·s & \multirow{2}{150}{\textbf{ High Power | Level 1} \newline 
        Level 1 Certification required for purchase. Certification available through Tripoli or NAR.
        Under 125g propellant is Federal Aviation Administration exempt.}\\
        \hline
        I & 320.01 – 640 N·s & 71.9 – 144 lbf·s & \\[2cm]
        \hline
        %____High Power | Level 2 _____
        J & 640.01 – 1,280 N·s & 144.01–288 lbf·s & \multirow{3}{150}{\textbf{ High Power | Level 2} \newline
        Level 2 Certification required for purchase. Certification available through Tripoli or NAR.}\\
        \hline
        K & 1,280.01 – 2,560 N·s & 288.01–576 lbf·s & \\
        \hline 
        L & 2,560.01 – 5,120 N·s & 576.01–1,151 lbf·s & \\[.2cm]
        \hline
        %_______High Power | Level 3________
        M & 5,120.01 – 10,240 N·s & 1,151.01–2,302 lbf·s & \multirow{3}{150}{\textbf{ High Power | Level 3}
        \newline
        Level 3 Certification required for purchase. Certification available through Tripoli or NAR.}\\
        \hline 
        N & 10,240.01 – 20,480 N·s & 2,302.01–4,604 lbf·s & \\
        \hline 
        O & 20,480.01 – 40,960 N·s & 4,604.01–9,208 lbf·s & \\[.2cm]
        \hline
 \end {tabular}

\end{document}
2个回答

2

看看新的tabularray包。这将为您提供更好的结果,整齐地分布行,并自动处理水平线:

\documentclass[12pt,a4paper]{article}

\usepackage[margin=1in]{geometry}

\usepackage{tabularray}

\begin{document}

\noindent
\begin{tblr}{
  colspec={ c c c X},
  vlines,
  hlines,
  vspan=even
}
    H & 160.01 – 320 N·s & 36.01 – 71.9 lbf·s & \SetCell[r=2]{} \textbf{High Power | Level 1} \newline Level 1 Certification required for purchase. Certification available through Tripoli or NAR.
    Under 125g propellant is Federal Aviation Administration exempt.\\
    I & 320.01 – 640 N·s & 71.9 – 144 lbf·s & \\
\end{tblr}

\end{document}

在此输入图片描述

(您可能需要查看 siunitx 包以获得数字和单位的适当间距...)


2
您可以通过用 \cline{1-3} 替换一些 \hline 来进行修复。更准确地说,当 multirow 跨越了 n 行时,在它之后必须进行 n-1 次此替换。
\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage[margin=1in]{geometry}

\begin{document}
\renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular}{c|c|c|c}
        \hline
       \textbf{ Classification} & \textbf{Total Impulse} & \textbf{Total Impulse} & \textbf{Type/}\\
        & (Newton-Seconds) & (Pounds-Seconds) & \textbf{US Requirements}\\
        \hline
        %___________Micro____________
        1/8 A & 0—0.3125 \textbf{N·s} & 0 – 0.07 lbf·s & \multirow{1}{*}\textbf{Micro} \\%[.3cm]
        %\cline{3-4}
        %\cline{4-5}
        \hline
        %_________Low Power_________
        1/4 A & 0.3126 – 0.625 N·s & 0.071 – 0.14 lbf·s & \multirow{6}{*}{Low Power}\\
        \cline{1-3}
        1/2 A & 0.626 – 1.25 N·s & 0.141 – 0.28 lbf·s & \\
        \cline{1-3}
        A & 0.626 – 1.25 N·s & 0.141 – 0.28 lbf·s & \\
        \cline{1-3}
        B & 2.51 – 5.00 N·s & 0.561 – 1.12 lbf·s & \\
        \cline{1-3}
        C & 5.01 – 10.0 N·s & 1.121 – 2.25 lbf·s & \\
        \cline{1-3}
        D & 10.01 – 20.0 N·s & 2.251 – 4.5 lbf·s & \\
        \hline
        %_______Mid Power__________
        E & 20.01 – 40.0 N·s & 4.51 – 8.99 lbf·s & \multirow{3}{*}{Mid Power}\\
        \cline{1-3}
        F & 40.01 – 80.0 N·s & 8.991 – 18.0 lbf·s & \\
        \cline{1-3}
        G & 80.01 – 160 N·s & 18.01 – 36.0 lbf·s & \\
        \hline
        %_____High Power | Level 1_________
        H & 160.01 – 320 N·s & 36.01 – 71.9 lbf·s & \multirow{2}{150px}{\textbf{ High Power | Level 1} \newline 
        Level 1 Certification required for purchase. Certification available through Tripoli or NAR. Under 125g propellant is Federal Aviation Administration exempt.}\\
        \cline{1-3}
        I & 320.01 – 640 N·s & 71.9 – 144 lbf·s & \\[2cm]
        \hline
        %____High Power | Level 2 _____
        J & 640.01 – 1,280 N·s & 144.01–288 lbf·s & \multirow{3}{150px}{\textbf{ High Power | Level 2} \newline
        Level 2 Certification required for purchase. Certification available through Tripoli or NAR.}\\
        \cline{1-3}
        K & 1,280.01 – 2,560 N·s & 288.01–576 lbf·s & \\
        \cline{1-3}
        L & 2,560.01 – 5,120 N·s & 576.01–1,151 lbf·s & \\[.2cm]
        \hline
        %_______High Power | Level 3________
        M & 5,120.01 – 10,240 N·s & 1,151.01–2,302 lbf·s & \multirow{3}{150px}{\textbf{ High Power | Level 3}
        \newline
        Level 3 Certification required for purchase. Certification available through Tripoli or NAR.}\\
        \cline{1-3}
        N & 10,240.01 – 20,480 N·s & 2,302.01–4,604 lbf·s & \\
        \cline{1-3}
        O & 20,480.01 – 40,960 N·s & 4,604.01–9,208 lbf·s & \\[.2cm]
        \hline
 \end {tabular}

\end{document}

输出:

screenshot of output

此外,使用此标题时,\begin{tabular}{c|c|c|c{3.5cm}}\multirow{3}{150}{} 会出现错误。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接