1

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:

enter image description here

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

enter image description here

\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}
1
  • 1
    To add more space between the images, you might want to have a look at the cellspace package and the lengths \cellspacetoplimit and \cellspacebottomlimit. – leandriis Sep 5 '19 at 21:05
2

Abd with this simpler code?

\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}{cp{0.5\textwidth}}
    \textbf{Label} & \textbf{Meaning} \\ \midrule
    \includegraphics[width=0.25\textwidth,valign=t]{example-image-a} &
   Explosives
    \\ \addlinespace[2ex]
    \includegraphics[width=0.25\textwidth,valign=t]{example-image-a} &
      Flammable
      \begin{itemize}
        \item Specifically, the number~2 at the bottom (and the plain red
        background), identifies flammable gases
      \end{itemize}
  \end{tabular}
\end{center}

\end{document} 

enter image description here

3
  • Very nice =) What was I doing wrong? – Au101 Sep 5 '19 at 22:20
  • 1
    Not sure, but I would say the nested tabulars added some vertical spacing (and some complexity in the code). – Bernard Sep 5 '19 at 22:49
  • Must have been the result of earlier experiments. Thanks! – Au101 Sep 5 '19 at 23:12

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.