I would like to create a table like the one I show in the image but I'm a bit lost.
Let's see if someone can help me.
Thank you.
Here's a solution which uses the l
column type for the first column and the r
column type for the six data columns. To give the table material a more open "look", no vertical lines are drawn, and the line-drawing macros of the booktabs
package are used in place of \hline
and \cline
.
\documentclass{article}
\usepackage{booktabs} % for well-spaced horizontal rules
\begin{document}
\begin{center}
\begin{tabular}{@{} l *{6}{r} @{}} % "@{}" eliminates horizontal whitespace padding.
\toprule
Database & \multicolumn{6}{c@{}}{Number of operations} \\
\cmidrule(l){2-7}
& 10 & 50 & 100 & 1000 & 10000 & 100000 \\
\midrule
MongoDB & 61 & 75 & 84 & 387 & 2693 & 23354 \\
RavenDB & 570 & 898 & 1213 & 6939 & 71343 & 740450 \\
\ldots\\
MS Sql Express & 30 & 94 & 129 & 1790 & 15588 & 216479 \\
\bottomrule
\end{tabular}
\end{center}
\end{document}
In addition to novski's answer, here is a variant using rules from booktabs
for a more open appearance and siunitx
for better alignment of number.
\documentclass{article}
\usepackage{multirow}
\usepackage[group-minimum-digits=4]{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{l
S[table-format=3]
S[table-format=3]
S[table-format=4]
S[table-format=4]
S[table-format=5]
S[table-format=6]}
\toprule
\multirow{2.5}{*}{Database} & \multicolumn{6}{c}{Number of operations} \\
\cmidrule{2-7}
& 10 & 50 & 100 & 1000 & 10000 & 100000\\
\midrule
MongoDB & 61 & 75 & 84 & 387 & 2693 & 23354 \\
RavenDB & 570 & 898 & 1213 & 6939 & 71343 & 740450 \\
\bottomrule
\end{tabular}
\end{document}
Here is the variant without the \multirow
:
\toprule
Database & \multicolumn{6}{c}{Number of operations} \\
\cmidrule{2-7}
siunitx
option group-minimum-digits=4
to avoid some unevenness across rows.
group-minimum-digits=4
, the last column should have S[table-format=7]
. I'd not use \multirow
, as the upper left cell has no reason for being lowered, being a first level header.
i use this dependencies:
\usepackage{longtable}
\usepackage{multirow}
~
\begin{longtable}{|l|c|c|c|c|c|c|}\hline
\multirow{2}{*}{Database} & \multicolumn{6}{c|}{Number of operations} \\\cline{2-7}
& 10 & 50 & 100 & 1000 & 10000 & 1000000\\\hline\endhead
MongoDB & 61 & 75 & 84 & 387 & 2693 & 23354 \\
RavenDB & 570 & 898 & 1213 & 6939 & 71343 & 740450 \\ \hline
\caption{Database evaluation}
\label{tab:databaseeval}
\end{longtable}
longtable
? The table in the question seems to be short enought to fit onto a single page.
Commented
Jan 12, 2019 at 12:28
longtable
is not a floating environment." (See: tex.stackexchange.com/a/215443/134144) You might want to keep that in mind when using longtable
.
Commented
Jan 12, 2019 at 12:39
tables
. here on site are tons of similar question.\multicolumn
command and for 'Database' you might want to have a look at the\multirow
command.