3

I have two tables side by side, in one minipage each. My question is, how to use \toprule and \bottomrule to span the entire width of the table environment (as opposed to spanning only the current tabular)? By "entire width" I don't mean literally having length equal to \textwidth, but to be smart about it like \toprule is.

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{table}
  % I want a \toprule (?) here (?) to (cleverly) span
  % the entire table environment.
  \begin{minipage}[t]{.5\textwidth}
    \begin{tabular}{c}
      \toprule            % This spans only this (leftmost) table.
      \\
      % Table Content.
      \\
      \bottomrule
    \end{tabular}
  \end{minipage}
  ~
  \begin{minipage}[t]{.5\textwidth}
    \begin{tabular}{c}
      \toprule            % This spans only this (rightmost) table.
      \\
      % Table Content.
      \\
      \bottomrule
    \end{tabular}
  \end{minipage}
\end{table}

\end{document}
4
  • 2
    As far as I remember tables can be nested, so instead of your minipages you could use a table with one row two cells, each of which is a table. Untested
    – daleif
    Commented Jul 4, 2017 at 16:20
  • 1
    I might try that, will let you know how it works.
    – dow
    Commented Jul 4, 2017 at 16:22
  • Be aware that @daleif terminology could be misleading: you cannot nest table environments (which produce a floating object and can therefore be used in “outer paragraph mode” only); what you can nest are tabular environments.
    – GuM
    Commented Jul 4, 2017 at 16:51
  • @GuM you are totally right, I meant tabular not table
    – daleif
    Commented Jul 4, 2017 at 16:51

1 Answer 1

2

Nest tables.

\documentclass{article}

\usepackage{booktabs,array}

\begin{document}

\begin{table}

\begin{tabular}{
  @{}
  p{\dimexpr.5\textwidth}
  @{}
  p{\dimexpr.5\textwidth}
  @{}
}
\toprule
\begin{tabular}{c}
\toprule
Table Content. \\
\bottomrule
\end{tabular}
&
\begin{tabular}{c}
\toprule
Table Content. \\
\bottomrule
\end{tabular}
\\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

2
  • It would be good to add some inline comments about what does the @{} part do.
    – dow
    Commented Jul 4, 2017 at 18:14
  • @dow It removes the intercolumn space
    – egreg
    Commented Jul 4, 2017 at 19:19

You must log in to answer this question.

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