[Tex/LaTex] How to add line separators between columns in Latex table

columnstables

I am looking for a way to separate particular columns (together with their headers) with a vertical line.

So far I have the following code and a table output:

\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\small 
\begin{tabular}{@{\extracolsep{1pt}} ccccccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & var-A-1 & var-A-2 & var-B-1 & var-B-2 & var-B-3 & var-C-1 & var-C-2 & var-C-2.1 \\ 
\hline \\[-1.8ex] 
1 & $0.2655$ & $0.8984$ & $0.206$ & $0.4977$ & $0.9347$ & $0.3861$ & $0.4821$ & $0.6685$ \\ 
2 & $0.3721$ & $0.9447$ & $0.1766$ & $0.7176$ & $0.2121$ & $0.0134$ & $0.5996$ & $0.7942$ \\ 
3 & $0.5729$ & $0.6608$ & $0.687$ & $0.9919$ & $0.6517$ & $0.3824$ & $0.4935$ & $0.1079$ \\ 
4 & $0.9082$ & $0.6291$ & $0.3841$ & $0.38$ & $0.1256$ & $0.8697$ & $0.1862$ & $0.7237$ \\ 
5 & $0.2017$ & $0.0618$ & $0.7698$ & $0.7774$ & $0.2672$ & $0.3403$ & $0.8274$ & $0.4113$ \\ 
\hline \\[-1.8ex] 
\end{tabular} 
\end{table} 

enter image description here

and I would like to end up with something like this:

enter image description here

Best Answer

just place the separator char in the tabular column definition:

cc|ccc|cccc