centre align table with width equal to column width latex
Answers
Answered by
0
If the default tabular environment is used, every colunm get the width they need. This could lead to extra wide tables or to a bad looking if the width differs between the rows.
Solution
One solution is to use the p-parameter of the tabular environment. This has the disadvantage that the cells could only be in justify format.
Example
\documentclass{article}
\begin{document}
\begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
\hline
1 cm width & 2 cm width & 3 cm width \\
\hline
test 1 & test 2 & test 3\\
\hline
\end{tabular}
Solution
One solution is to use the p-parameter of the tabular environment. This has the disadvantage that the cells could only be in justify format.
Example
\documentclass{article}
\begin{document}
\begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
\hline
1 cm width & 2 cm width & 3 cm width \\
\hline
test 1 & test 2 & test 3\\
\hline
\end{tabular}
Similar questions