我正在尝试将图像与表格对齐。该图像浮动在表格下方。
这是我的代码:
\multirow{4}{*}{\includegraphics[width=1.5in,height=0.8in]{IIIT}}
& & & \\
& Shubham Rathi & Male & \\
& Computer Science & B. Tech + MS (Computational Humanities) & \\
& IIIT Hyderabad & & \\
& & &
{\includegraphics[width=0.8in]{Icon}}
\end{tabular}
我想要的效果如下:
我做错了什么?我该如何改正?
这是 sharelatex 文件:https://www.sharelatex.com/project/57e542d03afea89017192474
答案1
正如@Ignasi 所说,您可以使用另一个multirow
方法来构造跨越多行的表格单元格。
在这里,我们合并第一列的四个单元格以插入第一幅图像,并对第四列执行相同操作以插入第二幅图像
\documentclass{article}
\usepackage{geometry}
\usepackage{multirow}
\usepackage{graphicx}
\geometry{left=0.75in,top=0.75in,right=0.7in,bottom=0.75in}
\begin{document}
\begin{table}[h]
\centering
\label{my-label1}
\bfseries
\begin{tabular}{llll}
\multirow{4}{*}{\includegraphics[width=1.5in,height=0.8in]{IIIT}}
& & &
\multirow{4}{*}{\includegraphics[width=0.8in]{Icon}} \\
& Shubham Rathi & Male & \\
& Computer Science & B. Tech + MS (Computational Humanities) & \\
& IIIT Hyderabad & & \\
\end{tabular}
\end{table}
\end{document}
答案2
tabular
您可以使用带有嵌套表格的表格,利用默认垂直对齐居中的事实。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\noindent\makebox[\textwidth]{% stick in the margins
\begin{tabular}{@{}ccc@{}}
\begin{tabular}{@{}c@{}}% left image
\includegraphics[width=1.5in,height=0.8in]{example-image-a}
\end{tabular}
&
\begin{tabular}{@{}ll@{}}% data in the center
Shubham Rathi & Male \\
Computer Science & B. Tech + MS (Computational Humanities) \\
IIIT Hyderabad & \\
\end{tabular}
\begin{tabular}{@{}c@{}}% left image
\includegraphics[width=0.8in,height=0.8in]{example-image-b}
\end{tabular}
\end{tabular}%
}% end of \makebox
\end{document}