I am trying to center the following LateX table:
\begin{table*}[ht]
\caption{Comparison of optimization algorithms}
\label{my-label}
\begin{tabularx}{\textwidth}{|c|c|c|c|c|c|c|c|c|c|c|}
\hhline{-*{10}{-}}
Density & \multicolumn{3}{c|}{ 0.2 nodes/m } & \multicolumn{3}{c|}{ 0.3 nodes/m } & \multicolumn{3}{c|}{ 0.2 nodes/m }\\
\hhline{-*{10}{-}}
Bandwidth & \multicolumn{3}{c|}{ 20 MHz } & \multicolumn{3}{c|}{ 20 MHz } & \multicolumn{3}{c|}{ 120 MHz }\\
\hhline{-*{10}{-}}
Algorithm & DLNN & Bayesian & Grid & DLNN & Bayesian & Grid & DLNN & Bayesian & Grid \\
\hhline{-*{10}{-}}
Time & 40s & 85s & 575s & 45s & 90s & 573s & 45s & 85s & 658s \\
\hhline{-*{10}{-}}
Min CBR & 0.0618 & 0.0175 & 0.0168 & 0.02635 & 0.0272 & 0.0263 & 0.0022 & 0.0022 & 0.0021 \\
\hhline{-*{10}{-}}
$\gamma$ & 6.8 & 2.6 & 6.8 & 9 & 3.367 & 8.9 & 1.14 & 2.202 & 0.9 \\
\hhline{-*{10}{-}}
k & 10 & 8 & 8 & 10 & 8 & 10 & 10 & 10 & 10 \\
\hhline{-*{10}{-}}
$\lambda$ & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\hhline{-*{10}{-}}
Nrp & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\hhline{-*{10}{-}}
PRP & 0.9991 & 0.9993 & 0.9990 & 0.9990 & 0.9990 & 0.9990 & 0.9997 & 0.9997 & 0.9992 \\
\hhline{-*{10}{-}}
ED & 0.00040 & 0.00043 & 0.00040 & 0.00040 & 0.00046 & 0.00040 & 5.5E-05 & 5.6E-05 & 6.0E-05 \\
\hhline{-*{9}{-}}
\end{tabularx}
\end{table*}
I've tried \centering and \begin{center}. None of these worked, and I'm not sure why...

\begin{tabularx}{\textwidth}the table spans the whole width. If you want to centre the table, reduce the width or switch to a normaltabularso that it can have its natural width. Is your page width enough for the table? – samcarter_is_at_topanswers.xyz Jan 24 '24 at 15:16\documentclass{...}, the required\usepackage's,\begin{document}, and\end{document}. That may seem tedious to you, but think of the extra work it represents for the users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – samcarter_is_at_topanswers.xyz Jan 24 '24 at 15:17hso you should remove[ht]which does nothing useful and will force the table to the end of the document if it is more that 70% of the page height – David Carlisle Jan 24 '24 at 15:27