
考慮以下 MWE:
\documentclass{report}
\usepackage{tabularx}
\usepackage{graphicx}
\begin{document}
\begin{tabular}{|c|c|}
\hline a & b \\ \hline
\rotatebox[origin=c]{90}{Hello} & d \\ \hline
e & f \\ \hline
\end{tabular}
\vspace{1cm}
\begin{tabular}{|c|c|}
\hline a & b \\ \hline
\rotatebox[origin=c]{90}{There} & \includegraphics[height=2cm]{dummy.png} \\ \hline
e & f \\ \hline
\end{tabular}
\end{document}
在第一個表格的第二行中,旋轉的文字(“Hello”)與其相鄰單元格的文字(“d”)垂直對齊。
在第二個表中,垂直對齊有問題:文字似乎在底部對齊[或旋轉前左對齊],並且圖形下方有空格。在這種情況下如何獲得垂直對齊呢?
我發現這個相關問題但我的問題似乎是由在相鄰單元格中添加圖像引起的。
答案1
對於第二個帶有圖像的表:
\documentclass{report}
\usepackage{tabularx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{tabular}{|c|c|}
\hline a & b \\ \hline
\rotatebox[origin=c]{90}{There}
& \includegraphics[height=2cm,valign=c,
margin= 0pt 3pt 0pt 3pt]{example-image-duck} \\
\hline
e & f \\
\hline
\end{tabular}
\end{document}