You can't use \toprule
outside of a tabular
environment.
Here's a way to get your table without \subfloat
, which is not useful here. I simply set the two tables inside an "overall" table for the purpose of \toprule
and \bottomrule
; setting explicit widths is time consuming because the width have to be computed in order not to get overfull boxes; I think that it's better letting TeX doing the work.
The two inner tables are set with the [t]
option to get them aligned at their tops.
\documentclass[a4paper,oneside,titlepage,draft]{scrbook}
\usepackage[T1]{fontenc} %Silbentrennung
\usepackage[utf8]{inputenc} % Umlaute
\usepackage[ngerman]{babel}
\usepackage{booktabs}
\usepackage{tabularx}
\newcommand{\mW}[2]{$\overline{#1}=#2$}
\newenvironment{mytable}[1][htb]
{\begin{table}[#1]\small}
{\end{table}}
\begin{document}
\begin{mytable}
\centering
\caption{Worms}
\begin{tabular}{@{}c@{}}% an "outside" table
\toprule
\begin{tabular}[t]{lrrrr}
Klasse & Zeit & y & x & Bez. \\
\midrule
0,0 - 2,1 & a, 16:45 & 0,0 & 1,0 & H1 \\
\mW{x}{1,1} & a, 16:56 & 5,0 & 0,5 & H2 \\
& a, 17:15 & 10,0 & 1,0 & H3 \\
& a, 17:37 & 15,0 & 2,1 & H4 \\
& b, 12:40 & 37,4 & 1,0 & H7 \\
\midrule
5,0 - 6,0 & a, 16:20 & 0,0 & 5,0 & I1 \\
\mW{x}{5,2} & a, 16:58 & 5,0 & 5,0 & I2 \\
& a, 17:19 & 10,0 & 6,0 & I3 \\
& b, 12:39 & 37,4 & 5,0 & I7 \\
\midrule
10,0 - 12,1 & a, 16:30 & 0,0 & 10,0 & J1 \\
\mW{x}{10,4}& a, 17:00 & 5,0 & 10,0 & J2 \\
& b, 12:44 & 31,0 & 10,0 & J6 \\
& b, 12:38 & 37,4 & 10,0 & J7 \\
\end{tabular}% <- REMOVE THIS % IF YOU WANT A SMALL SEPARATION BETWEEN THE TABLES
\begin{tabular}[t]{lrrrr}
Klasse & Zeitpunkt & y & x & Bez. \\
\midrule
15,0 - 17,1 & a, 16:32 & 0,0 & 15,0 & K1 \\
\mW{x}{15,7}& a, 17:04 & 5,0 & 15,0 & K2 \\
& a, 17:25 & 10,0 & 16,0 & K3 \\
& a, 17:49 & 15,0 & 17,1 & J4 \\
& b, 12:36 & 37,4 & 15,0 & K7 \\
& b, 08:24 & 37,4 & 16,5 & M7 \\
& b, 12:50 & 37,4 & 16,5 & M7 \\
\midrule
18,6 - 20,6 & a, 16:38 & 0,0 & 20,0 & L1 \\
\mW{x}{19,7}& b, 06:13 & 5,0 & 18,6 & M2 \\
& b, 11:05 & 5,0 & 18,6 & M2 \\
& a, 17:07 & 5,0 & 19,0 & L2 \\
& b, 06:17 & 7,5 & 20,2 & M3 \\
& b, 06:21 & 15,0 & 20,6 & M4 \\
& b, 06:25 & 23,1 & 20,3 & M5 \\
& b, 06:30 & 31,0 & 19,7 & M6 \\
\end{tabular}\\% end the "outside" table line
\bottomrule
\end{tabular}
\end{mytable}
\end{document}
Best Answer
The answer is: yes, it is possible.
Under the assumption that your .tex files each consists in some code of the form
\begin{table}\begin{tabular}{...} ... \end{tabular}\end{table}
, you cantable
environment to do nothing, andsubtable
environment; such an environment usesminipage
internally, which means you don't have to useminipage
explicitly.Note that, in this specific case, you want to use
\input
, not\include
; see When should I use \input vs. \include? for more details.See my example below, in which I've defined a macro called
\insertmytabular
, for more automation.Edit (answer to follow-up question): in that case, define
\insertmytabular
as follows: