表格:单元格垂直对齐

表格:单元格垂直对齐

我有一个tabu表,我的默认行样式是和必须p。但我想要头行(第 1 列第 2 列在 MWE 中)垂直居中。我该如何实现呢?

梅威瑟:

\documentclass{article}
\usepackage{array}
\usepackage{tabu}
\usepackage{blindtext}
\usepackage{ragged2e}
\tabulinesep =0.5em
\newcommand*{\mytext}{\RaggedRight This is some blindtext with words and letters.}

\begin{document}
\begin{tabu} to\textwidth{|X[1,l,p]|X[1,l,p]|X[1,l,p]|}% m is not allowed!!!
    \hline
    Column 1 & Column 2 & Long Long very long caption, more than one line \\
    \hline
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \hline
\end{tabu}
\end{document}

输出

答案1

由于某种原因,不允许从p类型列更改为类型,因此您可以使用:m\raisebox

\documentclass{article}
\usepackage{array}
\usepackage{tabu}
\usepackage{blindtext}
\usepackage{ragged2e}
\tabulinesep =0.5em
\newcommand*{\mytext}{\RaggedRight This is some blindtext with words and letters.}

\begin{document}
\begin{tabu} to\textwidth{|X[1,l,p]|X[1,l,p]|X[1,l,p]|}
    \hline
    \raisebox{-\baselineskip}[0pt][0pt]{Column 1} 
      & \raisebox{-\baselineskip}[0pt][0pt]{Column 2} 
      & Long Long very long caption, more than one line \\
    \hline
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \hline
\end{tabu}
\end{document}

在此处输入图片描述

相关内容