Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using the graphicx and the includegraphics command, I want to place a figure in a table cell. In addition, I use the arraystretch command the increase the padding of cells. Unfortunately, I get a strange alignment behavior, if I use all in common:

enter image description here

The text in the second row should also be aligned at the cell's top. I used nearly only native latex stuff, so I don't think it is something about package correlations. Am I doing something wrong? Thank you!!

Here is my MWE:

\documentclass[12pt,twoside,openright,a4paper,oldfontcommands]{memoir}

\usepackage{tabularx}
\usepackage[pdftex]{graphicx}
\usepackage[table]{xcolor}

\begin{document}

\newlength{\convetionsSymbolWidth}
\setlength{\convetionsSymbolWidth}{3.5cm}

\newlength{\convetionsDescriptionWidth}
\setlength{\convetionsDescriptionWidth}{\textwidth}
\addtolength{\convetionsDescriptionWidth}{-\convetionsSymbolWidth}
\addtolength{\convetionsDescriptionWidth}{4\tabcolsep}

\begingroup
    \renewcommand{\arraystretch}{1.9}
    \begin{table}[h!]
        \begin{tabular}{ >{\centering\arraybackslash}p{\convetionsSymbolWidth}
           p{\convetionsDescriptionWidth} }
            \hline\hline

            Text & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
            placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
            nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
            varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
            non ipsum nunc.\\

            \arrayrulecolor{gray}\hline     

            \includegraphics[width=\marginparwidth]{structureIconArtifactsProxyWorkload.pdf}
            \newline
            {\footnotesize \emph{\textcolor{gray}{$\rightarrow$ Fig.~2.6, p.~31}}} &        
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
            placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
            nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
            varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
            non ipsum nunc.
        \end{tabular}
    \end{table}
\endgroup

\end{document}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

use

 \raisebox{\dimexpr-\height+2ex}{%
     \includegraphics[width=\marginparwidth]%
          {structureIconArtifactsProxyWorkload.pdf}}
share|improve this answer
    
Great, thank you, this works! Could you also explain why :-)? –  strauberry Jul 21 at 13:37
1  
the image is for TeX "one big character" which has the same baseline as the first line in the next cell. Compare {\Huge X} x which shows the same behaviour. –  Herbert Jul 21 at 13:40

Another alternative is use of package adjustbox and add valign=t (vertically align top) into the \includegraphic option. Remove [demo] from the graphicx package for true image

enter image description here

Code

\documentclass[12pt,twoside,openright,a4paper,oldfontcommands]{memoir}

\usepackage{tabularx}
\usepackage[pdftex,demo]{graphicx}           % remove demo for true image
\usepackage[table]{xcolor}
\usepackage[export]{adjustbox}               % <--- new 
\begin{document}

\newlength{\convetionsSymbolWidth}
\setlength{\convetionsSymbolWidth}{3.5cm}

\newlength{\convetionsDescriptionWidth}
\setlength{\convetionsDescriptionWidth}{\textwidth}
\addtolength{\convetionsDescriptionWidth}{-\convetionsSymbolWidth}
\addtolength{\convetionsDescriptionWidth}{4\tabcolsep}

\begingroup
    \renewcommand{\arraystretch}{1.9}
    \begin{table}[h!]
        \begin{tabular}{ >{\centering\arraybackslash}p{\convetionsSymbolWidth}
           p{\convetionsDescriptionWidth} }
            \hline\hline

            Text & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
            placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
            nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
            varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
            non ipsum nunc.\\
            \arrayrulecolor{gray}\hline   

 \includegraphics[valign=t,width=\marginparwidth]{structureIconArtifactsProxyWorkload.pdf}
           \newline
            {\footnotesize \emph{\textcolor{gray}{$\rightarrow$ Fig.~2.6, p.~31}}} &        
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
            placerat arcu lorem, at volutpat ante lobortis in. Nullam at velit et
            nisi pellentesque molestie. Pellentesque pretium egestas nunc vel
            varius. Proin non augue id arcu condimentum sodales vel ut leo. Morbi
            non ipsum nunc. 
        \end{tabular}
    \end{table}
\endgroup

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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