# How to split columns into 2

I want the first row to stay normal and then every row after that should be split into 2 columns. I've done it on Microsoft word to show exactly what I want. I tried used multicolumn but couldn't get it to work correctly.

\begin{center}
\begin{tabular}{ |c|c|c|c|c|c|c|c| }
\hline
B    & B 1 & B 2 & B3 & B4 & B5 & B6 & B 7 \\
\hline
1   & 12 & 12 & 12 & 12 &12  &12& 12\\
\hline
2   & 12& 12& 12& 12&12& 12& 12\\
\hline
3   & & & & & & & \\
\hline
4   & & & & & & &\\
\hline
5   & & & & & & &\\
\hline
6   & & & & & & & \\
\hline
7   & & & & & & &\\
\hline
\end{tabular}
\end{center}

• welcome to tex.se! cells you can merge, but not divide. for your cell with x you can obtain with \multicolumn{2}{c}{x}. similar for others. – Zarko Mar 18 '18 at 17:10
• Thanks Zarko, apologies but its my first time creating a table on latex so still a little confused. I tried doing that but it came up with an error. I've updated the question with what I have so far. – Humza Mar 18 '18 at 17:29
• You might take a look at the wikibook for an overview about tables in LaTeX. Also consider using the booktabs package and following the guidelines laid out in the documentation of booktabs for prettier tables. – Skillmon likes topanswers.xyz Mar 18 '18 at 17:55
• to see your table in context, we need to see complete but small document beginning with\documentclass{...} and ending with \end{document}. about tables beside what suggest @Skillmon, see wiert.me/2014/04/03/… – Zarko Mar 18 '18 at 17:58

• your table code fragment doesn't reproduce showed table. for this it ha defined one column less as needed (you have defined only 8 columns, but showed table has 9)
• for help to people who like to help you, y\documentclass{...} and ending with \end{document}, which show your problem. it should have in preamble loaded all to your problem relevant packages (if any needed)
• as i mentioned in comment, cells cant be split, but can be merged. so solution in general in your case is use command \multicolumn{2}{c}{...} which merge tvo columns and cell's content align in its middle.
• without knowing content of your table your code snippet can be converted into mwe as follows:

\documentclass{article}

\begin{document}
\begin{center}
\begin{tabular}{| *{9}{c|} }
\hline
B    & \multicolumn{2}{c|}{x}
& \multicolumn{2}{c|}{z}
& \multicolumn{2}{c|}{w}
& \multicolumn{2}{c|}{t}                \\
\hline
1   &   12  &   12  &   12  &   12  &   12  &   12  &   12  &   12  \\
\hline
2   &   12  &   12  &   12  &   12  &   12  &   12  &   12  &   12  \\
\hline
3   &       &       &       &       &       &       &       &       \\
\hline
\end{tabular}
\end{center}
\end{document}


• however, your table can be written on many diferent way. one of them is usebooktabs packages for horizontal rules where needed, omit vertical riles and for example use modified X columns from package tabularx:

\documentclass{article}
\usepackage{booktabs, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
\begin{center}
\begin{tabularx}{\linewidth}{ c *{8}{C} }
\toprule
B    & \multicolumn{2}{c}{x}
& \multicolumn{2}{c}{z}
& \multicolumn{2}{c}{w}
& \multicolumn{2}{c}{t}                \\
\midrule
1   &   12  &   12  &   12  &   12  &   12  &   12  &   12  &   12  \\
2   &   12  &   12  &   12  &   12  &   12  &   12  &   12  &   12  \\
3   &       &       &       &       &       &       &       &       \\
\bottomrule
\end{tabularx}
\end{center}
\end{document}


• Ahh yes I see what I was doing wrong. Thanks and for the future tips, I'll be sure too use them next time when asking a question. – Humza Mar 18 '18 at 18:35
\documentclass[12pt,a4paper]{article}
\usepackage{array,multirow,textcomp}
\usepackage[T1]{fontenc}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
%\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
%\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

%    \setlength\extrarowheight{32pt}
\begin{document}

\centering
\begin{tabular}{|c|C{1cm}|C{1cm}|C{1cm}|C{1cm}|C{1cm}|C{1cm}|C{1cm}|C{1cm}|C{1cm}}
\hline
x & \multicolumn{2}{c|}{y}& \multicolumn{2}{c|}{z} & \multicolumn{2}{c|}{w}& \multicolumn{2}{c|}{t}\\ \hline
1 &&&&&&&&\\ \hline
2 &&&&&&&&\\ \hline
3  &&&&&&&&\\ \hline
4  &&&&&&&&\\ \hline
5  &&&&&&&&\\ \hline
6  &&&&&&&&\\   \hline
7  &&&&&&&&\\ \hline

\end{tabular}

\end{document}


• Why \cline{1-9} instead of a \hline? And why are you using C column specifiers? It doesn't seem necessary here. – Skillmon likes topanswers.xyz Mar 18 '18 at 17:51
• In the example, you define a C column twice. You as well load the array package twice and included some packages that are not needed (multirow,textcomp) to produce the table. – leandriis Mar 18 '18 at 17:52