I am finishing up a table for an IEEE publication but I have a problem because the table is pushed outside of the margins of the paper as you see below:
I am not sure why that is happening. Although I noticed that the "keyword" column might be the item responsible for this behavior because if some of the keywords are composed of a small word, than this problem is less visible (but still present). Also the second problem, very likely caused by the length of the "keyword" column, is that this causes a misalignment of the headers to the right but they should be in the middle.
Below is what I have obtained so far:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{siunitx} % v3!
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\usepackage{ragged2e}
\usepackage{caption}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{mwe}
\usepackage{booktabs, makecell, multirow, tabularx}
\setcellgapes{3pt}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}%
\hsize=#1\hsize}X}
% Other paragraphs...
\begin{table*}\centering
\ra{1.3}
\begin{tabular}{@{}rrrrcrrrcrrr@{}}\toprule
& \multicolumn{3}{c}{QUERY-1} & \phantom{abc}& \multicolumn{3}{c}{QUERY-2} &
\phantom{abc} & \multicolumn{3}{c}{QUERY-3}\\
\cmidrule{2-4} \cmidrule{6-8} \cmidrule{10-12}
& Keyword & Occurrence & Strength && Keyword & Occurrence & Strength && Keyword & Occurrence & Strength\\ \midrule
$Top$\\
$1.$ & photoacoustics & 58 & 1047 && photoacoustics & 854 & 23329 && -1.0032 & -1.7104 & -21.7969\\
$2,$ & ultrasonics & 59 & 712 && photo-acoustic imaging & 1063 & 19283 && 4.3590& 34.5809& 76.9167\\
$3.$ & photo-acoustic imaging & 50 & 615 && animals & 568 & 18569 && -121.0518& -137.1210& -220.2500\\
$4.$ & echography & 31 & 611 && human & 556 & 16810 && -121.0518& -137.1210& -220.2500\\
$5.$ & ultrasonic applications & 63 & 600 && mouse & 389 & 13542 && -1.2998& -3.8202& -1.2784\\
$6.$ & procedures & 23 & 552 && procedures & 421 & 13287 && -11.1631& -5.7108& -15.6728\\
$7.$ & ultrasound & 26 & 505 && diagnostic imaging & 350 & 10806 && 52.5745& 10.1098& -140.2130\\
$8.$ & diagnostic imaging & 23 & 460 && chemistry & 286 & 10113 && 52.5745& 10.1098& -140.2130\\
$9.$ & ultrasound imaging & 29 & 430 && female & 250 & 8782 && 52.5745& 10.1098& -140.2130\\
$10.$ & animal experiment & 15 & 417 && animal model & 204 & 7883 && 52.5745& 10.1098& -140.2130\\
$Bottom$\\
$1.$ & non-contact & 8 & 62 && photonics & 15 & 200 && -1.0032 & -1.7104 & -21.7969\\
$2,$ & surface defects & 8 & 62 && cardiovascular system & 7 & 199 && 4.3590& 34.5809& 76.9167\\
$3.$ & fiber reinforced plastic & 6 & 61 && ultrasonography & 6 & 199 && -121.0518& -137.1210& -220.2500\\
$4.$ & damage visualization & 5 & 58 && focused ultrasound & 12 & 197 && -121.0518& -137.1210& -220.2500\\
$5.$ & elastography & 5 & 57 && raman scattering & 9 & 196 && -1.0032 & -1.7104 & -21.7969\\
$6,$ & high spacial resolution & 6 & 56 && prostate cancer & 8 & 195 && 4.3590& 34.5809& 76.9167\\
$7.$ & computerized tomography & 8 & 54 && photoacoustic measurements & 13 & 94 && -121.0518& -137.1210& -220.2500\\
$8.$ & ultrasound propagation & 6 & 53 && excitation wavelength & 13 & 193 && -121.0518& -137.1210& -220.2500\\
$9.$ & laser ultrasonic systems & 6 & 51 && breast imaging & 9 & 190 && 4.3590& 34.5809& 76.9167\\
$10.$ & nondestructive testing & 7 & 49 && fluences & 10 & 1894 && -121.0518& -137.1210& -220.2500\\
\bottomrule
\end{tabular}
\caption{Caption}
\end{table*}
I have researched this problem quite a bit and came across this source, this other source. They both were useful to have an understanding of the margins but still they could not be used to solve the issue I have.
I dug more into the problem and find out this source and also this one. However, despite useful, those last two sources were not able to lead me to a proper conclusion.
Please if anyone had the same problem, point out to a proper solution.
EDITS
Thanks to a user the third column is updated to "words" values. However this is causing an incorrect behavior of the column as you can see below.
\begin{table*}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l lS[table-format=2.0] S[table-format=4.0]
lS[table-format=4.0] S[table-format=5.0]
*{3}{S[table-format=-3.4]} }
\toprule
& \multicolumn{3}{c}{QUERY 1}
& \multicolumn{3}{c}{QUERY 2}
& \multicolumn{3}{c}{QUERY 3 (???)} \\
\cmidrule{2-4} \cmidrule{5-7} \cmidrule{8-10}
& Keyword & {\#} & {Strength}
& Keyword & {\#} & {Strength}
& {Keyword} & {\#} & {Strength} \\
\midrule
\multicolumn{5}{@{}l}{\itshape Top}\\
1. & photoacoustics & 58 & 1047 & photoacoustics & 854 & 23329 & human & 803 & 18692 \\
2. & ultrasonics & 59 & 712 & photo-acoustic imaging & 1063 & 19283 & three dimensional imaging & 606 & 15014 \\
3. & photo-acoustic imaging & 50 & 615 & animals & 568 & 18569 & female & 544 & 13097 \\
4. & echography & 31 & 611 & human & 556 & 16810 & echography & 492 & 12084 \\
5. & ultrasonic applications & 63 & 600 & mouse & 389 & 13542 & ultrasonopgraphy & 271 & 6733\\
6. & procedures & 23 & 552 & procedures & 421 & 13287 & ultrasonics & 289 & 5390 \\
7. & ultrasound & 26 & 505 & diagnostic imaging & 350 & 10806 & pregnancy & 207 & 5075 \\
8. & diagnostic imaging & 23 & 460 & chemistry & 286 & 10113 & algorithms & 187 & 5039 \\
9. & ultrasound imaging & 29 & 430 & female & 250 & 8782 & 3d ultrasound & 227 & 4569 \\
10. & animal experiment & 15 & 417 & animal model & 204 & 7883 & fetus echography & 150 & 3645 \\
\addlinespace
\multicolumn{5}{@{}l}{\itshape Bottom}\\
1. & non-contact & 8 & 62 & photonics & 15 & 200 & cancer prognosis & 5 & 107 \\
2. & surface defects & 8 & 62 & cardiovascular system & 7 & 199 & image resolution & 9 & 106 \\
3. & fiber reinforced plastic & 6 & 61 & ultrasonography & 6 & 199 & wave propagation & 7 & 105 \\
4. & damage visualization & 5 & 58 & focused ultrasound & 12 & 197 & position sensors & 5 & 104 \\
5. & elastography & 5 & 57 & raman scattering & 9 & 196 & fibers & 6 & 103 \\
6, & high spacial resolution & 6 & 56 & prostate cancer & 8 & 195 & medical robotics & 7 & 103 \\
7. & computerized tomography & 8 & 54 & photoacoustic measurements & 13 & 94 & breast lesion & 5 & 101 \\
8. & ultrasound propagation & 6 & 53 & excitation wavelength & 13 & 193 & segmentation methods & 7 & 100 \\
9. & laser ultrasonic systems & 6 & 51 & breast imaging & 9 & 190 & robotic surgery & 6 & 99 \\
10. & nondestructive testing & 7 & 49 & fluences & 10 & 1894 & transducer elements & 6 & 98 \\
\bottomrule
\addlinespace
\end{tabular*}
\caption{Caption}
\end{table*}