在具有可變單元格高度的表格中垂直底部對齊圖像

在具有可變單元格高度的表格中垂直底部對齊圖像

我在垂直對齊圖像時遇到\adjustimage問題調整盒包在一個表中。我正在自動創建許多表格,它們具有相同的佈局,其中一個 X 列具有可變長度的文本,然後是中間的一些短列,最後一列具有較小高度的圖像。該影像應始終與單元格底部對齊。

問題似乎是第一個 X 列,因為有時文字適合一行,有時它會分成兩行,而且我找不到一種方法始終使圖像適合 X 列的底線,無論文字的數量如何該單元格中的行。

因為我事先不知道 X 列中文字的長度,所以我正在尋找一種解決方案,無論文字長度如何,該解決方案都有效。

\documentclass[a4paper, 12pt]{scrartcl}

\usepackage{adjustbox}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{.8\textwidth}{X r r p{50mm}}
\hline
here is some text over two lines & N & M & \adjustimage{width = 50mm, height = 2mm}{example-image}\\
\hline
one line text & N & M & \adjustimage{width = 50mm, height = 2mm}{example-image}\\
\hline
\end{tabularx}

\end{document} 

在此輸入影像描述

答案1

其中之一?

\documentclass[a4paper, 12pt]{scrartcl}

\usepackage{adjustbox}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{.8\textwidth}{X r r p{50mm}}
\hline
here is some text over two lines & N & M &\mbox{}\newline \adjustimage{width = 50mm, height = 2mm}{example-image}\\
\hline
one line text & N & M & \adjustimage{width = 50mm, height = 2mm}{example-image}\\
\hline
\end{tabularx}
\vskip1cm

\bgroup
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}b{#1}}
\begin{tabularx}{.8\textwidth}{X r r p{50mm}}
\hline
here is some text over two lines & N & M & \adjustimage{width = 50mm, height = 2mm}{example-image}\\
\hline
one line text & N & M & \adjustimage{width = 50mm, height = 2mm}{example-image}\\
\hline
\end{tabularx}
\egroup

\end{document} 

在此輸入影像描述

相關內容