我正在制作一个带有图像的表格,我想为每张图片添加标题,同时我想对齐行。
\begin{table} [ht]
\centering
\begin{tabular}{||c c c c ||}
\toprule
Sample number & Dimensions & Result & Observations \\ [0.5ex]
\midrule
H1E & $T:29.37\pm0.01$ mm &
\raisebox{-\totalheight}{\includegraphics[width=0.15\textwidth]{h1e.jpg}} &
Valid test\\
& $L:29.00\pm0.01$ mm & & \\
& W:$33.90\pm0.01$ mm & & \\
\hline
H2E & $T:29.40\pm0.01$ mm &
\raisebox{-\totalheight}{\includegraphics[width=0.15\textwidth]{h2e.jpg}} &
Invalid test, no parallelism\\
& $L:28.50\pm0.01$ mm & & \\
& W:$34.41\pm0.01$ mm & & \\
\hline
H3E & $T:29.17\pm0.01$ mm &
\raisebox{-\totalheight}{\includegraphics[width=0.15\textwidth]{h3e.jpg}} &
Valid test\\
& $L:27.50\pm0.01$ mm & & \\
& W:$30.39\pm0.01$ mm & & \\
\hline
H4E & $T:30.55\pm0.01$ mm &
\raisebox{-\totalheight}{\includegraphics[width=0.15\textwidth]{h4e.jpg}} &
Valid test\\
& $L:29.94\pm0.01$ mm & & \\
& W:$31.70\pm0.01$ mm & & \\
\bottomrule
\end{tabular}
\caption{Static compression tests in axial direction of honeycomb}
\label{tab:statcomp}
\end{table}
答案1
两个主要挑战是Dimensions
和Result
列。我建议使用p
列来Dimensions
将所有三行包装到一个单元格中。对于Result
列,可以使用包valign=m
中的选项。最后,为了保持一致性,内部的s 应该全部替换为s。adjustbox
\hline
\midrule
\documentclass[a4paper]{article}
\usepackage{graphicx, array, booktabs}
\usepackage[export]{adjustbox}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{cm{.25\textwidth}cc}
\toprule
Sample number & Dimensions & Result & Observations \\ \midrule
H1E & $T:29.37\pm0.01$ mm \newline
$L:29.00\pm0.01$ mm \newline
W:$33.90\pm0.01$ mm &
\includegraphics[width=0.15\textwidth,valign=m]{h1e.jpg} &
Valid test \\ \midrule
%
H2E & $T:29.40\pm0.01$ mm \newline
$L:28.50\pm0.01$ mm \newline
W:$34.41\pm0.01$ mm &
\includegraphics[width=0.15\textwidth,valign=m]{h2e.jpg} &
Invalid test, no parallelism \\ \midrule
%
H3E & $T:29.17\pm0.01$ mm \newline
$L:27.50\pm0.01$ mm \newline
W:$30.39\pm0.01$ mm &
\includegraphics[width=0.15\textwidth,valign=m]{h3e.jpg} &
Valid test\\ \midrule
%
H4E & $T:30.55\pm0.01$ mm \newline
$L:29.94\pm0.01$ mm \newline
W:$31.70\pm0.01$ mm &
\includegraphics[width=0.15\textwidth,valign=m]{h4e.jpg} &
Valid test \\ \bottomrule
\end{tabular}
\caption{Static compression tests in axial direction of honeycomb}
\label{tab:statcomp}
\end{table}
\end{document}
答案2
这里有两个布局,带有标题。一个makecell
仅用于单元格中的填充和换行符hhline
,另一个用于 tabstackengine
另一种尺寸对齐,在两种情况下,尺寸都分组在一个单元格中:
\documentclass{article}
\usepackage{amsmath}
\usepackage{makecell, booktabs, caption, hhline}
\captionsetup{font =footnotesize, skip=6pt}
\usepackage{graphicx}
\usepackage{tabstackengine}
\begin{document}
\begin{table} [!ht]
\centering%
\renewcommand{\cellalign}{lt}
\setcellgapes{5pt}\makegapedcells
\setstackgap{L}{3.5ex}
\begin{tabular}{||c >{\stackMath}ccc ||}
\hhline{----}
\makecell{Sample\\ number} & Dimensions (mm)& Result & Observations \\ [0.5ex]
\hhline{||----||}
H1E & {$\tabbedLongunderstack[l]{%
T: & 29.37\pm0.01\\ L: & 29.00\pm0.01\\ W: & 33.90\pm0.01}$} &
\raisebox{\dimexpr 1.6ex-\height}{\includegraphics[width=0.2\textwidth]{vent_cat}} &
Valid test\\
\hhline{||----||}
H2E &%
{$\tabbedLongunderstack[l]{%
T: & 29.40\pm0.01 \\ L: & 28.50\pm0.01 \\ W: & 34.41\pm0.01}$} &
\raisebox{\dimexpr 2ex-\height}{\parbox{0.2\textwidth}{\includegraphics[width=0.2\textwidth]{vent_cat}%\\
\centering\captionof{figure}{\\Ventriloquist Cat}}} &
Invalid test, no parallelism\\
\hhline{||----||}
H3E & {$\tabbedLongunderstack[l]{T: & 29.17\pm0.01 \\ L: & 27.50\pm0.01 \\ W: & 30.39\pm0.01}$} &
\raisebox{\dimexpr 2ex-\height}{\includegraphics[width=0.2\textwidth]{vent_cat}} &
Valid test\\%
\hhline{||----||}
H4E & {$\tabbedLongunderstack[l]{T: &30.55\pm0.01 \\ L: &\phantom{0}9.94 \pm0.01 \\ W:&31.70\pm0.01 }$} &
\raisebox{\dimexpr 2ex-\height}{\includegraphics[width=0.2\textwidth]{vent_cat}} &
Valid test\\
\hhline{----}
\end{tabular}
\caption{Static compression tests in axial direction of honeycomb}
\label{tab:statcomp}
\end{table}
\begin{table} [!ht]
\centering%
\renewcommand{\cellalign}{lt}
\setcellgapes{5pt}\makegapedcells
\begin{tabular}{c >{$}c<{$}cc}
\toprule
\makecell{Sample \\ number} & \text{Dimensions (mm)} & Result & Observations \\ [0.5ex]
\midrule
H1E & \makecell{T: 29.37\pm0.01\\ L: 29.00\pm0.01\\ W: 33.90\pm0.01} &
\raisebox{\dimexpr 2ex-\height}{\parbox{0.3\textwidth}{\centering\includegraphics[width=0.25\textwidth]{sendak}\captionof{figure}{Where the Wild Things are}}} &
Valid test\\
\addlinespace[3ex]
H2E & \makecell{T: 29.40\pm0.01 \\ L: 28.50\pm0.01 \\ W: 34.41\pm0.01} &
\raisebox{\dimexpr 2ex-\height}{\includegraphics[width=0.25\textwidth]{sendak}} &
Invalid test, no parallelism\\
\addlinespace[3ex]
H3E & \makecell{T: 29.17\pm0.01 \\ L: 27.50\pm0.01 \\ W: 30.39\pm0.01} &
\raisebox{\dimexpr 2ex-\height}{\includegraphics[width=0.25\textwidth]{sendak}} &
Valid test\\%
\addlinespace[3ex]
H4E & \makecell{T: 30.55\pm0.01 \\ L: 9.94\pm0.01 \\ W: 31.70\pm0.01 } &
\raisebox{\dimexpr 2ex-\height}{\includegraphics[width=0.25\textwidth]{sendak}} &
Valid test\\\bottomrule
\end{tabular}
\caption{Static compression tests in axial direction of honeycomb}
\label{tab:statcomp-1}
\end{table}
\end{document}