我在垂直对齐图像时遇到\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}