3

I have read about multicolumn in latex but I couldn't figure this out. How can I draw this table with assumptions that the width of A and B are evenly distributed, likewise for F,G,H,I,J and K.

Please help me. Thank you enter image description here

4
  • 1
    Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. Aug 22, 2018 at 19:37
  • Do you really want to have "A" and "B" vertically centered? Assuming these two headers are of the same order as "C", they should be at the same height as "C" is a well.
    – Mico
    Aug 22, 2018 at 19:47
  • And, are the six columns labelled "F" thru "K" supposed to have the same widths, or can their widths vary? If so, what should determine the widths? Should column "A" be a lot wider than column "B"?
    – Mico
    Aug 22, 2018 at 19:52
  • If A and B are replaced with long names using multiple lines, you might also look at multirow package (or just use \smash\parbox to overlay the empty rows) Aug 22, 2018 at 21:23

3 Answers 3

3

Here are two possible solutions. The first solution generates minimum-width columns; observe that they don't have to have the same widths. The second solution uses fixed widths for all columns; I'm assuming that columns 3 thru 8 should all have the same width.

enter image description here

\documentclass{article}   
\usepackage{array} % for '\newcolumntype' and '\extrarowheight' macros
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % centered version of 'p' column type
\renewcommand{\familydefault}{\sfdefault} % optional
\begin{document}

\begin{center}
\setlength{\extrarowheight}{3pt} % for a more open "look"

%% first solution: 'c' column type for all 8 columns
\begin{tabular}{|*{8}{c|}}
\hline
& & \multicolumn{6}{c|}{C} \\
\cline{3-8}
A & B & \multicolumn{3}{c|}{D} & \multicolumn{3}{c|}{E}\\
\cline{3-8}
& & F & G & H & I & J & K \\ \hline
& & & & & & & \\ \hline
& & & & & & & \\ \hline
& & & & & & & \\ \hline
\end{tabular}

\bigskip
%% second solution: use 'C' column type, with various widths
\begin{tabular}{|C{8mm}|C{6mm}|*{6}{C{4mm}|}} % set suitable column widths
\hline
& & \multicolumn{6}{c|}{C} \\
\cline{3-8}
A & B & \multicolumn{3}{c|}{D} & \multicolumn{3}{c|}{E}\\
\cline{3-8}
& & F & G & H & I & J & K \\ \hline
& & & & & & & \\ \hline
& & & & & & & \\ \hline
& & & & & & & \\ \hline
\end{tabular}
\end{center}
\end{document}
1

You can do that with {NiceTabular} of nicematrix.

In this environment, you create 'blocks' with a command \Block and then, you only have to use the key hvlines to draw all the rules excepted rules.

\documentclass{article}   
\usepackage{nicematrix} 

\begin{document}
\setlength{\extrarowheight}{3pt}
\begin{NiceTabular}{*{8}{c}}[columns-width=6mm,hvlines]
\Block{3-1}{A} & \Block{3-1}{B} & \Block{1-6}{C} \\
& & \Block{1-3}{D} & & & \Block{1-3}{E} \\
& & F & G & H & I & J & K \\
\\
\\
\\
\end{NiceTabular}
\end{document}

You need several compilations because nicematrix uses PGF/Tikz.

Output of the above code

0
0

In this particular case, I would use a tool to create latex tables such as https://www.tablesgenerator.com/ and manually enter in the data.

For example

% Please add the following required packages to your document preamble:
% \usepackage{multirow}
\begin{table}[]
\begin{tabular}{lllllllllll}
\multicolumn{2}{l}{\multirow{6}{*}{A}} & \multirow{6}{*}{B} & \multicolumn{8}{l}{\multirow{2}{*}{C}}                                                                                                           \\
\multicolumn{2}{l}{}                   &                    & \multicolumn{8}{l}{}                                                                                                                             \\
\multicolumn{2}{l}{}                   &                    & \multicolumn{4}{l}{\multirow{2}{*}{D}}                                           & \multicolumn{4}{l}{\multirow{2}{*}{E}}                        \\
\multicolumn{2}{l}{}                   &                    & \multicolumn{4}{l}{}                                                             & \multicolumn{4}{l}{}                                          \\
\multicolumn{2}{l}{}                   &                    & \multicolumn{2}{l}{\multirow{2}{*}{F}} & \multirow{2}{*}{G}    & \multicolumn{2}{l}{\multirow{2}{*}{H}} & \multicolumn{3}{l}{\multirow{2}{*}{K}} \\
\multicolumn{2}{l}{}                   &                    & \multicolumn{2}{l}{}                   &                       & \multicolumn{2}{l}{}                   & \multicolumn{3}{l}{}                   \\
                   &                   &                    &                    &                   &                       &                 &                      &             &             &            \\
                   &                   &                    &                    &                   &                       &                 &                      &             &             &           
\end{tabular}
\end{table}
3
  • 1
    Did you try to actually generate a table based on this code? The result doesn't resemble the OP's table, I'm afraid.
    – Mico
    Aug 22, 2018 at 20:15
  • Hmm, oh well, maybe I should check next time? and have included borders
    – GrandFleet
    Aug 22, 2018 at 21:43
  • The absent vertical and horizontal lines are a minor issue. Do look into the issue of where the capital letters "I" and "J" are supposed to go.
    – Mico
    Aug 22, 2018 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .