I have a similar problem to this one: How to top align text and image in table?
What I want is a table essentially like this one over on Wikipedia, with an image in the first column and a textual explanation in the second column. The second column needs to be a paragraph-like column as it will have a bullet-pointed list. I would like the text to be vertically aligned with the top of the image.
My interpretation of the solution in the linked question using valign=T
from the adjustbox
package did not end well:
\begin{center}
\begin{tabular}{cc}
\textbf{Label} & \textbf{Meaning} \\ \midrule
\includegraphics[width=0.25\textwidth,valign=T]%
{./IST_Work/Hazard_Warning_Label-Explosive} &
\vspace{0pt}\begin{tabular}{@{}p{0.5\textwidth}@{}}Explosives\end{tabular}
\\
\includegraphics[width=0.25\textwidth,valign=T]%
{./IST_Work/Hazard_Warning_Label-Flammable_Gases} &
\vspace{0pt}\begin{tabular}{@{}p{0.5\textwidth}@{}}
Flammable
\begin{itemize}
\item Specifically, the number~2 at the bottom (and the plain red
background), identifies flammable gases
\end{itemize}
\end{tabular}
\end{tabular}
\end{center}
The issue with the second row hardly needs pointing out, but I'm not very impressed with the first row either, there is an unsightly, unnecessary grap above the image which I would prefer not to have.
Additional info
A previous version of my table had vertically centred text in the second column. I would prefer top-aligned text anyway, but I want to mention a problem I had when I went down this path as it may be relevant. This is what I ended up with:
\begin{center}
\begin{tabular}{cc}
\textbf{Label} & \textbf{Meaning} \\ \midrule
\noindent\parbox{0.25\textwidth}{%
\includegraphics[width=0.25\textwidth]%
{./IST_Work/Hazard_Warning_Label-Explosive}} &
\begin{tabular}{@{}p{0.5\textwidth}@{}}Explosives\end{tabular}
\\
\noindent\parbox{0.25\textwidth}{%
\includegraphics[width=0.25\textwidth]%
{./IST_Work/Hazard_Warning_Label-Flammable_Gases}} &
\begin{tabular}{@{}p{0.5\textwidth}@{}}
Flammable
\begin{itemize}
\item Specifically, the number~2 at the bottom (and the plain red
background), identifies flammable gases
\end{itemize}
\end{tabular}
\end{tabular}
\end{center}
In my opinion, these images are too close together. This can be fixed very nicely with \\[5em]
in this version. However, other solutions I experimented with could not be fixed in this way, and this fix tended to shift the text in the right hand column up a bit. Please do watch out for that, I would like to be able to add a nice little bit of white space between the rows. My current value of \arraystretch
is 1.25.
Please note, I may need the solution to work with longtable
, I've a feeling this table might spill onto a second page.
MWE
\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[export]{adjustbox}
\renewcommand{\arraystretch}{1.25}
\setlength{\tabcolsep}{0.8em}
\begin{document}
\begin{center}
\begin{tabular}{cc}
\textbf{Label} & \textbf{Meaning} \\ \midrule
\includegraphics[width=0.25\textwidth,valign=T]{example-image-a} &
\vspace{0pt}\begin{tabular}{@{}p{0.5\textwidth}@{}}Explosives\end{tabular}
\\
\includegraphics[width=0.25\textwidth,valign=T]{example-image-a} &
\vspace{0pt}\begin{tabular}{@{}p{0.5\textwidth}@{}}
Flammable
\begin{itemize}
\item Specifically, the number~2 at the bottom (and the plain red
background), identifies flammable gases
\end{itemize}
\end{tabular}
\end{tabular}
\end{center}
\end{document}
cellspace
package and the lengths\cellspacetoplimit
and\cellspacebottomlimit
.