I would like to create a table where I can adjust the overall width of the table, hence the tabularx environment. However I am having difficulty in configuring my tables such that I can control:
- The individual width of each column.
- Centre each column.
This is the code I am using:
\documentclass[15pt,twoside]{report}
\usepackage{amsfonts}
\usepackage{tabularx, booktabs}
\usepackage{siunitx}
\usepackage{array}
\begin{document}
\begin{table}[h!]
\centering
\begin{tabularx}{\textwidth}{p{1.5cm}p{1.5cm}p{1.5cm}p{2.5cm}p{1.5cm}}\toprule\\[0.09ex]
Modelling & Reference & $\mu_{s}$ & Modelling & Outcome \\ Noise RMS & Input Noise & & Time Duration \\ [2ex] \midrule\\ [0.5ex]
Optimal (0.3)& & 0.5 & Stopped once converged & Converged \\ [2ex]
0.05 & & 0.25 & $n=10000$ & Failed to converge \\ [2ex]
0.1 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.15 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.2 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.25 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.3 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.35 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.4 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.45 & & 0.25 & $n=10000$ & Destabilised \\ [2ex]
0.5 & & 0.25 & $n=10000$ & Destabilised \\ [0.5ex]\\ \bottomrule
\end{tabularx}
\end{table}
I have deliberately kept the second column empty for now. Any help on this is greatly appreciated as I have been trying to solve this for hours (including searching similar posts on tex stack exchange) to no avail. Thanks.
Best Answer
You don't need
tabularx
if you don't use itsX
columns which adjust their width according to the available space.You probably just need a new column type
M
defined in this way:You don't also need to use different rows for long cells, since they are wrapped into new lines automatically.
MWE:
Output
As a side note,
15pt
is not a valid option for thereport
class.