-1

Good day. I have been trying to properly align the table below in latex but, it results in the words escaping the table:

\begin{table}[!htbp] % !
\centering
\caption{Input parameters}
\vspace{1pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}|lccccccccccc}       % {0.8\textwidth}
\hline
\multicolumn{12}{l}{Table of Results for Mn, Mw, PDI and X  \hfill                                   
Operating Temperature, T = 100$^{\circ}$C} \\ 
\hline\hline
\multicolumn{4}{l|}{\begin{tabular}[c]{@{}l@{}}DETERMINISTIC SIMULATION\\ Monomer/Solvent = 60/40 
v/v\\ Initiator Concentration = 5v\\ Simulation time, t = 5mins\end{tabular}} &
\multicolumn{4}{l|}{\begin{tabular}[c]{@{}l@{}}STOCHASTIC SIMULATION\\ Monomer/Solvent = 60/40 
v/v\\ Initiator Concentration = 5v\\ Simulation time, t =5mins\end{tabular}} &
\multicolumn{4}{l}{\begin{tabular}[c]{@{}l@{}}EXPERIMENTAL RESULTS\\ Monomer/Solvent = 60/40 
v/v\\ Initiator Concentration = 5v\\ Simulation time, t = 5mins\end{tabular}} \\ \hline
\multicolumn{1}{c}{Mn} &
\multicolumn{1}{c}{Mw} &
\multicolumn{1}{c}{PDI} &
\multicolumn{1}{c|}{X} &
\multicolumn{1}{c}{Mn} &
\multicolumn{1}{c}{Mw} &
\multicolumn{1}{c}{PDI} &
\multicolumn{1}{c|}{X} &
\multicolumn{1}{c}{Mn} &
\multicolumn{1}{c}{Mw} &
\multicolumn{1}{c}{PDI} &
\multicolumn{1}{c}{X} \\
\hline
\multicolumn{1}{c}{457.44} &
\multicolumn{1}{c}{810.72} &
\multicolumn{1}{c}{1.61} &
\multicolumn{1}{c|}{0.61} &
\multicolumn{1}{c}{339.15} &
\multicolumn{1}{c}{574.16} &
\multicolumn{1}{c}{1.51} &
\multicolumn{1}{c|}{0.55} &
\multicolumn{1}{c}{6768} &
\multicolumn{1}{c}{13607} &
\multicolumn{1}{c}{1.57} &
\multicolumn{1}{c}{0.091}\\ 
\hline
\end{tabular*}
\end{table}

Here is the outcome:

1

teddiclax
  • 35
  • 4

1 Answers1

2

One of the rules to create a clean table is to either avoid repeated information or move it somewhere else: heading, annotation or even outside the table, s.a. the main text. I removed content from the second to the fourth row and move it to a bottom of table, which then became extremely wide and shallow. So the next idea was to decrease its width.

The long phrases are split in multi-lines. I applied makecell for that. I also decreased space between columns and reduced font in cells with numbers. After the changes, the table is much cleaner and can even fit the page.

I also prefer booktabs from regular and I most of times suggest the package in my solutions.

enter image description here

\documentclass{amsbook}
\usepackage{array}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{caption}
\captionsetup[table]{position=top,skip=6pt}
\newcommand\fmtnum[1]{\small#1}
\newcommand\tnote[1]{\rlap{\textsuperscript{\,#1}}}
\begin{document}
\begin{table}
  \renewcommand*{\arraystretch}{1.25}
  \setlength\tabcolsep{4.1pt}
  \centering
  \caption{Input parameters}
  \begin{tabular}{@{}*{12}{c}@{}}       % {0.8\textwidth}
    \toprule
    \multicolumn{12}{@{}c@{}}{
        \raggedright Table of Results for Mn, Mw, PDI and X | Operating Temperature, T = 100$^{\circ}$C} \\
    \midrule
    \multicolumn{4}{c}{\makecell*{DETERMINISTIC\\SIMULATION\tnote{*}}}
    & \multicolumn{4}{c}{\makecell*{STOCHASTIC\\SIMULATION\tnote{*}}}
    & \multicolumn{4}{c}{\makecell*{EXPERIMENTAL\\RESULTS\tnote{*}}} \\
    \cmidrule(r){1-4} \cmidrule(lr){5-8} \cmidrule(l){9-12}
    Mn              & Mw              & PDI           & X              & Mn              & Mw              &
    PDI             & X               & Mn              & Mw            & PDI            & X \\
    \cmidrule(r){1-4} \cmidrule(lr){5-8} \cmidrule(l){9-12}
    \fmtnum{457.44} & \fmtnum{810.72} & \fmtnum{1.61} & \fmtnum{0.61}  & \fmtnum{339.15} & \fmtnum{574.16} &
    \fmtnum{1.51}   & \fmtnum{0.55}   & \fmtnum{6768} & \fmtnum{13607} & \fmtnum{1.57}   & \fmtnum{0.091} \\
    \bottomrule
    \multicolumn{12}{@{}l}{$^{*}$ \makecell[tl]{\footnotesize Monomer/Solvent = 60/40 v/v,
        Initiator Concentration = 5v, Simulation\\\footnotesize time, t = 5mins}}
  \end{tabular}
\end{table}
\end{document}

EDIT.

A new table

enter image description here

\documentclass{amsbook}
\usepackage{makecell}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\captionsetup[table]{position=top,skip=6pt}
\newcommand\fmtnum[1]{#1}
\newcommand\tnote[1]{\rlap{\textsuperscript{\,#1}}}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{table}
  \renewcommand*{\arraystretch}{1.15}
  \setlength\tabcolsep{4.1pt}
  \centering
  \caption{Input parameters}
  \begin{tabularx}{0.8\textwidth}{
        *2{>{\hsize=0.15\hsize\linewidth=\hsize}X}
        *2{>{\hsize=0.1\hsize\linewidth=\hsize}X}
        *2{>{\hsize=0.15\hsize\linewidth=\hsize}X}
        *2{>{\hsize=0.1\hsize\linewidth=\hsize}X}
    }
    \toprule
    \multicolumn{8}{@{}c@{}}{\makecell{
        Table of Results for Mn, Mw, PDI and X\\Operating Temperature, T = 100$^{\circ}$C}} \\
    \midrule
    \multicolumn{4}{c}{\makecell{DETERMINISTIC\\SIMULATION\tnote{*}}}
    & \multicolumn{4}{c}{\makecell{STOCHASTIC\\SIMULATION\tnote{*}}} \\
    \cmidrule(r){1-4} \cmidrule(l){5-8}
    Mn & Mw & PDI & X & Mn & Mw & PDI & X \\
    \cmidrule(r){1-4} \cmidrule(l){5-8}
    \fmtnum{457.44} & \fmtnum{810.72} & \fmtnum{1.61} & \fmtnum{0.61}
    & \fmtnum{339.15} & \fmtnum{574.16} & \fmtnum{0.21} & \fmtnum{0.55} \\
    \bottomrule
    \multicolumn{8}{@{}l}{$^{*}$\makecell[tl]{
        \footnotesize Monomer/Solvent = 60/40 v/v, Initiator Concentration = 5v, Simulation\\\footnotesize time, t = 5mins}}
  \end{tabularx}
\end{table}
\end{document}
Celdor
  • 2,437
  • 2
  • 23
  • 44
  • Thank you for the previous solution @Celdor. However, I have been trying to eliminate the 'EXPERIMENTAL RESULTS' column without distorting the shape of the table. Can you help in rectifying this? – teddiclax Oct 06 '22 at 15:21
  • Apart from removing last columns from each row, obviously, you also need to change a column specification from 12 to 8 since you are going to reduce its number by 4. You also need to remove each instance of `\cmidrule{9-12}`, which draw last bars. The last thing is to re-format both the big title underneath the caption and annotations: as `makecell` package is added, you can apply `\makecell{...\\...\\...}` to break long expressions into multi lines. Let me know if that fails. – Celdor Oct 06 '22 at 15:51
  • Thanks for the timely response @Celdor. I've implemented your suggestion however, still got challenges adjusting the table width. Can you take a look at the above re-edited table? – teddiclax Oct 06 '22 at 16:31
  • See my updated answer. It seems table required a few more advanced changes as I thought before. – Celdor Oct 06 '22 at 16:49
  • Also, I rejected your changes in my answer in case you made them by mistake. – Celdor Oct 06 '22 at 16:50
  • Hello @ Celdor. Thank you for the solution however, from the figure I initially loaded today, I intended that under the "DETERMINISTIC" and "STOCHASTIC" columns, there should only be 2 columns for "X" and "PDI" respectively. – teddiclax Oct 06 '22 at 17:24
  • @teddiclax You didn't mentioned that before. You asked: _I have been trying to eliminate the 'EXPERIMENTAL RESULTS' column without distorting the shape of the table. Can you help in rectifying this?_ which I believe I did in my update. – Celdor Oct 07 '22 at 09:11
  • So, in the end, your table should have everything what the update shows except only those columns should remain: `PDF X PDI X`. Is that correct? – Celdor Oct 07 '22 at 09:16
  • 1
    Thank you for the response @Celdor. I have rectified the issue already. Once again, thanks for the responses. – teddiclax Oct 07 '22 at 20:01