I need to reproduce in Latex a table with 3 columns and 5 rows. It should use the full width of the paragraph, center the contents of the cells both horizontally and vertically, and auto-adjust longer texts. But above all, it must have the same height for all lines .
I used tabularx
(to have the table more easily in the width of the paragraph), I redefined the type of column X to center the contents of the cells horizontally and vertically, and I got to this result:
Code with Minimum Compileable Example
\documentclass[10pt,a4paper]{article}
\usepackage[portuguese]{babel}
\usepackage[latin1]{inputenc}
\usepackage{tabularx}
\usepackage{ragged2e}
\begin{document}
% Redefine a coluna do tipo X para centralizar horizontal e verticalmente seu conteúdo
\renewcommand\tabularxcolumn[1]{>{\Centering}m{#1}}
\begin{table}[!h]
\begin{center}
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
Linha 1 & Lorem ipsum dolor sit amet. & Aenean suscipit, nunc ac sodales bibendum, massa lacus iaculis augue, ut suscipit mauris libero in velit. \
\hline
Linha 2 & Vivamus quis justo ac elit condimentum molestie. & Etiam ultrices a libero sed semper. \
\hline
Linha 3 & Morbi ultrices sodales justo, et dictum quam sodales eget. & Cras tortor libero, volutpat eget erat eu, blandit tempus nunc. \
\hline
Linha 4 & Pellentesque gravida, odio sed aliquet tempus, metus lectus sodales sapien. & Fusce fermentum malesuada eros. \
\hline
Linha 5 & Etiam commodo interdum dictum. In sit amet semper leo. In non auctor mauris. & Vivamus ultrices augue non enim pulvinar feugiat. \
\hline
\end{tabularx}
\end{center}
\end{table}
\end{document}
Resultant Table
Ijusthavenotbeenabletoleavealltherowswiththesameheight(ideallythefirstrow,sinceitwastheleastpossibletoincludetherightcellcontent).I'vealreadytried specify extra spacing at the end of each line , but this solution requires a lot of trial and error and the end result is not is good because it only adds spaces in the last column. I've also tried package easytable
, but it does not allow you to set the width of the paragraph and ends up extrapolating the limits of the page, as well as not wrapping long texts. And finally I also tried changing the vertical spacing (or arraystretch ) , but the result was not expected because apparently this command only increases the inner margin of the cells and does not guarantee that the rows have the same height.
Does anyone have a solution to this problem?