如何生成如下的表格?

如何生成如下的表格?

我尝试使用 {longtable} 和 {supertabular} 生成这样的表格,但失败了。有人可以帮忙吗?

\documentclass{article} 
\begin{document}     
\begin{supertabular}{|c|c|c|c|c|}
        \hline 
        Size & Lethal to & Number  & Trackable & Produces Lethal Fragments  \\
        & Operational & in& &When Impacting An  \\
        & Spacecraft &Orbit & & Operational Spacecraft \\
        \hline
        Small & (Usually) Not & Millions & No & No\\
        (<1cm) && &  & \\\hline
        Medium  & Usually & ~500,000  & No & Maybe\\
        (1cm - 10cm)&  & in LEO &  & \\\hline
        Large & (Almost) Always & ~22,000 & Yes & Yes - 100s to 10,000s\\
        (>10cm)&& && \\\hline
\end{supertabular}
\end{document}

答案1

另一种使用booktabs表格规则的方法tabularx是获取适合文本宽度的表格并siunitx正确排版单位。

vinnton太空船表格

\documentclass{article} 
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{booktabs}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}     
\noindent
\begin{tabularx}{\textwidth}{XC{.18\linewidth}XXC{.3\linewidth}}
    \toprule
    Size & Lethal to Operational  Spacecraft & Number in Orbit & Trackable & Produces Lethal Fragments When Impacting An  Operational Spacecraft \\
    \midrule
    Small (\SI{<1}{\centi\meter})           & (Usually) Not     & Millions             & No   & No\\\addlinespace
    Medium (\SIrange{1}{10}{\centi\meter})  & Usually           & $\sim$500,000 in LEO & No & Maybe\\\addlinespace
    Large (\SI{>10}{\centi\meter})          & (Almost) Always   & $\sim$22,000       & Yes  & Yes -- 100s to 10,000s\\
    \bottomrule
\end{tabularx}
\end{document}

答案2

如果你确实想要一些颜色,这里有两个交换行和列的解决方案。一个有垂直和水平规则,另一个只有水平规则(内置不是使用booktabs,因为这会导致彩色单元格中出现空白)。我认为后者看起来更好:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{array, supertabular, makecell, hhline, cellspace, booktabs}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage[table, x11names]{xcolor}
\usepackage{eqparbox}
\newcommand\blankcell{\multicolumn{1}{c|}{\cellcolor{white}}}
\begin{document}

\centering
\begin{supertabular}{| >{\columncolor{Burlywood1!80}}Sl|*{3}{Sc|}}
        \cline{2-4}
\blankcell & \multicolumn{3}{Sc|}{Size}\\
 \hhline{~|---|}
\rowcolor{DarkSeaGreen3}\blankcell & Small (<\,1cm) & Medium (1cm--10cm) & Large (>\,10cm) \\
        \hline
      \eqparbox{C1}{Lethal to\\ Operational Spacecraft} & (Usually) Not & Usually & (Almost) Always \\
        \hline
        Number in Orbit & Millions & \makecell{\textasciitilde\,500,000\\ in LEO} & \textasciitilde\,22,000 \\
        \hline
   Trackable & No & No & Yes\\
        \hline
        \eqparbox{C1}{ Produces Lethal Fragments \\When Impacting an\\ Operational Spacecraft} & No & Maybe & Yes -- 100\,s to 10,000\,s \\
        \hline
\end{supertabular}

\vskip1cm
\begin{supertabular}{ >{\columncolor{Burlywood1!80}}Sl*{3}{Sc}}
\cellcolor{white}& \multicolumn{3}{Sc}{Size}\\
 \hhline{~---}
\rowcolor{DarkSeaGreen3}\cellcolor{white} & Small (<\,1cm) & Medium (1cm – 10cm) & Large (>\,10cm) \\
        \Xhline{0.8pt}
      \eqparbox{C1}{Lethal to\\ Operational Spacecraft} & (Usually) Not & Usually & (Almost) Always \\
        \hline
        Number in Orbit & Millions & \makecell{\textasciitilde\,500,000\\ in LEO} & \textasciitilde\,22,000 \\
        \hline
   Trackable & No & No & Yes\\
        \hline
        \eqparbox{C1}{ Produces Lethal Fragments \\When Impacting an\\ Operational Spacecraft} & No & Maybe & Yes -- 100\,s to 10,000\,s \\
        \Xhline{0.8pt}
\end{supertabular}

\end{document} 

在此处输入图片描述

相关内容