3

I'm doing a table with images, and I would like to include the caption for each image and also I would like to align the rows.enter image description here

\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}

2 Answers2

2

The two main challenges are the Dimensions and the Result columns. I suggest using a p column for the Dimensions to wrap all three lines into one cell. For the Result column, the valign=m option from the adjustbox package can be used. Finally, the inner \hlines should all be replaced by \midrules for consistency.

\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}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
1

Here are two layouts, with captions,. One uses makecell only for padding and line breaks in cells and hhline, the other uses tabstackengine for another alignment of dimensions, which are grouped in a single cell in both cases:

\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} 

enter image description here enter image description here

Bernard
  • 271,350