# How to generate a table as below?

I try to generate a table like this using {longtable} and {supertabular} but failed. Anybody can help?

\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}

• Could you post what you tried? – Bernard Jan 29 '16 at 11:55
• Will it really be a long table (breaking across pages)? – Bernard Jan 29 '16 at 12:15
• The spacing seems a bit odd and i find the colour pretty distracting. – Johannes_B Jan 29 '16 at 12:42
• First step: hold your typographical nose – Brent.Longborough Jan 29 '16 at 18:09

An alternative using booktabs for the table rules, tabularx to get a table that fits the textwidth and siunitx to properly typeset the units.

\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}

• I took the liberty to add $\sim$ to your code. In your version, the tilde didn't show up... – Habi Jan 29 '16 at 13:25
• @habi oh, i completely overlooked those. Thanks :-) – Johannes_B Jan 29 '16 at 13:28
• Thanks a lot! What if I want to add a title below this table? Seems that \caption{} didn't work... – Vinnton Jan 29 '16 at 15:47
• @Vinnton Shure it does. You'll have to embed the tabularx inside a table environment, as so: gist.github.com/habi/f4ec705147dbb86e7275. As per this answer I place the captions above the tables. – Habi Jan 29 '16 at 16:17

If you absolutely want some colour, here are two solutions with swapping rows and columns. One with vertical and horizontal rules, the other with only horizontal rules (built not using booktabs, as this leads to white spaces in coloured cells). The latter looks better, in my opinion:

\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}


• It seems that in the first table you have twoSc| surplus. – Zarko Jan 29 '16 at 14:09
• @Zarko: Oh! yes. Thank you, I'll correct it at once. – Bernard Jan 29 '16 at 14:29
• Thanks a lot! What if I want to add a title below this table? Seems that \caption{} didn't work... – Vinnton Jan 29 '16 at 15:48
• For \caption you need to put table into table environment. Or, if you like to have table direct in text, than you should use \captionof {table}{ table title } and ad in preamble package caption or capt-of. – Zarko Jan 29 '16 at 16:25
• @Vinnton the question for a caption is a different one and should be posted as such. You wrote that question two times, here and under my answer. Two people reacted, one of them not knowing that the question is already answered. – Johannes_B Jan 29 '16 at 16:43