How to avoid words escape a table in latex

Viewed 18

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

1 Answers

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}
Related