1

I am a new latex users and I can build only simple table I must build a more complex table as depict in the follow image: enter image description here

How can build this table code????

3
  • Go here and use this online table generator. You will get the resulting code to paste into your project. tablesgenerator.com/# Commented Mar 7, 2016 at 21:58
  • You can try tablesgenerator.com to play and learn Commented Mar 7, 2016 at 21:59
  • This is actually quite easy with multirow and \multicolumn{...} and \cline commands. Or without multirow and manual placement of layer in the second row`
    – user31729
    Commented Mar 7, 2016 at 22:06

2 Answers 2

3

Without any extra package and much ado, just using \multicolumn and \cline statements (and the usual tabular commands etc.)

\documentclass{article}

\begin{document}

\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|l|*{8}{p{1.2cm}|}}
\hline
Derivative & \multicolumn{8}{c|}{Integral layer} \tabularnewline
\cline{2-9} 
layer & Type1 & Type2 &  Type3 &  Type4 &  Type5 &  Type6 &  Type7 &   Type8 \tabularnewline
\hline
A & & & & & & & & \tabularnewline
\hline
B & & & & & & & & \tabularnewline
\hline
\end{tabular}

\end{document}

enter image description here

8
  • Thanks, but what is \renewcommand{\arraystretch}{1.2}??? Commented Mar 7, 2016 at 22:13
  • @LucaAngelino: It changes the vertical distance between lines in a table.
    – user31729
    Commented Mar 7, 2016 at 22:14
  • Of course, there are other setups, with tabularx and better spacing, but this 'minimal' setup works too;-)
    – user31729
    Commented Mar 7, 2016 at 22:17
  • @LucaAngelino: You're welcome. Happy TeXing!
    – user31729
    Commented Mar 7, 2016 at 22:23
  • What does the *{8} bit do? Commented Mar 8, 2016 at 1:11
1

Christian's answer gives the exact formatting, but here's one using booktabs that I think looks better:

enter image description here

\documentclass{article}
\usepackage[margin=1in]{geometry} % table is too wide for default margins
\usepackage{booktabs}
\usepackage{lipsum} % to show extent of margins

\begin{document}
\lipsum[1]

\begin{table}
\centering
\begin{tabular}{r *{8}{c}} \toprule
& \multicolumn{8}{c}{Integral layer} \\ \cmidrule{2-9}
Derivative layer & Type 1 & Type 2 & Type 3 & Type 4 & Type 5 & Type 6 & Type 7 & Type 8 \\ \midrule
A & & & & & & & \\
B & & & & & & & \\
C & & & & & & & \\
D & & & & & & & \\
E & & & & & & & \\
F & & & & & & & \\
G & & & & & & & \\ \bottomrule
\end{tabular}
\caption{\label{tab:thetable} The table}
\end{table}

\end{document}

You must log in to answer this question.

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