# Misaligned vertical lines in table

In my document I use different kinds of tables, as shown below in a simplified way. My problem only affects the first table shown in the output. Strangely, the vertical lines between columns "B" and "C" are misaligned. This error only occurs when I include package siunitx which however I need to create tables like the second one.

How can I avoid the misaligned vertical lines?

\documentclass[a4paper,preprint,3p]{elsarticle}

\usepackage{siunitx}
\usepackage{multirow}
\usepackage{subcaption}
\usepackage{booktabs}

\begin{document}

{\scriptsize
\begin{tabular}{rr|rr|rr}
\hline
& A &   \multicolumn{2}{c}{B} & \multicolumn{2}{|c}{C} \\
& & B1 & B2 & C1 & C2 \\
\hline
1 & 2 & 3 & 2 & 1 & 2 \\
1 & 2 & 3 & 2 & 1 & 2 \\
\hline
\end{tabular}
}

\vspace{3cm}

{\scriptsize
\begin{tabular}{
lS[table-text-alignment=center, table-column-width = 0.47 cm, table-format=1.2]
S[table-text-alignment=center, table-column-width = 0.47 cm, table-format=1.2]
}
\hline
& {col 1} & {col 2} \\
\hline
line 1 & 1.22 & 1.13  \\
line 2 & 0.04 & 0.04 \\
\hline
\end{tabular}
}

\end{document}


Just shift the | to the first \multicolumn like
 & A &   \multicolumn{2}{c|}{B} & \multicolumn{2}{c}{C} \\

BTW, siunitx has nothing to do with this alignment. Place | carefully while using \multicolumn.