3

My table looks like this:

table

The left column will contain words, like it is now, and in the right column I want to add these small pictures (some are a bit bigger than this one) in every row.

I have two problems however, as can be seen from the image linked:

  1. how do I center the text of the first column properly? Tight now it is a bit pushed to the bottom of the field.

  2. how do i center the image in the field? Right now it is pushed against the top wall of the table.

My code looks like this:

\begin{table}[h]
\centering
\begin{tabular}{l|l}
\textbf{Verb}   & \textbf{Example}   \\ \hline
``goes-to''         & \includegraphics[scale=1]{images/appendix/B/1.png} \\ \hline
``walks-to''        &     \\ \hline
``says to''         &        \\ \hline
``chats to''        &              
\end{tabular}
\caption{My caption}
\label{my-label}
\end{table}
2

Here is a solution with some vertical padding. The cellspace package is done for that: it defines a minimal vertical spacing at the top and the bottom of cells in columns with a specifier prefixed with S. With the makecell package, you can have line breaks in cells, thus allowing for several aimges in a single cell:

\documentclass{article}
\usepackage{cellspace, graphicx, makecell}
\renewcommand\cellspacetoplimit{3pt}
\renewcommand\cellspacebottomlimit{3pt}
\newcommand\rowincludegraphics[2][]{\raisebox{-0.45\height}{\includegraphics[#1]{#2}}}
\begin{document}
\begin{table}[h]
  \centering
  \begin{tabular}{c|Sl}
    \textbf{Verb} & \textbf{Example} \\ \hline
    ``goes-to'' & \rowincludegraphics[scale=0.1]{loupnorstein2} \\ \hline
    ``walks-to'' & \rowincludegraphics[scale=0.1]{loupnorstein2} \\ \hline
    ``says to'' & \rowincludegraphics[scale=0.1]{loupnorstein2} \\ \hline
    ``chats to'' & \makecell{\rowincludegraphics[scale=0.1]{loupnorstein2}\\[3.8ex]\rowincludegraphics[scale=0.1]{loupnorstein2}}
  \end{tabular}
  \caption{My caption}
  \label{my-label}
\end{table}
\end{document} 

enter image description here

  • I added an example code of two images in a cell, but for some reason, the snpshot I include doesn't display. – Bernard Apr 16 '15 at 21:36
3

You can use adjustbox package with export option. With this, you will get valin= as a key to \includegraphics. valign=c will do what you want.

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{array}
\begin{document}
  \begin{table}[h]
\centering
\setlength{\extrarowheight}{1em}
\begin{tabular}{c|l}
\textbf{Verb}   & \textbf{Example}   \\ \hline
``goes-to''         & \includegraphics[scale=0.1,valign=c]{example-image-a} \\[1em] \hline
``walks-to''        & \includegraphics[scale=0.1,valign=c]{example-image-a}    \\[1em] \hline
``says to''         &  \includegraphics[scale=0.1,valign=c]{example-image-a}      \\[1em] \hline
``chats to''        &\includegraphics[scale=0.1,valign=c]{example-image-a}
\end{tabular}
\caption{My caption}
\label{my-label}
\end{table}
\end{document}

enter image description here

  • Thank you. Does exactly what you said. However is there also a possibility to add like a couple of mm on the top and bottom? I don't really want it sticked to the top and bottom, i want a bit of free space. Thank you for your time – Dennis Apr 16 '15 at 16:21

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.