如何對齊旋轉的表格單元格

如何對齊旋轉的表格單元格

我需要對齊旋轉單元格文字的幫助。問題是我事先不知道表格中出現的文本,所以我不能使用類似\settowidth\rotheadsize{text}.

這是我到目前為止所擁有的。

\documentclass{article}
\usepackage{graphicx}
\usepackage{makecell, rotating}
\renewcommand\theadalign{lb}
\begin{document}

\small

\noindent\begin{tabular}{@{}|p{2.5cm}|l|p{2cm}|l|l|p{16mm}|p{13mm}|@{}}
\hline
A & \rothead{text} & a long text that spans over multiple lines  & b & c & d & \rothead{efg} \\
 \hline
\multicolumn{7}{|c|}{sometext} \tabularnewline
 \hline
\end{tabular}

\end{document}

在此輸入影像描述

我希望在表格單元格的底部添加“text”和“efg”一詞,以便它與“長文本......多行”的最後一個基線很好地對齊。

不確定這是否重要:我用於tabularx表格。

答案1

A如果您想要底部的所有內容(例如,也),則使用 [b] 列類型作為長列應該可以。如果它們應該留在頂部,您可能需要測量大柱,例如:

\documentclass{article}
\usepackage{graphicx}
\usepackage{makecell, rotating}
\renewcommand\theadalign{lb}
\usepackage{zref-savepos}
\begin{document}

\small

\newlength\startstopdistance
\startstopdistance=\dimexpr \zposy{stop}sp-\zposy{start}sp+\baselineskip+\arrayrulewidth\relax

\noindent\begin{tabular}{@{}|p{2.5cm}|l|p{2cm}|l|l|p{16mm}|p{13mm}|@{}}
\hline\noalign{\zsavepos{start}}
A & \raisebox{\startstopdistance}[0pt][0pt]{\rotatebox{90}{text}}& a long text that spans over multiple lines  & b & c & d &
    \raisebox{\startstopdistance}[0pt][0pt]{\rotatebox{90}{efg}} \\
 \hline\noalign{\zsavepos{stop}}
\multicolumn{7}{|c|}{sometext} \tabularnewline
 \hline
\end{tabular}

\end{document}

在此輸入影像描述

相關內容