表格标题行高与垂直对齐

表格标题行高与垂直对齐

如何设置单行(本例中为标题)的行高并垂直居中对齐?

这是我的 MWE:

\documentclass{article}
\begin{document}
        \begin{tabular}{@{\extracolsep{\fill}} | *4{p{0.22\linewidth} | } }
            \hline
            \multicolumn{1}{|c|}{\small \textbf{Alfa}} &
            \multicolumn{1}{ c|}{\small \textbf{Bravo}}   &
            \multicolumn{1}{ c|}{\small \textbf{Charlie}}  &
            \multicolumn{1}{ c|}{\small \textbf{Delta}} \\ \hline \hline
            Name: \vspace{0.8cm} & Name: & Name: & Name: \\  
            \hline
            Date: \vspace{0.8cm}& Date: & Date: & Date: \\ \hline
        \end{tabular}
\end{document}

答案1

您可以使用 包来实现这一点makecell,该包定义了 引入的单元格的通用格式\thead\makecell以及一些其他命令。参数包括通过 命令在这些单元格的顶部和底部添加的长度\Gape

我还建议使用tabularx环境。下面我给出了四种可能性:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}

 \usepackage{tabularx, makecell, booktabs}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{\Gape[3ex]}
\renewcommand\cellgape{\Gape[4pt][0.8cm]}

 \begin{document}

 \centering
        \begin{tabular}{@{\extracolsep{\fill}} | *4{p{0.22\linewidth} | } }
            \hline
            \thead{Alfa} &
            \thead{Bravo} &
            \thead{Charlie} &
            \thead{Delta} \\ \hline \hline
            Name: \vspace{0.8cm} & Name: & Name: & Name: \\
            \hline
            Date: \vspace{0.8cm}& Date: & Date: & Date: \\ \hline
        \end{tabular}
\vskip 1cm
 \begin{tabularx}{\linewidth}{|*4{X |}}
            \hline
            \thead{Alfa} &
            \thead{Bravo} &
            \thead{Charlie} &
            \thead{Delta} \\ \hline \hline
            Name: \vspace{0.8cm} & Name: & Name: & Name: \\
            \hline
            Date: \vspace{0.8cm}& Date: & Date: & Date: \\ \hline
        \end{tabularx}
\vskip 1cm
 \begin{tabularx}{\linewidth}{l*4{X }}
             & \thead{Alfa} &
            \thead{Bravo} &
            \thead{Charlie} &
            \thead{Delta} \\
            \toprule
            Name: \vspace{0.8cm} & & & & \\
            \cmidrule(l){1-5}
            Date: \vspace{0.8cm}& & & & \\
           \bottomrule
        \end{tabularx}
\vskip 1cm
 \begin{tabularx}{\linewidth}{l!{\vrule width1pt}*4{X }}
             & \thead{Alfa} &
            \thead{Bravo} &
            \thead{Charlie} &
            \thead{Delta} \\
            \Xhline{1pt}
            \makecell[tl]{Name: } & & & & \\
            \makecell[tl]{Date:} & & & & \\
        \end{tabularx}

\end{document} 

在此处输入图片描述

相关内容