\usepackage{array} causes the build to break

arraystables

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 before arydshln.

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.

\documentclass{article}
%\usepackage[toc,page]{appendix}

\usepackage{graphicx}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage{arydshln} % add hash line for tables



\begin{document}
    
\begin{table}[htbp]
\centering
\sisetup{uncertainty-mode=separate}

\begin{tabular}{
  @{}
  l
  S[table-format=3.2(2)]
  S[table-format=3.2(2)]
  S[table-format=3.2(2)]
  @{}
}
\toprule
Relative to & \multicolumn{3}{c@{}}{Counts on} \\
\cmidrule(l){2-4}
& {CT\_PMTOR} & {CT\_SiOR} & {CT\_SiAND} \\
\midrule
CT\_PMTOR & 100.00 \pm 0.19 & 713.36 \pm 1.05 & 139.53 \pm 0.25 \\
CT\_SiOR  &  14.02 \pm 0.02 & 100.00 \pm 0.07 &  19.56 \pm 0.02 \\
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
\addtolength{\tabcolsep}{-1.5pt}% 11.87808/8

\newcommand{\hd}[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}

\begin{tabular}{
  @{}
  l
  S[table-format=2.3]
  @{${}\pm{}$}
  S[table-format=1.4]
  S[table-format=7.0]
  @{${}\pm{}$}
  S[table-format=4.0]
  S[table-format=7.0]
  @{${}\pm{}$}
  S[table-format=4.0]
  c
  @{}
} 
\toprule
Channel &
\multicolumn{2}{c}{\smash{\hd{Background \\ Rate (Hz)}}} &
\multicolumn{5}{c}{Counts} \\
\cmidrule(l){4-8}
\multicolumn{3}{c}{}& \multicolumn{2}{c}{Total} &
\multicolumn{2}{c}{\hd{Background \\ Subtracted}} &
Simulated \\
\midrule
CT\_PMTOR & 8.52 & 0.015 & 530818 & 729 & 530443 & 729 & X \\   
CT\_SiOR  & 25.58 & 0.026 & 3785118 & 1946 & 3783992 & 1946 & X \\
CT\_SiAND & 0.297 & 0.0028 & 740160 & 860 & 740147 & 860 & X \\
\bottomrule
\end{tabular}

\caption{Caption for Table 2}
\label{tab:text}

\end{table}
    
\end{document}

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.

enter image description here