2

I have this long table with a lot of similar entries repeated.

example

I've tried to improve the visual result with some space between rows and grouping the common part of each entry. i.e. the first four observed variables should be:

  • Blue rods revolute position goalkeeper
  • Blue rods revolute position defence
  • Blue rods revolute position midfield
  • Blue rods revolute position attack

However, I'm not satisfied with the visual result. I would try with something similar to the cases environment (i.e. a big "{" between the first and the second column for each group) but I don't know how to do it with table rows.

Of course, if you have a suggestion on how to better compress the data or a suggestion on how to have a better visual effect that doesn't involve the big "{" you're welcome. However, note that the order how the row is important, so I cannot merge "blue rods" and "red rods".

This is the code I used to generate the example:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell} 

\begin{document}
\begin{table}[htbp]
  \centering
  \begin{tabular}{@{}*{2}{l}*{2}{c}@{}}
    \toprule
    \multicolumn{2}{c}{Observed variable} &
    \thead{Lowest \\ possible value} &
    \thead{Highest \\ possible value} \\
    \midrule
    \multirow{4}{*}{\makecell[l]{Blue rods: \\ revolute position}}
    & Goalkeeper &
    $-\pi$ & $\pi$ \\
    & Defense &
    $-\pi$ & $\pi$ \\
    & Midfield &
    $-\pi$ & $\pi$ \\
    & Attack &
    $-\pi$ & $\pi$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Blue rods: \\ prismatic position}}
    & Goalkeeper &
    $-0.9451e-1$ & $0.9451e-1$ \\
    & Defense &
    $-1.82e-1$ & $1.82e-1$ \\
    & Midfield &
    $-0.665e-1$ & $0.665e-1$ \\
    & Attack &
    $-1.11e-1$ & $1.11e-1$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Blue rods: \\ revolute velocity}}
    & Goalkeeper &
    $-\infty$ & $\infty$ \\
    & Defense &
    $-\infty$ & $\infty$ \\
    & Midfield &
    $-\infty$ & $\infty$ \\
    & Attack &
    $-\infty$ & $\infty$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Blue rods: \\ prismatic velocity}}
    & Goalkeeper &
    $-\infty$ & $\infty$ \\
    & Defense &
    $-\infty$ & $\infty$ \\
    & Midfield &
    $-\infty$ & $\infty$ \\
    & Attack &
    $-\infty$ & $\infty$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Red rods: \\ revolute position}}
    & Goalkeeper &
    $-\pi$ & $\pi$ \\
    & Defense &
    $-\pi$ & $\pi$ \\
    & Midfield &
    $-\pi$ & $\pi$ \\
    & Attack &
    $-\pi$ & $\pi$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Red rods: \\ prismatic position}}
    & Goalkeeper &
    $-0.9451e-1$ & $0.9451e-1$ \\
    & Defense &
    $-1.82e-1$ & $1.82e-1$ \\
    & Midfield &
    $-0.665e-1$ & $0.665e-1$ \\
    & Attack &
    $-1.11e-1$ & $1.11e-1$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Red rods: \\ revolute velocity}}
    & Goalkeeper &
    $-\infty$ & $\infty$ \\
    & Defense &
    $-\infty$ & $\infty$ \\
    & Midfield &
    $-\infty$ & $\infty$ \\
    & Attack &
    $-\infty$ & $\infty$ \\

    &&&\\

    \multirow{4}{*}{\makecell[l]{Red rods: \\ prismatic velocity}}
    & Goalkeeper &
    $-\infty$ & $\infty$ \\
    & Defense &
    $-\infty$ & $\infty$ \\
    & Midfield &
    $-\infty$ & $\infty$ \\
    & Attack &
    $-\infty$ & $\infty$ \\

    &&&\\

    \multirow{3}{*}{\makecell[l]{Ball: \\ position}}
    & x &
    $-5.75e-1$ & $5.75e-1$ \\
    & y &
    $-3.55e-1$ & $3.55e-1$ \\
    & z &
    $-\infty$ & $\infty$ \\
    \bottomrule
  \end{tabular}
  \caption{Observation space bounds}
\end{table}
\end{document}
  • I might remove those entries and make a new table, with a caption mentioning "For Goalkeeper, Defense, Midfield, and Attack". – Teepeemm Dec 5 '18 at 16:23
5

This is mainly stylistic, but the answer contains also some useful suggestions.

I'd avoid braces, as they add nothing to comprehension. The labels should be aligned to the top row, not in the center, where they're ambiguous. In a table, a blank position means repetition of the value above. This way, the small space between groups is sufficient to make clear what the label refers to.

I'd also divide the table into three sections, adding “Blue rods”, “Red rods” and “Ball” at the top of the sections, in a distinct font for emphasize them.

Using siunitx is essentially mandatory for numeric tables.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{siunitx}

\sisetup{output-exponent-marker=\ensuremath{\mathrm{e}}}

\begin{document}

\begin{table}[htbp]
  \centering\small
  \begin{tabular}{
    @{}
    l
    l
    S[table-format=-1.4e1]
    S[table-format=1.4e1]
    @{}c@{}
  }
    \toprule
    \multicolumn{2}{@{}c}{Observed variable} & \multicolumn{2}{c@{}}{Possible value} \\
    \cmidrule(l){3-4}
    && {Lowest} & {Highest} \\

    \midrule
    \multicolumn{4}{@{}l@{}}{\itshape Blue rods} \\

    revolute position
    & Goalkeeper &
    {$-\pi$} & {$\pi$} \\
    & Defense &
    {$-\pi$} & {$\pi$} \\
    & Midfield &
    {$-\pi$} & {$\pi$} \\
    & Attack &
    {$-\pi$} & {$\pi$} \\

    \addlinespace

    prismatic position
    & Goalkeeper &
    -0.9451e-1 & 0.9451e-1 \\
    & Defense &
    -1.82e-1 & 1.82e-1 \\
    & Midfield &
    -0.665e-1 & 0.665e-1 \\
    & Attack &
    -1.11e-1 & 1.11e-1 \\

    \addlinespace

    revolute velocity
    & Goalkeeper &
    {$-\infty$} & {$\infty$} \\
    & Defense &
    {$-\infty$} & {$\infty$} \\
    & Midfield &
    {$-\infty$} & {$\infty$} \\
    & Attack &
    {$-\infty$} & {$\infty$} \\

    \addlinespace

    prismatic velocity
    & Goalkeeper &
    {$-\infty$} & {$\infty$} \\
    & Defense &
    {$-\infty$} & {$\infty$} \\
    & Midfield &
    {$-\infty$} & {$\infty$} \\
    & Attack &
    {$-\infty$} & {$\infty$} \\

    \midrule
    \multicolumn{4}{@{}l@{}}{\itshape Red rods} \\

    revolute position
    & Goalkeeper &
    {$-\pi$} & {$\pi$} \\
    & Defense &
    {$-\pi$} & {$\pi$} \\
    & Midfield &
    {$-\pi$} & {$\pi$} \\
    & Attack &
    {$-\pi$} & {$\pi$} \\

    \addlinespace

    prismatic position
    & Goalkeeper &
    -0.9451e-1 & 0.9451e-1 \\
    & Defense &
    -1.82e-1 & 1.82e-1 \\
    & Midfield &
    -0.665e-1 & 0.665e-1 \\
    & Attack &
    -1.11e-1 & 1.11e-1 \\

    \addlinespace

    revolute velocity
    & Goalkeeper &
    {$-\infty$} & {$\infty$} \\
    & Defense &
    {$-\infty$} & {$\infty$} \\
    & Midfield &
    {$-\infty$} & {$\infty$} \\
    & Attack &
    {$-\infty$} & {$\infty$} \\

    \addlinespace

    prismatic velocity
    & Goalkeeper &
    {$-\infty$} & {$\infty$} \\
    & Defense &
    {$-\infty$} & {$\infty$} \\
    & Midfield &
    {$-\infty$} & {$\infty$} \\
    & Attack &
    {$-\infty$} & {$\infty$} \\

    \midrule
    \multicolumn{4}{@{}l@{}}{\itshape Ball} \\

    position
    & x &
    -5.75e-1 & 5.75e-1 \\
    & y &
    -3.55e-1 & 3.55e-1 \\
    & z &
    {$-\infty$} & {$\infty$} \\
    \bottomrule
  \end{tabular}
  \caption{Observation space bounds}
\end{table}
\end{document}

enter image description here

  • I know that a better approach was possible. Your solution is better than what I was looking for. – gvgramazio Dec 5 '18 at 17:57
3

edited corrected errors in column headers and renew definition for command case

like this?

enter image description here

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, multirow, makecell}
\renewcommand\theadgape{}
\usepackage{amsmath}
\newcommand{\case}[1]%
{$\displaystyle
\text{\makecell[l]{#1}}\quad
\left\{\begin{tabular}{l}
            Goalkeeper  \\
            Defense     \\
            Midfield    \\
            Attack 
        \end{tabular}\right.
$}

\begin{document}
    \begin{table}[htbp]
    \centering
\begin{tabular}{ @{} l *{2}{>{$} c < {$} } @{}  }
    \toprule
\thead{Observed variable}
    &   \text{\thead{Lowest \\ possible value}}
        &   \text{\thead{Highest \\ possible value}} \\
        \midrule

\case{Blue rods: \\ prismatic position}
    &   \makecell{-\pi    \\
                  -\pi    \\
                  -\pi    \\
                  -\pi}
    &   \makecell{-\pi    \\
                  -\pi    \\
                  -\pi    \\
                  -\pi}       \\
   \addlinespace
\case{Blue rods: \\ prismatic position}
    &   \makecell[r]{-0.9451e-1 \\
                  -1.82e-1      \\
                  -0.665e-1     \\
                  -1.11e-1}
    &   \makecell[r]{0.9451e-1  \\
                  1.82e-1       \\
                  0.665e-1      \\
                  1.11e-1}      \\
   \addlinespace
\case{Red rods: \\ prismatic  velocity}
    &   \makecell{-\infty       \\
                  -\infty       \\
                  -\infty       \\
                  -\infty}
    &   \makecell{\infty        \\
                  \infty        \\
                  \infty        \\
                  \infty}       \\
     \bottomrule
    \end{tabular}
\caption{Observation space bounds}
    \label{tab:...}
\end{table}
\end{document}
  • This is what I've already tried. I discarded this solution because it doesn't use table rows. The consequence is that the vertical space between values is different from the one between cases. Of course, it could be hard-coded, but I'm against solutions that require high maintenance. – gvgramazio Dec 5 '18 at 17:55
  • @gvgramazio, see corrected answer. now (as i see) are removed small discrepancy in vertical aligning of rows. however, contents in cells in last two columns should not bi higher than in the first column. – Zarko Dec 5 '18 at 19:03
1

A solution with a simpler code, based on bigdelim:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow, bigdelim}
\usepackage{makecell}
\newcommand{\e}[1]{\,\mathrm{e}{#1}}

\begin{document}

\begin{table}[htbp]
  \centering
\renewcommand{\theadfont}{\normalsize}
  \begin{tabular}{@{}l@{ \,}cl*{2}{c}@{}}
    \toprule
    \multicolumn{3}{c}{Observed variable} &
    \thead{Lowest \\ possible value} &
    \thead{Highest \\ possible value} \\
    \midrule
\addlinespace[1.5ex]
   & \ldelim\{{4}{0pt} & Goalkeeper &
    $-\pi$ & $\pi$ \\
Blue rods: & & Defense &
     $-\pi$ & $\pi$ \\
revolute position & & Midfield &
    $-\pi$ & $\pi$ \\
    & & Attack &
    $-\pi$ & $\pi$ \\
\addlinespace[2ex]
  & \ldelim\{{4}{0pt} & Goalkeeper &
 $-0.9451\e{-1}$ & $ 0.9451\e{-1}$ \\
Blue rods: & & Defense &
 $-1.82\e{-1}$ & $1.82\e{-1}$ \\
prismatic position & & Midfield &
 $-0.665\e{-1}$ & $0.665\e{-1}$ \\
 & & Attack &
 $-1.11\e{-1}$ & $1.11\e{-1}$ \\
\addlinespace[2ex]
 \multirow{4}{*}{\makecell[l]{Blue rods: \\ revolute velocity}}
 & \ldelim\{{4}{0pt} & Goalkeeper &
 $-\infty$ & $\infty$ \\
Blue rods: & & Defense &
 $-\infty$ & $\infty$ \\
revolute velocity & & Midfield &
 $-\infty$ & $\infty$ \\
  & & Attack &
 $-\infty$ & $\infty$ \\
\addlinespace[2ex]
  & \ldelim\{{4}{0pt} & Goalkeeper &
 $-\infty$ & $\infty$ \\
Blue rods: & & Defense &
 $-\infty$ & $\infty$ \\
prismatic velocity & & Midfield &
 $-\infty$ & $\infty$ \\
  & & Attack &
 $-\infty$ & $\infty$ \\
\addlinespace[2ex]
  & \ldelim\{{4}{0pt} & Goalkeeper &
 $-\pi$ & $\pi$ \\
Red rods: & & Defense &
 $-\pi$ & $\pi$ \\
revolute position & & Midfield &
 $-\pi$ & $\pi$ \\
 & & Attack &
 $-\pi$ & $\pi$ \\
\addlinespace[2ex]
  & \ldelim\{{4}{0pt} & Goalkeeper &
 $-0.9451\e{-1}$ & $0.9451\e{-1}$ \\
Red rods: & & Defense &
 $-1.82\e{-1}$ & $1.82\e{-1}$ \\
 prismatic position & & Midfield &
 $-0.665\e{-1}$ & $0.665\e{-1}$ \\
  & & Attack &
 $-1.11\e{-1}$ & $1.11\e{-1}$ \\
\addlinespace[2ex]
 & \ldelim\{{4}{0pt} & Goalkeeper &
 $-\infty$ & $\infty$ \\
Red rods: & & Defense &
 $-\infty$ & $\infty$ \\
revolute velocity & & Midfield &
 $-\infty$ & $\infty$ \\
  & & Attack &
 $-\infty$ & $\infty$ \\
\addlinespace[2ex]
 & \ldelim\{{4}{0pt} & Goalkeeper &
 $-\infty$ & $\infty$ \\
Red rods: & & Defense &
 $-\infty$ & $\infty$ \\
 prismatic velocity & & Midfield &
 $-\infty$ & $\infty$ \\
 & & Attack &
 $-\infty$ & $\infty$ \\
\addlinespace[2ex]
 \multirow{3}{*}{\makecell[l]{Ball: \\ position}}
 & \ldelim\{{3}{0pt} & x &
 $-5.75\e{-1}$ & $5.75\e{-1}$ \\
 & & y &
 $-3.55\e{-1}$ & $3.55\e{-1}$ \\
 & & z &
 $-\infty$ & $\infty$ \\
\addlinespace[1ex]
    \bottomrule
  \end{tabular}
  \caption{Observation space bounds}
\end{table}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.