2

I built the following table through the help of this webtool but I'm not satisfied about the vertical spacing between the rows. Can you show how to improve it and reduce a little bit the size of the table? Is convenient to use the multirow command? If yes, how to implement it?

\documentclass{article}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{csvsimple}
\usepackage{graphicx}

\sisetup{
    round-mode=places,
    uncertainty-mode = separate,
}

\begin{document}

\begin{table}[ht]
\centering
\caption{Summary of the \glspl{acronym:NEO} classification \cite{web:CNEOS:NEO:Basics:NEO:Groups}.}
\label{tab:NEOs:classification}
\begin{tabular}{@{}lll@{}}
\toprule
\multicolumn{1}{l}{\textbf{Group}} & \textbf{Definition} & \textbf{Description} \\ \midrule
NECs & \begin{tabular}[c]{@{}l@{}}$q \leq \SI{1.3}{\astronomicalunit}$ \\  $P  < \SI{200}{\years}$\end{tabular} & Near-Earth Comets \\[0.35cm]
NEAs & $q \leq \SI{1.3}{au}$ & Near-Earth Asteroids \\[0.35cm] 
Atiras & \begin{tabular}[c]{@{}l@{}}$a< \SI{1.0}{\astronomicalunit}$\\ $Q \leq \SI{0.983}{\astronomicalunit}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}\glspl{acronym:NEA} whose orbits are contained entirely with the\\ orbit of the Earth (named after asteroid 163693 Atira).\end{tabular} \\[0.35cm] 
Atens & \begin{tabular}[c]{@{}l@{}}$a< \SI{1.0}{\astronomicalunit}$\\ $Q > \SI{0.983}{\astronomicalunit} $\end{tabular} & \begin{tabular}[c]{@{}l@{}}Earth-crossing \glspl{acronym:NEA} with semi-major axes \\ smaller than Earth's (named after asteroid 2062 Aten).\end{tabular} \\[0.35cm]  
Apollos & \begin{tabular}[c]{@{}l@{}}$a> \SI{1.0}{\astronomicalunit}$\\ $q< \SI{1.017}{\astronomicalunit}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}Earth-crossing \glspl{acronym:NEA} with semi-major axes larger \\ than Earth's (named after asteroid 1862 Apollo).\end{tabular} \\[0.35cm]  
Amors & \begin{tabular}[c]{@{}l@{}}$a> \SI{1.0}{\astronomicalunit}$\\ $ 1.017 < q < 1.3 \SI{}{\astronomicalunit} $\end{tabular} & \begin{tabular}[c]{@{}l@{}}Earth-approaching \glspl{acronym:NEA} with orbits exterior to \\ Earth's but interior to Mars' (named after asteroid 1221 Amor).\end{tabular} \\[0.35cm] 
PHAs & \begin{tabular}[c]{@{}l@{}}$MOID \leq \SI{0.05}{\astronomicalunit}$\\ $H \leq \num{22.0}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}Potentially Hazardous Asteroids: \glspl{acronym:NEA} whose \\ \gls{acronym:MOID} with \\ the Earth is 0.05 au or less and whose absolute \\ magnitude ($H$) is 22.0 or brighter.\end{tabular} \\ \bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

1
  • You can adjust the row spacing using \arraystretch (macro scale factor), but it will have no effect in the outer tabular for values <2. I would use an m or M column (see array and tabularx manuals) for the third column. Commented Nov 27, 2022 at 17:34

3 Answers 3

4

There's no need for multirow.

I would define the last column as paragraph-like and let latex decide on line breaks. For example, I applied m{<len>} with the fixed length and a left-alignment because your example is vertically centred.

I think it's better to use arraystretch to change the spacing between rows. The disadvantage is it becomes asymmetrical when factors are larger and needs adjustments. In this case, only the first row requires an extra strut (via \rule...).

I also created a convenient macro to add multiple lines with arraystretch defined as 1, so the internal row spacing remains default--of course, this is subject to change.

Here's the table

enter image description here

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{ragged2e}
% \usepackage{csvsimple}
% \usepackage{graphicx}

\sisetup{
    round-mode=places,
    uncertainty-mode = separate,
}
\DeclareSIUnit\years{Y}    % \years is not defined 
\newcommand\glspl[1]{#1}   % Here: error compiling the code, hence this macro
\newcommand\gls[1]{#1}     % Here: error compiling the code, hence this macro
\NewDocumentCommand\TB{O{l}m}{%
    \renewcommand\arraystretch{1}
    \begin{tabular}{@{}#1@{}}#2\end{tabular}}


\begin{document}
\begin{table}[ht]
    \renewcommand\arraystretch{1.85}
    \centering
    \caption{Summary of the \protect\glspl{acronym:NEO} classification \cite{web:CNEOS:NEO:Basics:NEO:Groups}.}
    \label{tab:NEOs:classification}
    \begin{tabular}{@{}ll >{\RaggedRight}m{8cm}@{}}
        \toprule
        \rule[-0.7\normalbaselineskip]{0pt}{1.8\normalbaselineskip}%
        \textbf{Group}
        & \textbf{Definition}
        & \textbf{Description}\\
        \midrule
        NECs
        & \TB{
            $q\leq \qty{1.3}{\astronomicalunit}$\\
            $P < \qty{200}{\years}$
        }
        & Near-Earth Comets \\
        NEAs
        & $q \leq \qty{1.3}{au}$
        & Near-Earth Asteroids \\
        Atiras
        & \TB{
            $a< \qty{1.0}{\astronomicalunit}$\\
            $Q \leq \qty{0.983}{\astronomicalunit}$
        }
        & \glspl{acronym:NEA} whose orbits are contained entirely with the orbit of the Earth (named after asteroid 163693 Atira). \\
        Atens
        & \TB{
            $a< \qty{1.0}{\astronomicalunit}$\\
            $Q > \qty{0.983}{\astronomicalunit} $
        } 
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes smaller than Earth's (named after asteroid 2062 Aten). \\
        Apollos
        & \TB{
            $a> \qty{1.0}{\astronomicalunit}$\\
            $q< \qty{1.017}{\astronomicalunit}$
        }
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes larger than Earth's (named after asteroid 1862 Apollo). \\ 
        Amors
        & \TB{
            $a> \qty{1.0}{\astronomicalunit}$\\
            $1.017 < q < 1.3 \qty{}{\astronomicalunit}$}
        & Earth-approaching \glspl{acronym:NEA} with orbits exterior to Earth's but interior to Mars' (named after asteroid 1221 Amor). \\
        PHAs
        & \TB{%
            $MOID \leq \qty{0.05}{\astronomicalunit}$\\
            $H \leq \num{22.0}$
        }
        & Potentially Hazardous Asteroids: \glspl{acronym:NEA} whose \gls{acronym:MOID} with the Earth is 0.05 au or less and whose absolute magnitude ($H$) is 22.0 or brighter. \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document}

Another solution is tabularx with X-column-type to avoid having to search for the accurate column width. By default, tabularx defines X as p{} but in the table above it may not work. The macro: tabularxcolumn is provided to redefine X, e.g.

\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}m{#1}}
2
  • Since I use a complex modular overleaf project with many .tex files, can you show how to "embed" the preamble inside the table environment?
    – g_don
    Commented Nov 27, 2022 at 23:30
  • 1
    @Giuseppe It's ok to move the whole blocks of \newcommand, \NewDocumentCommand, or \DeclareSIUnit inside an environment, e.g. table in a separate file. You will just make them locally visible only within this environment. Other tables can't use those macros unless you repeat the definitions. It's important the definitions are placed before the first use!
    – Celdor
    Commented Nov 28, 2022 at 0:15
1

I would use \tblr of tabularray package and redefine \TB style:

\documentclass{article}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\sisetup{
    round-mode=places,
    uncertainty-mode = separate,
}
\DeclareSIUnit\years{Y}    % \years is not defined
\newcommand\glspl[1]{#1}   % Here: error compiling the code, hence this macro
\newcommand\gls[1]{#1}     % Here: error compiling the code, hence this macro
\NewDocumentCommand\TB{m}{\begin{array}{@{}l @{}}#1\end{array}}

\begin{document}
    \begin{table}[ht]
    \centering
\caption{Summary of the \protect\glspl{acronym:NEO} classification \cite{web:CNEOS:NEO:Basics:NEO:Groups}.}
\label{tab:NEOs:classification}
    \begin{tblr}{colspec={@{} l Q[l, mode=math] X[l,m] @{}},
                 row{1} ={font=\bfseries, mode=text}
                 }
        \toprule
Group   &   Definition  
            & Description                           \\
        \midrule
NECs    & \TB{q\leq \qty{1.3}{au}\\
              P < \qty{200}{\years}}
            & Near-Earth Comets                     \\
NEAs    &   q \leq \qty{1.3}{au} 
            & Near-Earth Asteroids                  \\
Atiras  & \TB{a <    \qty{1.0}{au}   \\
              Q \leq \qty{0.983}{au}}
            & \glspl{acronym:NEA} whose orbits are contained entirely with the orbit of the Earth (named after asteroid 163693 Atira).                          \\
Atens   & \TB{a < \qty{1.0}{\astronomicalunit}  \\
              Q > \qty{0.983}{\astronomicalunit}}
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes smaller than Earth's 
        (named after asteroid 2062 Aten).           \\
Apollos & \TB{a> \qty{1.0}{\astronomicalunit}   \\
              q< \qty{1.017}{\astronomicalunit}}
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes larger than Earth's 
        (named after asteroid 1862 Apollo).         \\
Amors   & \TB{a> \qty{1.0}{\astronomicalunit}   \\
              1.017 < q < 1.3 \qty{}{\astronomicalunit}}
        & Earth-approaching \glspl{acronym:NEA} with orbits exterior to Earth's but interior to Mars' (named after asteroid 1221 Amor). \\
PHAs    & \TB{MOID \leq \qty{0.05}{\astronomicalunit} \\
              H \leq \num{22.0}}
        & Potentially Hazardous Asteroids: \glspl{acronym:NEA} whose \gls{acronym:MOID} with the Earth is 0.05 au or less and whose absolute magnitude ($H$) is 22.0 or brighter. \\
    \bottomrule
    \end{tblr}
    \end{table}
\end{document}

enter image description here

0

The code \\[0.35cm] at the end of each line gives a newline with a spacing of 3,5 mm. You can just reduce that number - or even remove the whole brackets. :)

1
  • 1
    I noticed that the command \\[0.35cm] does not produce an equal spacing among all the rows (Compare the first two rows with the others). Hence I would want a way to set spacing with a single command, without giving a command for each row.
    – g_don
    Commented Nov 27, 2022 at 19:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .