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}
  • Welcome to TeX.SX! Can you please provide a minimal working example (MWE) of what you have so far? This will help us help you. Also, we do not have your images available. Please consider providing them, or using example images. – sk8forether Jun 15 '17 at 17:13
  • Out of topic: I suggest you to have a look at the booktabs package. You might want to redesign your table according to best practices detailed in its documentation. – ebosi Jun 15 '17 at 17:15
  • Can you mention the packages you have used @Mark Spring – Biki Teron Jun 15 '17 at 17:17
  • @Biki Teron. I don't really know because I have a template from the Institute, but I have also included \usepackage{multirow, array}. That's the first time I use TeX... – Mark Spring Jun 15 '17 at 17:48
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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.