I'm trying to add the following lines to my document:
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
as per How to create fixed width table columns with text raggedright/centered/raggedleft? to center my table boxes.
However, just adding the line \usepackage{array}
causes my build to break with a "Undefined control sequence. }" on this command:
\renewcommand{\subsectionautorefname}{Sec.}
and also same error on this table:
\begin{table}[H]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{cl|lll|}
\cline{3-5}
\multicolumn{1}{l}{} & & \multicolumn{3}{c|}{Counts on:} \\ \cline{3-5}
\multicolumn{1}{l}{} & & CT\_PMTOR & CT\_SiOR & CT\_SiAND \\ \hline
\multicolumn{1}{|c|}{\multirow{3}{*}{Relative to:}} & CT\_PMTOR & 100.00 $\pm$ 0.19 & 713.36 $\pm$ 1.05 & 139.53 $\pm$ 0.25 \\
\multicolumn{1}{|c|}{} & CT\_SiOR & 14.02 $\pm$ 0.02 & 100.00 $\pm$ 0.07 & 19.56 $\pm$ 0.02 \\
\multicolumn{1}{|c|}{} & CT\_SiAND & 71.67 $\pm$ 0.13 & 511.25 $\pm$ 0.65 & 100.00 $\pm$ 0.16 \\ \hline
\end{tabular}%
}
\caption{}
\label{tab:table}
\end{table}
BUT NOT this table, which is apparantly fine:
\begin{table}[H]
\begin{center}
\noindent\adjustbox{max width=\textwidth}{%
\begin{tabular}{cccc|c}
\toprule
Channel & Background Rate & Total counts & Background Subtracted Counts & Simulated Counts \\
\midrule
CT\_PMTOR & 8.52 $\pm$ 0.015Hz & 530818 $\pm$ 729 & 530443 $\pm$ 729 & X \\
CT\_SiOR & 25.58 $\pm$ 0.026Hz & 3785118 $\pm$ 1946 & 3783992 $\pm$ 1946 & X \\
CT\_SiAND & 0.297 $\pm$ 0.0028Hz & 740160 $\pm$ 860 & 740147 $\pm$ 860 & X \\
\bottomrule
\end{tabular}}
\caption{}
\label{tab:text}
\end{center}
\end{table}
Anyone got any idea whats going on here?
MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[toc,page]{appendix}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{adjustbox}
\usepackage{arydshln} % add hash line for tables
\usepackage{array}
\begin{document}
\begin{table}[htbp]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{cl|lll|}
\cline{3-5}
\multicolumn{1}{l}{} & & \multicolumn{3}{c|}{Counts on:} \\
\cline{3-5}
\multicolumn{1}{l}{} & & CT\_PMTOR & CT\_SiOR & CT\_SiAND \\
\hline
\multicolumn{1}{|c|}{\multirow{3}{*}{Relative to:}} & CT\_PMTOR & 100.00 $\pm$ 0.19 & 713.36 $\pm$ 1.05 & 139.53 $\pm$ 0.25 \\
\multicolumn{1}{|c|}{} & CT\_SiOR & 14.02 $\pm$ 0.02 & 100.00 $\pm$ 0.07 & 19.56 $\pm$ 0.02 \\
\multicolumn{1}{|c|}{} & CT\_SiAND & 71.67 $\pm$ 0.13 & 511.25 $\pm$ 0.65 & 100.00 $\pm$ 0.16 \\
\hline
\end{tabular}%
}
\caption{Caption for Table 1}
\label{tab:table}
\end{table}
\begin{table}[htbp]
\centering
\adjustbox{max width=\textwidth}{%
\begin{tabular}{cccc|c}
\toprule
Channel & Background Rate & Total counts & Background Subtracted Counts & Simulated Counts \\
\midrule
CT\_PMTOR & 8.52 $\pm$ 0.015 Hz & 530818 $\pm$ 729 & 530443 $\pm$ 729 & X \\
CT\_SiOR & 25.58 $\pm$ 0.026 Hz & 3785118 $\pm$ 1946 & 3783992 $\pm$ 1946 & X \\
CT\_SiAND & 0.297 $\pm$ 0.0028 Hz & 740160 $\pm$ 860 & 740147 $\pm$ 860 & X \\
\bottomrule
\end{tabular}
}
\caption{Caption for Table 2}
\label{tab:text}
\end{table}
\end{document}
Comment out and re-add the array package to break/fix the build
Best Answer
You need to load
array
beforearydshln
.But you can also improve the appearance of your tables: the second one needs to be reduced in width, but not by resizing it; rather, you want to avoid repetitions.
For the second table, I looked at the overfull box message and divided the amount between the eight available intercolumn spaces. For your setup, comment the
\addtolength
line and look at the amount you get, which depends on the actual settings of your document.After seeing the amount of overfull, if any, just divide by 8.