使用graphicx
和includegraphics
命令,我想在表格单元格中放置一个图形。此外,我使用 命令arraystretch
增加单元格的填充。不幸的是,如果我使用 all in common,我会得到一个奇怪的对齐行为:
第二行的文本也应该与单元格顶部对齐。我几乎只使用了原生乳胶材料,所以我不认为这与包相关性有关。我做错了什么吗?谢谢!!
这是我的 MWE:
\documentclass[12pt,twoside,openright,a4paper,oldfontcommands]{memoir}
\usepackage{tabularx}
\usepackage[pdftex]{graphicx}
\usepackage[table]{xcolor}
\begin{document}
\newlength{\convetionsSymbolWidth}
\setlength{\convetionsSymbolWidth}{3.5cm}
\newlength{\convetionsDescriptionWidth}
\setlength{\convetionsDescriptionWidth}{\textwidth}
\addtolength{\convetionsDescriptionWidth}{-\convetionsSymbolWidth}
\addtolength{\convetionsDescriptionWidth}{4\tabcolsep}
\begingroup
\renewcommand{\arraystretch}{1.9}
\begin{table}[h!]
\begin{tabular}{ >{\centering\arraybackslash}p{\convetionsSymbolWidth}
p{\convetionsDescriptionWidth} }
\hline\hline
Text & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
non ipsum nunc.\\
\arrayrulecolor{gray}\hline
\includegraphics[width=\marginparwidth]{structureIconArtifactsProxyWorkload.pdf}
\newline
{\footnotesize \emph{\textcolor{gray}{$\rightarrow$ Fig.~2.6, p.~31}}} &
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
non ipsum nunc.
\end{tabular}
\end{table}
\endgroup
\end{document}
答案1
使用
\raisebox{\dimexpr-\height+2ex}{%
\includegraphics[width=\marginparwidth]%
{structureIconArtifactsProxyWorkload.pdf}}
答案2
另一种方法是使用包adjustbox
并添加valign=t
(垂直对齐顶部)到\includegraphic
选项中。从包中删除 [demo]graphicx
以获得真实图像
代码
\documentclass[12pt,twoside,openright,a4paper,oldfontcommands]{memoir}
\usepackage{tabularx}
\usepackage[pdftex,demo]{graphicx} % remove demo for true image
\usepackage[table]{xcolor}
\usepackage[export]{adjustbox} % <--- new
\begin{document}
\newlength{\convetionsSymbolWidth}
\setlength{\convetionsSymbolWidth}{3.5cm}
\newlength{\convetionsDescriptionWidth}
\setlength{\convetionsDescriptionWidth}{\textwidth}
\addtolength{\convetionsDescriptionWidth}{-\convetionsSymbolWidth}
\addtolength{\convetionsDescriptionWidth}{4\tabcolsep}
\begingroup
\renewcommand{\arraystretch}{1.9}
\begin{table}[h!]
\begin{tabular}{ >{\centering\arraybackslash}p{\convetionsSymbolWidth}
p{\convetionsDescriptionWidth} }
\hline\hline
Text & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
non ipsum nunc.\\
\arrayrulecolor{gray}\hline
\includegraphics[valign=t,width=\marginparwidth]{structureIconArtifactsProxyWorkload.pdf}
\newline
{\footnotesize \emph{\textcolor{gray}{$\rightarrow$ Fig.~2.6, p.~31}}} &
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
non ipsum nunc.
\end{tabular}
\end{table}
\endgroup
\end{document}