I'm new in Latex and I was trying to replicate this table that was created with Microsoft Word:
But I cannot have the same structure.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityFirst, 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.
\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}
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.
Something like this?
\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.
\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.
1. Never, ever use vertical rules. 2. Never use double rules.
.