从这个答案,我有:
\documentclass{standalone}
\usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{cellspace}
\setlength\cellspacetoplimit{2ex}
\setlength\cellspacebottomlimit{2ex}
\begin{document}
\begin{tabular}{L{0.5in}L{0.5in}Sl}
test & test & test \\
test & test & test \\
test & test & test
\end{tabular}
\end{document}
这给了我拉伸的行和两个固定宽度的左列:
为什么固定最后一列的宽度会破坏它?
\documentclass{standalone}
\usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{cellspace}
\setlength\cellspacetoplimit{2ex}
\setlength\cellspacebottomlimit{2ex}
\begin{document}
\begin{tabular}{L{0.5in}L{0.5in}L{0.5in}}
test & test & test \\
test & test & test \\
test & test & test
\end{tabular}
\end{document}
答案1
引用cellspace
手动的:
要改善表格间距,必须将表格前言和附加内容更改
S
为列类型l
、c
、r
。段落列p
、m
和b
也同样如此,只是它们必须用一对额外的括号括起来。
以下 MWE 包含两种遵循此规则的可能性,要么S
在列定义中本地使用,要么将其包含在新列类型的全局定义中M
:
\documentclass{standalone}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{M}[1]{S{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}}
\usepackage{cellspace}
\setlength\cellspacetoplimit{2ex}
\setlength\cellspacebottomlimit{2ex}
\begin{document}
\begin{tabular}{S{L{0.5in}}S{L{0.5in}}S{L{0.5in}}}
test & test & test \\
test & test & test \\
test & test & test
\end{tabular}
\begin{tabular}{M{0.5in}M{0.5in}M{0.5in}}
test & test & test \\
test & test & test \\
test & test & test
\end{tabular}
\end{document}