方法1: 使用p{x cm}能固定列宽,但是不能修改是否居中、左对齐、右对齐。只能使用默认格式
\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}
效果图:
方法2:
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}}
示例如下:
\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}