table fixed width

LaTeX table fixed width

StartSearchLaTeX for Beginners F.A.Q.LaTeX faqLaTeX topicsLaTeX course
< centering a table     > footnote within a table

fixed width

How to create a table in LaTeX with fixed width? generate LaTeX tables with fixed width online

Problem

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}


\end{document}


Output:

Hint

The alignment of the cells could be changed by using the package tabularx and define three new row-types: flush left fixed width:
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

center fixed width:
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

flush right fixed width:
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

example 2

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

\begin{tabular}{|L{1cm}|C{2cm}|R{3cm}|}
\hline
1 cm width & 2 cm  width & 3 cm  width \\
\hline
test 1 & test 2 & test 3\\
\hline
\end{tabular}

\end{document}
output:


Contact   Privacy Policy   disclosures

accept decline

This website uses cookies and pixel tags to ensure you get the best experience on our website. By using this website, you consent to the use of cookies.learn more about cookies see also our privacy policy