2

I am working on a lab manual for a course that I teach. In the lab safety chapter, I want to have a table of the GHS pictograms and their descriptions. I plan for this to be a longtable so a page break can happen inside the table if needed. However, when I do this, I can only get the description text in the second column to align to the vertical center of the graphic (using an m column) or the bottom of the graphic (using either the p or b column). What is peculiar is that I get the same behavior with the graphic in either a p or b column. How do I get the the text in the second column to be aligned to to the top of the graphic or the top of the cell.

\documentclass{book}
\usepackage{longtable}
\usepackage{array}
\usepackage{graphicx}
\begin{document}
I expected this one to align the second column to the top of the graphic.
\begin{longtable}{|p{1in}| >{\raggedright}p{4.5in}|}\hline
    p column & p column \tabularnewline \hline
    \includegraphics[width=1in]{pictogram.png} 
    & This pictogram is for substances that have certain properties in certain situations. 
    This pictogram indicates a level and type of hazard or risk when using the substance. 
    \tabularnewline \hline
\end{longtable} 

This one behaves like I expect. 
\begin{longtable}{|m{1in}| >{\raggedright}p{4.5in}|}\hline
    m column & p column \tabularnewline \hline
    \includegraphics[width=1in]{pictogram.png} 
    & This pictogram is for substances that have certain properties in certain situations. 
    This pictogram indicates a level and type of hazard or risk when using the substance. 
    \tabularnewline \hline
\end{longtable} 

This one behaves like I expect.
\begin{longtable}{|b{1in}| >{\raggedright}p{4.5in}|}\hline
    b column & p column \tabularnewline \hline
    \includegraphics[width=1in]{pictogram.png} 
    & This pictogram is for substances that have certain properties in certain situations. 
    This pictogram indicates a level and type of hazard or risk when using the substance. 
    \tabularnewline \hline
\end{longtable} 

This one is close to what I want, but will not look correct with longer text.
\begin{longtable}{|m{1in}| >{\raggedright}b{4.5in}|}\hline
    m column & b column \tabularnewline \hline
    \includegraphics[width=1in]{pictogram.png} 
    & This pictogram is for substances that have certain properties in certain situations. 
    This pictogram indicates a level and type of hazard or risk when using the substance. 
    \tabularnewline \hline
\end{longtable} 
\end{document}

enter image description here

1 Answers1

1
\documentclass{book}
\usepackage{array, longtable}
\usepackage[export]{adjustbox}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}

I expected this one to align the second column to the top of the graphic.
\begin{longtable}{|p{1in}| >{\raggedright}p{4.5in}|}\hline
    p column & p column \tabularnewline \hline
    \includegraphics[width=1in,valign=t, margin=0pt 3pt 0pt 3pt]{example-image-duck}
    & This pictogram is for substances that have certain properties in certain situations.
    This pictogram indicates a level and type of hazard or risk when using the substance.
    \tabularnewline \hline
    \includegraphics[width=1in,valign=t, margin=0pt 3pt 0pt 3pt]{example-image-duck}
    & \lipsum*[1]
    \tabularnewline \hline
\end{longtable}
\end{document}

enter image description here

edit: for shorter code (when you like to insert many images), you can define new command, for example \insertimage as

\newcommand\insertimage[1]{\includegraphics[width=1in,valign=t, margin=0pt 3pt 0pt 3pt]{#1}}

and than you it in your table as

\insertimage{example-image-duck} & \lipsum*[1]
Zarko
  • 296,517
  • I tried using adustbox after reading the other question, and it threw an error on compiling the document. I ended up wrapping the image in \raisebox to reset the image baseline to the top. – Ben Norris Aug 01 '18 at 02:10
  • @BenNorris, provided answer works. this means that you change something. from "threw error" i cant say anything where you made some error. – Zarko Aug 01 '18 at 06:10
  • I get the following error: Package xkeyval Error: 'valign' undefined in families 'Gin'. – Ben Norris Aug 02 '18 at 02:47
  • @BenNorris, do you by accidentally remove option export at loading of the package adjustbox? without it proposed solution doesn't work. – Zarko Aug 02 '18 at 07:08