2

I'm new in Latex and I was trying to replicate this table that was created with Microsoft Word:

enter image description here

But I cannot have the same structure.

3
  • 1
    I'd suggest to read introduccition to booktabs and remember it's rules: 1. Never, ever use vertical rules. 2. Never use double rules..
    – Ignasi
    Oct 17, 2016 at 10:19
  • Please tell us more about the desired structured of this table. E.g., what should its width be? Should it maybe fill the available horizontal space? Should columns 2 and 3 be half as wide as column 1 and 4, respectively, with column 5 as wide as the first four combined? Should text inside the cells be allowed to wrap in case it's wider than the allocated cell width?
    – Mico
    Oct 17, 2016 at 13:06
  • In addition, where should the material in a given cell be placed? Should it be centered, left-aligned, right-aligned, fully-justified, or something else?
    – Mico
    Oct 17, 2016 at 13:15

2 Answers 2

6

First, judging by the appearance of your screenshot, I take it that column 5 should take up half the available horizontal space, and that columns 1 and 4 should be twice as wide as columns 2 and 3. Second, you haven't specified how wide the table should be overall, so I'll assume that it should take up the full width of the textblock. Third, you also haven't specified how the material inside the table should be organized; for the example below I've assumed that line wrapping should be allowed and that the material in each cell should be typeset ragged-right. (Full justification is not advisable for text typeset in narrow columns.)

If these assumptions are on target, the following code may do what you're looking to achieve. It uses a tabularx environment. Observe how the relative widths of the five columns are specified: 0.8333, 0.4167, 0.4167, 0.8333, and 2.5000; the sum of these five numbers is 5 -- the total number of columns of type X. Observe also that \hline draws full-width horizontal rules whereas \cline rules only span the columns given in the argument of the macro.

enter image description here

\documentclass{article}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\begin{document}
\begin{table}[h]
\setlength\tabcolsep{3pt}      % default value: 6pt
\setlength\extrarowheight{2pt} % default value: 0pt
\begin{tabularx}{\textwidth}{|>{\hsize=0.8333\hsize}L|
                              >{\hsize=0.4167\hsize}L|
                              >{\hsize=0.4167\hsize}L|
                              >{\hsize=0.8333\hsize}L|
                              >{\hsize=2.5000\hsize}L|}
\hline
a & b & c & d & e \\
  &   &   &   &   \\
  &   &   &   &   \\
  &   &   &   &   \\
  &   &   &   &   \\
\hline
a & b & c & d & e \\
\hline
f & g & h & i & j \\
  &   &   &   &   \\
\cline{3-3} \cline{5-5}
k & l & m & n & p \\
\cline{3-3} \cline{5-5}
k & l & m & n & p \\
\cline{3-3} \cline{5-5}
k & l & m & n & p \\
\cline{3-3} \cline{5-5}
k & l & m & n & p \\
\hline
\end{tabularx}
\end{table}
\end{document}
2
  • Thanks for your answer! Your assumptions are correct. The table that i need to build is a long table, there is anyway to split the table (the same you created here) across multiple pages?
    – NxA
    Oct 17, 2016 at 14:12
  • @NxA - See this answer for a brief discussion of how to combine the capabilities of the tabularx and longtable environments, with the help of the ltxtable package and its \LTXtable macro. If you have additional questions about this approach, please post a new query.
    – Mico
    Oct 17, 2016 at 15:13
6

Something like this?

enter image description here

\documentclass[11pt,a4paper]{article}
\usepackage{multicol}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|c|c|c|c|c|}
\hline 
 a   &   a & a   &  a  & a      \\
\hline
    &    &    &    &       \\   
\hline 
\multirow{5}{*}{     } & \multirow{5}{*}{     } &     & \multirow{5}{*}{     } &     \\
\hline 
  &  &  text  &  & text \\
\cline{3-3}   \cline{5-5}  
  &  &  text  &  & text \\
\cline{3-3}   \cline{5-5}
  &  &  text  &  & text \\
\cline{3-3}   \cline{5-5}  
  &  &  text  &  & text \\
\hline   

\end{tabular}
\end{document}

Basically, the \multirow command allows you to combine several rows into one. Similarly, the \multicol command allows you to combine several columns into one, by the way. \cline{i-j} is the command to draw horizontal lines across the columns specified, beginning in column i and ending in column j.

1
  • 1
    The \multirow{5}{*}{ } directives do nothing at all here; observe that replacing them with ` ` (blank) produces the exact same outcome. Please justify the use of \multirow more deliberately.
    – Mico
    Oct 17, 2016 at 13:46

You must log in to answer this question.

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