我正在尝试创建一个以四个数字居中的表格,并且下一行的文本也应居中。
如您所见,parboxes 未居中,我尝试了几种方法来解决这个问题,但都无法解决。感谢您的建议!
\begin{table}
\centering
\caption{xxx}
\label{tab:xxx}
\begin{tabular}{p{2.5cm}p{2.5cm}p{2.5cm}p{2.5cm}} %
\hline
\parbox[c]{1em}{\includegraphics[height=0.5in]{example-image-b}}
& \parbox[c]{1em}{\includegraphics[height=0.5in]{example-image-b}}
& \parbox[c]{1em}{\includegraphics[height=0.5in]{example-image-b}}
& \parbox[c]{1em}{\includegraphics[height=0.5in]{example-image-b}}\\
\multicolumn{1}{|c|}{Part} & \multicolumn{1}{|c|}{Impactor} & \multicolumn{1}{c|}{Scalp} &\multicolumn{1}{c|}{Sphere}\\
x & x & x & x\\
x & x & x & x\\
x & x & x & x\\
\end{tabular}
\end{table}
答案1
简单就是力量。那么只使用 怎么样\hfil
?
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{tabular}{|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|} %
\hfil\includegraphics[height=0.5in]{example-image-a} &
\hfil\includegraphics[height=0.5in]{example-image-b} &
\hfil\includegraphics[height=0.5in]{example-image-c} &
\hfil\includegraphics[height=0.5in]{example-image} \\
\hfil Part & \hfil Impactor & \hfil Scalp & \hfil Sphere \\
\end{tabular}
\end{document}
答案2
我不确定我是否正确理解了你的问题,但让我尝试一下:
代码相当简单:
\documentclass{article}
\usepackage{graphicx}
\usepackage{array, booktabs}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{table}
\centering
\caption{xxx}
\label{tab:xxx}
\begin{tabular}{*{4}{C{2.5cm}}} %
\toprule
\includegraphics[height=0.5in]{example-image-b}
& \includegraphics[height=0.5in]{example-image-b}
& \includegraphics[height=0.5in]{example-image-b}
& \includegraphics[height=0.5in]{example-image-b} \\
Part & Impactor & Scalp & Sphere \\
x & x & x & x\\
x & x & x & x\\
x & x & x & x
\end{tabular}
\end{table}
\end{document}