使用 \rotatebox 和 tabularx 垂直居中单元格

使用 \rotatebox 和 tabularx 垂直居中单元格

我似乎找不到解决此问题的先前答案:在下表中,我希望左上角单元格中的文本垂直居中,而不是像现在这样在顶部对齐。

\documentclass[a4paper,12pt]{article}
\usepackage[margin=129pt]{geometry}
\usepackage{tabularx,graphics,makecell,mathptmx}

\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{document}

\begin{table}[h]
\begin{tabularx}{\textwidth}{|c|X|c|c|}
\hline
\scriptsize \rotatebox{90}{\makecell{No. of\\the line.}} & \tiny\centering 
THE COLUMN WITH THE MOST TEXT. & \scriptsize\makecell{A header\\AND\\the 
description\\to go\\with it} & \scriptsize\makecell{Another header\\AND\\the 
description\\to go\\with it}\\ \hline
O & Some quite long text that will definitetly wrap over three lines& 
\makecell{100, 500 Values.\\36 No.} & 36, 24 No.\\  \hline

\end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

感谢您的帮助...

答案1

您可以使用固定宽度类型的第一列m

在此处输入图片描述

\documentclass{article}

\usepackage{tabularx,graphics,makecell}

\renewcommand\tabularxcolumn[1]{ m{#1} }

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{ | >{\centering} m{2em} | X | c | c | }
  \hline
  \scriptsize \rotatebox{90}{\makecell{No.\ of \\ the line.}} 
    & \tiny\centering THE COLUMN WITH THE MOST TEXT. 
    & \scriptsize\makecell{A header \\ AND \\ the description \\ to go \\ with it} 
    & \scriptsize\makecell{Another header \\ AND \\ the description \\ to go \\ with it} \\
  \hline
  O & Some quite long text that will definitely wrap over three lines
    & \makecell{100, 500 Values. \\ 36 No.} & 36, 24 No. \\
  \hline
\end{tabularx}

\end{document}

相关内容