I want to create a tabel in Latex, but it doesn’t seem to fit on page or there are some other problems with my code. It looks like this:
documentclass[11pt,a4paper]{article} usepackage[romanian]{babel}
usepackage[a4paper, total={6in, 8in}]{geometry}
usepackage{lscape}
usepackage{tabularx}
usepackage{multirow}
usepackage{makecell}
usepackage{array}
begin{document}
%begin{landscape}
begin{table}[ht]
centering
begin{tabularx}{textwidth}{ |p{2cm}| p{4cm}| p{4cm}| p{2cm}| p{3cm}| p{2cm}|p{2cm} |}
hline
multirow{2}{}{makecell{Long text Long text}} & multicolumn{2}{c|}{makecell{Long text Long text}} & multicolumn{3}{c|}{Long text} & multirow{2}{}{text text} cline{2-6}
&Long text &Long text &Long text & text text & makecell{text text text text} & hline hline
text text &Long text & Long textt & Long text & text & text & text hline
text text & Long text &Long text & text text & text & text & text hline
end{tabularx}
caption{no caption}
end{table}
%end{landscape}
end{document}
I tried to put it in landscape or adjust page dimensions, but nothing changed… There are lines of the table that disapper and I can’t see the last column. What can I do?
New contributor
mathuser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I would suggest to use the tabularray
package instead. It makes it very easy to merge cells:
documentclass[11pt,a4paper]{article}
usepackage[romanian]{babel}
usepackage[a4paper, total={6in, 8in}]{geometry}
usepackage{tabularray}
begin{document}
begin{table}[ht]
begin{tblr}{
colspec={XXXXXXX},
vlines,
hlines,
row{1}={halign=c}
}
SetCell[r=2]{} Long text Long text & SetCell[c=2]{} Long text & &
SetCell[c=3]{} Long text & & & SetCell[r=2]{} text text\
&Long text &Long text &Long text & text text & text text text text\
text text &Long text & Long textt & Long text & text & text & text\
text text & Long text &Long text & text text & text & text & text \
end{tblr}
caption{no caption}
end{table}
end{document}