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.

I want to place an image with includegraphics in a multirow table cell in a tabularx, and it shall be vertically aligned with the top of the cell.

Example with a rule instead of the image:

    \documentclass[11pt, a4paper]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[TS1, T1]{fontenc}
\usepackage{tabularx}
\usepackage{multirow}

\begin{document}


\begin{tabularx}{\textwidth}{@{}p{3cm} X r}  \hline
\multicolumn{2}{@{}l}{{\huge{}My Beautiful Text}} & 
\multirow{4}{*}{\rule{4cm}{6.5cm}%\includegraphics[height=6.5cm]{../../../2012_Bewerbungsfotos/2012-01_MB_Bewerbungsfoto_col.jpg}
}\\[24pt]
a & b\\[6pt]
a & b\\[6pt]
a & b\\[6pt]
a & b\\[6pt]
a & b
\end{tabularx}

\end{document}

Screenshot of PDF: enter image description here

How can I place the image directly at the \hline (identical with the top of the line where multirow is defined)?

EDIT to explain my "real" purpose:

  • In the real document, there is no hline at the top of the tabularx (I only added the hline to better view the top of the cells),
    but I'd like the inserted image to be aligned with the top of the text, as it does not look good IMHO if the image which spans over the whole height of the table starts below the text.
    (the original document contains personal data, so I tried to construct an artificial minimal example.)
  • the first line of the table is the only one with huge font size (heading), all the others are normalsize.
  • *
share|improve this question
    
What's the purpose of this? –  egreg Jan 24 '12 at 14:59
    
I've edited the question to explain what the "real" purpose is. –  Martin Jan 24 '12 at 16:22
    
See the edited answer. –  egreg Jan 24 '12 at 16:31
add comment

2 Answers

up vote 3 down vote accepted

The \huge command raises the row height, but \multirow doesn't respect it. It would work if you would place \huge before the tabular environment. This would affect the cells, but you could use >{\normalsize} for the column specifiers. Yet the rows would be higher.

\begingroup
\huge
\begin{tabularx}{\textwidth}{@{}>{\normalsize}p{3cm}>{\normalsize}X>{\normalsize}r@{}}\hline
\multicolumn{2}{@{}l}{{\huge{}My Beautiful Text}} & 
\multirow{4}{*}{\rule{4cm}{6.5cm}%\includegraphics[height=6.5cm]{../..
...
\end{tabularx}

\endgroup

multirow adjusted

Alternatively, use the optional fixup height argument for raising the image:

\multirow{nrows}[bigstruts]{width}[fixup]{text}

With a fixup height you could compensate that you actually use different row heights.

share|improve this answer
    
How can you avoid the increment of row height while maintaining the image height you desire. As i can see in your example above, there is a shift of about 1cm up of "My Beautiful Text" from the text a & b. –  azetina Jan 24 '12 at 15:14
    
That's why I recommend simply using a fixup value. 5pt works fine in the example. –  Stefan Kottwitz Jan 24 '12 at 15:25
    
@Stefan I finally chose the manual method with the fixup value, as there seems to be no "automatic" solution which does not involve typing by hand the height of the \huge text, if I understand your and egreg's solution –  Martin Jan 26 '12 at 21:46
add comment

A different approach is to put the image outside the tabular. We lower the image by its height minus the height of the strut in \huge size. The tabularx is "top aligned", so the image will be lined up with the first row; the depth of the box is made a bit longer (1ex) to help with the spacing underneath.

\newcommand{\foto}{%
  {\huge
   \raisebox{\dimexpr-\height+\ht\strutbox\relax}[0pt][\dimexpr\height-\ht\strutbox+1ex\relax]%
    {%
     \rule{4cm}{6.5cm}% put the image here
    }}%
}

\begin{document}

\noindent\begin{tabularx}{\dimexpr\textwidth-6.5cm\relax}[t]{@{}p{3cm} X}
\multicolumn{2}{@{}l}{\huge\strut My Beautiful Text} \\[24pt]
a & b\\[6pt]
a & b\\[6pt]
a & b\\[6pt]
a & b\\[6pt]
a & b
\end{tabularx}\foto

enter image description here

share|improve this answer
add comment

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.