我在表格中的两个不同列中有两个图像,在第三个表格中我想要一个文本,理想情况下是一个列表,但是当我写文本时它从最后一行开始并从那里向下,我希望文本从顶部开始。这是代码
\begin{tabular}{c c |p{0.30\linewidth}}
{\includegraphics[width=0.30\linewidth]{BoAwoNO2}}&
{\includegraphics[width=0.30\linewidth]{BoAwithNO}} &
Some text
\end{tabular}
以及输出的图像。
答案1
加载adjustbox
包可让您在执行命令时写入valign=c
或等。valign=t
\includegraphics{...}
代码
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{tabular}{c c |p{0.30\linewidth}}
{\includegraphics[valign=t, width=0.30\linewidth]{BoAwoNO2}}&
{\includegraphics[valign=t, width=0.30\linewidth]{BoAwithNO}} &
Some text text text text text text text text text text text text text text
\end{tabular}
\end{document}
输出
答案2
用于\vspace{0pt}
获取垂直对齐的不可见线:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{array}
\begin{document}
\begin{tabular}{*2{>{\vspace{0pt}}p{0.3\linewidth}}|>{\vspace{0pt}}p{0.3\linewidth}}
\includegraphics[width=\linewidth]{BoAwoNO2} &
\includegraphics[width=\linewidth]{BoAwithNO} &
Some text text text text text text text text text text text text text text
\end{tabular}
\end{document}
答案3
一种方法是针对图形文件在表格中使用嵌套的表格环境。
\documentclass[paper=a4,12pt]{scrbook}
\usepackage{blindtext}
\usepackage[demo]{graphicx}
\begin{document}
\begin{tabular}{c c |p{0.30\linewidth}}
\begin{tabular}{c}
{\includegraphics[width=0.30\linewidth]{BoAwoNO2}}
\end{tabular} &
\begin{tabular}{c}
{\includegraphics[width=0.30\linewidth]{BoAwithNO}}
\end{tabular}
& some text \tabularnewline
\end{tabular}
\end{document}
答案4
我只是介绍\tincludegraphics
将图像向下移动其高度减去文本支柱的高度。
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\newcommand\tincludegraphics[2][]{%
\raisebox{\dimexpr-\height+\ht\strutbox}{\includegraphics[#1]{#2}}%
}
\begin{document}
Smaller than image size:\\
\begin{tabular}{c c |p{0.30\linewidth}}
{\tincludegraphics[height=1in, width=0.30\linewidth]{BoAwoNO2}}&
{\tincludegraphics[width=0.30\linewidth]{BoAwithNO}} &
Text
\end{tabular}
Now larger than image size:\\
\begin{tabular}{c c |p{0.30\linewidth}}
{\tincludegraphics[height=.5in,width=0.30\linewidth]{BoAwoNO2}}&
{\tincludegraphics[width=0.30\linewidth]{BoAwithNO}} &
\scriptsize\lipsum[4]
\end{tabular}
\end{document}
如果需要居中图像,我定义\cincludegraphics
... 而不是使用p
列,我使用\parbox
带有[c]
居中选项的。这样,文本和图像将始终彼此居中。
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\newcommand\cincludegraphics[2][]{%
\raisebox{\dimexpr-.5\height+.5\ht\strutbox}{\includegraphics[#1]{#2}}%
}
\begin{document}
Smaller than image size:\\
\begin{tabular}{c c |c}
{\cincludegraphics[height=1in, width=0.30\linewidth]{BoAwoNO2}}&
{\cincludegraphics[width=0.30\linewidth]{BoAwithNO}} &
\parbox{0.30\linewidth}{Text}
\end{tabular}
Now larger than image size:\\
\begin{tabular}{c c |c}
{\cincludegraphics[height=.5in,width=0.30\linewidth]{BoAwoNO2}}&
{\cincludegraphics[width=0.30\linewidth]{BoAwithNO}} &
\parbox{0.30\linewidth}{\scriptsize\lipsum[4]}
\end{tabular}
\end{document}