# Table formatting with tabularx?

I am trying to format the table to obtain the one in the picture. However, the result is less than satisfactory, could you please help me with tabularx enviroment?

\begin{table}[]
\centering
\caption{Value of the force local maximums (F\textsubscript{i} and F\textsubscript{Q}) and magnitude of the associated load drops observed in the load-displacement curves of impacted and indented LTHIN\textsubscript{LVI}, LV1\textsubscript{LVI} and LV2\textsubscript{LVI} specimens, $\pm$ refers to the standard deviation between experiments.}
\label{Table3pD}
\begin{tabularx}{\linewidth}{ccccccc}
\hline
Material & \multicolumn{6}{c}{Test}                                                                          \\ \cline{2-7}
& \multicolumn{2}{c}{Impact at 10 J} & \multicolumn{2}{c}{Impact at 14 J} & \multicolumn{2}{c}{QSI} \\ \cline{2-7}
& F\textsubscript{i} (kN)              & Load drop (\%)       & F\textsubscript{i} (kN)              & Load drop (\%)         & F\textsubscript{Q} (kN)      & Load drop (\%)   \\ \hline
LTHIN\textsubscript{LVI}    & 3.24 $\pm$ 0.02       & 19.75 $\pm$ 0.55       & 3.41 $\pm$ 0.25       & 22.80 $\pm$ 1.40       & 3.32     & Multiple     \\
LV1\textsubscript{LVI}      & 3.19 $\pm$ 0.04       & 14.64 $\pm$ 2.55       & 3.24 $\pm$ 0.22       & 11.34 $\pm$ 4.46       & 3.10     & Multiple     \\
LV2\textsubscript{LVI}      & 3.51 $\pm$ 0.15       & 8.17 $\pm$ 2.36        & 3.95 $\pm$ 0.51       & 10.80 $\pm$ 1.28       & None     & None         \\ \hline
%   \end{tabular}
\end{tabularx}
\end{table}

• Why are you using tabularx if you have no X columns? This table looks like it would be fine without using tabularx at all. Also you should be using booktabs for its rules. (And it's helpful to post compilable documents on the site, instead of code fragments.) – Alan Munn Apr 21 at 17:27
• Thank you! Could you please provide an example (still very new in Latex) – Santi Apr 21 at 17:28
• Maybe you could elaborate on why you are not satisfied with the result. – Leonard Michlmayr Apr 21 at 19:27

Here's a juxtaposition of three possible solutions: with tabularx, with tabular, and with tabular*. Since there's no need for automatic line breaks in any cells, using tabularx seems like overkill. You should choose between either the tabular and the tabular* solution.

What I would really recommend you do (and what's implemented in all three solutions below) is to use the line-drawing macros of the booktabs package instead of \hline and \cline. I would also provide a bit more structure to the header material, say by placing information about units of measurement on lines of their own. Finally, consider using the \SI and \si macros of the siunitx package to typeset scientific units (with and without numbers).

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % choose page parameters suitably
\usepackage{tabularx,ragged2e,siunitx,booktabs}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\usepackage[skip=0.333\baselineskip]{caption} % optional

\begin{document}
\begin{table}
\caption{Table with \texttt{tabularx}} \label{tab:tabularx}

\begin{tabularx}{\linewidth}{@{} l *{6}{C}@{}}
\toprule
Material & \multicolumn{6}{c@{}}{Test} \\
\cmidrule(l){2-7}
& \multicolumn{2}{c}{Impact at \SI{10}{\joule}}
& \multicolumn{2}{c}{Impact at \SI{14}{\joule}}
& \multicolumn{2}{c}{QSI} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& $F_i$ & Load drop & $F_i$ & Load drop & $F_Q$ & Load drop \\
& (\si{\kilo\newton}) & (\%) & (\si{\kilo\newton}) & (\%) & (\si{\kilo\newton}) & (\%) \\
\midrule
LTHIN\textsubscript{LVI}    & 3.24 $\pm$ 0.02       & 19.75 $\pm$ 0.55       & 3.41 $\pm$ 0.25       & 22.80 $\pm$ 1.40       & 3.32     & Multiple     \\
LV1\textsubscript{LVI}      & 3.19 $\pm$ 0.04       & 14.64 $\pm$ 2.55       & 3.24 $\pm$ 0.22       & 11.34 $\pm$ 4.46       & 3.10     & Multiple     \\
LV2\textsubscript{LVI}      & 3.51 $\pm$ 0.15       & 8.17 $\pm$ 2.36        & 3.95 $\pm$ 0.51       & 10.80 $\pm$ 1.28       & None     & None  \\
\bottomrule
\end{tabularx}

\bigskip\bigskip

\caption{Table with \texttt{tabular}} \label{tab:tabular}
\centering
\begin{tabular}{@{} l *{6}{c} @{}}
\toprule
Material & \multicolumn{6}{c@{}}{Test} \\
\cmidrule(l){2-7}
& \multicolumn{2}{c}{Impact at \SI{10}{\joule}}
& \multicolumn{2}{c}{Impact at \SI{14}{\joule}}
& \multicolumn{2}{c}{QSI} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& $F_i$ & Load drop & $F_i$ & Load drop & $F_Q$ & Load drop \\
& (\si{\kilo\newton}) & (\%) & (\si{\kilo\newton}) & (\%) & (\si{\kilo\newton}) & (\%) \\
\midrule
LTHIN\textsubscript{LVI}    & 3.24 $\pm$ 0.02       & 19.75 $\pm$ 0.55       & 3.41 $\pm$ 0.25       & 22.80 $\pm$ 1.40       & 3.32     & Multiple     \\
LV1\textsubscript{LVI}      & 3.19 $\pm$ 0.04       & 14.64 $\pm$ 2.55       & 3.24 $\pm$ 0.22       & 11.34 $\pm$ 4.46       & 3.10     & Multiple     \\
LV2\textsubscript{LVI}      & 3.51 $\pm$ 0.15       & 8.17 $\pm$ 2.36        & 3.95 $\pm$ 0.51       & 10.80 $\pm$ 1.28       & None     & None  \\
\bottomrule
\end{tabular}

\bigskip\bigskip

\caption{Table with \texttt{tabular*}} \label{tab:tabular*}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{6}{c}}
\toprule
Material & \multicolumn{6}{c}{Test} \\
\cmidrule(l){2-7}
& \multicolumn{2}{c}{Impact at \SI{10}{\joule}}
& \multicolumn{2}{c}{Impact at \SI{14}{\joule}}
& \multicolumn{2}{c}{QSI} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7}
& $F_i$ & Load drop & $F_i$ & Load drop & $F_Q$ & Load drop \\
& (\si{\kilo\newton}) & (\%) & (\si{\kilo\newton}) & (\%) & (\si{\kilo\newton}) & (\%) \\
\midrule
LTHIN\textsubscript{LVI}    & 3.24 $\pm$ 0.02       & 19.75 $\pm$ 0.55       & 3.41 $\pm$ 0.25       & 22.80 $\pm$ 1.40       & 3.32     & Multiple     \\
LV1\textsubscript{LVI}      & 3.19 $\pm$ 0.04       & 14.64 $\pm$ 2.55       & 3.24 $\pm$ 0.22       & 11.34 $\pm$ 4.46       & 3.10     & Multiple     \\
LV2\textsubscript{LVI}      & 3.51 $\pm$ 0.15       & 8.17 $\pm$ 2.36        & 3.95 $\pm$ 0.51       & 10.80 $\pm$ 1.28       & None     & None  \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}

• Very helpful as well! – Santi Apr 21 at 18:09

You don't need to use tabularx for this type of table. Here's your example using booktabs for nicer spacing and rules, and the caption package to give you more control over the caption (in this case it automatically adds some space between the caption and the table.)

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{booktabs}
\usepackage{caption}
\begin{document}
\begin{table}[]
\centering
\caption{Value of the force local maximums (F\textsubscript{i} and F\textsubscript{Q}) and magnitude of the associated load drops observed in the load-displacement curves of impacted and indented LTHIN\textsubscript{LVI}, LV1\textsubscript{LVI} and LV2\textsubscript{LVI} specimens, $\pm$ refers to the standard deviation between experiments.}
\label{Table3pD}
\begin{tabular}{ccccccc}
\toprule
Material & \multicolumn{6}{c}{Test}                                                                          \\ \cmidrule{2-7}
& \multicolumn{2}{c}{Impact at 10 J} & \multicolumn{2}{c}{Impact at 14 J} & \multicolumn{2}{c}{QSI} \\ \cmidrule{2-7}
& F\textsubscript{i} (kN)              & Load drop (\%)       & F\textsubscript{i} (kN)              & Load drop (\%)         & F\textsubscript{Q} (kN)      & Load drop (\%)   \\
\midrule
LTHIN\textsubscript{LVI}    & 3.24 $\pm$ 0.02       & 19.75 $\pm$ 0.55       & 3.41 $\pm$ 0.25       & 22.80 $\pm$ 1.40       & 3.32     & Multiple     \\
LV1\textsubscript{LVI}      & 3.19 $\pm$ 0.04       & 14.64 $\pm$ 2.55       & 3.24 $\pm$ 0.22       & 11.34 $\pm$ 4.46       & 3.10     & Multiple     \\
LV2\textsubscript{LVI}      & 3.51 $\pm$ 0.15       & 8.17 $\pm$ 2.36        & 3.95 $\pm$ 0.51       & 10.80 $\pm$ 1.28       & None     & None         \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


• Thank you so much! – Santi Apr 21 at 17:59
• @Santi You're welcome. But you should look at the other answers too. I agree with both Mico and leandriis that using siunitx is a good idea for any table that has numerical data in it. – Alan Munn Apr 21 at 18:02

Here is an approach similar to Alan Munn's and Mico's but I have also used S type columns from siunitx in order to improve the alignment of the numbers (especially in the third column).

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}
\sisetup{separate-uncertainty}

\begin{document}
\begin{table}[]
\centering
\caption{Value of the force local maximums (F\textsubscript{i} and F\textsubscript{Q}) and magnitude of the associated load drops observed in the load-displacement curves of impacted and indented LTHIN\textsubscript{LVI}, LV1\textsubscript{LVI} and LV2\textsubscript{LVI} specimens, $\pm$ refers to the standard deviation between experiments.}
\label{Table3pD}
\begin{tabular}{c
S[table-format=1.2(3)]
S[table-format=2.2(3)]
S[table-format=1.2(3)]
S[table-format=2.2(3)]
S[table-format=1.2]
c}
\toprule
Material & \multicolumn{6}{c}{Test}                                                                          \\ \cmidrule{2-7}
& \multicolumn{2}{c}{Impact at 10 J} & \multicolumn{2}{c}{Impact at 14 J} & \multicolumn{2}{c}{QSI} \\ \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& {F\textsubscript{i} (\si{\kilo\newton})}             & {Load drop (\%)}       & {F\textsubscript{i} (\si{\kilo\newton})}              & {Load drop (\%)}         & {F\textsubscript{Q} (\si{\kilo\newton})}      & {Load drop (\%)}   \\
\midrule
LTHIN\textsubscript{LVI}    & 3.24 \pm 0.02       & 19.75 \pm 0.55       & 3.41 \pm 0.25       & 22.80 \pm 1.40       & 3.32     & Multiple     \\
LV1\textsubscript{LVI}      & 3.19 \pm 0.04       & 14.64 \pm 2.55       & 3.24 \pm 0.22       & 11.34 \pm 4.46       & 3.10     & Multiple     \\
LV2\textsubscript{LVI}      & 3.51 \pm 0.15       & 8.17 \pm 2.36        & 3.95 \pm 0.51       & 10.80 \pm 1.28       & {None}     & None         \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


I propose the following code, with packages geometry (to have more decent margins, if you don't need marginal notes, siunitx for the alignment of numbers and booktabs:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{tabularx, multirow, caption, booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}[!htb]
\centering\sisetup{table-number-alignment=center, separate-uncertainty, table-align-uncertainty=false}
\setlength{\tabcolsep}{4.5pt}
\caption{Value of the force local maximums (F\textsubscript{i} and F\textsubscript{Q}) and magnitude of the associated load drops observed in the load-displacement curves of impacted and indented LTHIN\textsubscript{LVI}, LV1\textsubscript{LVI} and LV2\textsubscript{LVI} specimens, $\pm$ refers to the standard deviation between experiments.}
\label{Table3pD}
\begin{tabularx}{\linewidth}{X*{2}{S[table-format=1.2(1)]S[table-format=2.2(2)]}S[table-format=1.2]c}
\toprule
\multirow{5}{=}{Material} & \multicolumn{6}{c}{Test} \\ \cmidrule(lr){2-7}
& \multicolumn{2}{c}{Impact at 10 J} & \multicolumn{2}{c}{Impact at 14 J} & \multicolumn{2}{c}{QSI} \\ \cmidrule(lr){2-7}
& {F\textsubscript{i} (kN)} & {Load drop (\%)} &{ F\textsubscript{i} (kN)} & {Load drop (\%)} & {F\textsubscript{Q} (kN)} & Load drop (\%) \\ \midrule
LTHIN\textsubscript{LVI} & 3.24 (2)& 19.75(55) & 3.41(25) & 22.80(140)
& 3.32 & Multiple \\ \addlinespace
LV1\textsubscript{LVI} & 3.19 (4)& 14.64(255) & 3.24(22) & 11.34(446)
& 3.10 & Multiple \\ \addlinespace
LV2\textsubscript{LVI} & 3.51 (15) & 8.17(236)& 3.95(51) & 10.80(128)
& {None} & None \\ \bottomrule
% \end{tabular}
\end{tabularx}
\end{table}

\end{document}