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.

Is it possible to place a figure within a multirow cell? The vertical alignment is ruined. Does it have to do anything with tikz's bounding boxes?

The following mwe produces the following result

Edit

Clarification after Gonzalo Medina's answer.

Why is it necessary to restrict the width of the figure? The figure is a box. Is it not possible to just fit this box in the merged cell? I have some figures that have to be rather big in order to be viewable.

Edit 2

After G.M.'s comment I realized that multirow works only horizontally and not vertically. Unfortunately, I can't make the figures much smaller because they don't look nice. So I have to increase the height of the unmerged rows.

Perhaps a work around would be to calculate the height of the *.pdf, divide it by the number of unmerged rows and use \vphantom{} on the unmerged cells to increase their height. Or some kind of a box. Probably increasing the arraystretch would work too if there are no rows without figures.

Is there a more robust way to handle this sitution?

\documentclass[]{article}
\usepackage{amsmath}

\usepackage{graphicx}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabu}

\begin{document}
\begin{table}
\centering
\renewcommand{\arraystretch}{2}
\begin{tabu}{ccc}
    \toprule
    Sections & Axis & Imperfections\\
    \midrule
    \multirow{2}{*}{\includegraphics[width=3cm]{circular_hollow.pdf}} & $y-y$ & $\dfrac{L}{200}$ \\
                                                                               & $z-z$ & $\dfrac{L}{150}$ \\
    \bottomrule
\end{tabu}
\end{table}

\end{document}

circular_hollow.pdf is produced by the following file

\documentclass[a4paper,12pt,fleqn]{article}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames,svgnames]{xcolor}  
\usepackage{mathtools}

\usepackage{tkz-tab,tkz-euclide}
\usetkzobj{all} % all the objects

\usepackage[xetex,active,tightpage]{preview}
\PreviewEnvironment[]{tikzpicture}
\PreviewEnvironment[]{pgfpicture}

\begin{document}
\begin{tikzpicture}[>=stealth]
\tkzInit[xmin=-4.5, xmax=4.5, ymin=-4.5, ymax=4.5]
\useasboundingbox(-4.5, -4.5) rectangle (4.5, 4.5);

% Concrete and steel section
\tkzDefPoints{0/0/O, 0/3/R}
\tkzDrawCircle[fill=black!10,line width=8pt](O,R)

% Steel Rebars + Stirrups
\tkzDefPoints{0/0/O, 0/2.3/R}
\tkzDrawCircle[fill=black!30,line width=2pt](O,R)

\foreach \a in {0,30,...,360}{%
    \tkzDefPoint(\a:2){A}
    \tkzDrawPoint(A)
}

% Axes
\tkzDefPoints{0/0/O, -4/0/Y, 0/-4/Z}
\tkzLabelPoint[left](Y){\huge $y$}
\tkzLabelPoint[below](Z){\huge $z$}

\tkzDrawSegments[line width=2pt,->](O,Y O,Z)

\end{tikzpicture}
\end{document}
share|improve this question
    
This question is similar, but the answers dont use multirow tex.stackexchange.com/questions/30488/… –  pmav99 Aug 10 '12 at 20:57
    
I don't understand your question; \multirow places the material without performing any scaling; since you are usng \multirow{2}{*}{...}, the width of the merged cell will be the natural width of the image, but the height of the merged cell is still the same as it was without the image so if you don't reduce the size of the image, the image will protrude and you will get an overfull \vbox warning. –  Gonzalo Medina Aug 10 '12 at 21:32
    
I see. So multirow works only horizontally, not vertically. I haven't realized that. Thank you. –  pmav99 Aug 10 '12 at 21:36
add comment

2 Answers

up vote 6 down vote accepted

A workaround I've just seen possible, without modifying the graphics, is this:

  • Include package bigstrut
  • Use the other parameters of multirow:
    • bigstruts: value 2.
    • fixup: value 2mm
  • Add a call of \bigstrut for each row being spanned.
  • Increasing \arraystretch to 3.

The code for the main tex file is this:

\documentclass[]{article}
\usepackage{amsmath}

\usepackage{graphicx}

\usepackage{booktabs}
\usepackage{multirow,bigstrut}
\usepackage{tabu}

\begin{document}
\begin{table}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabu}{ccc}
    \toprule
    Sections & Axis & Imperfections\\
    \midrule
    \multirow{2}[2]{*}[2mm]{\includegraphics[width=3cm]{circular_hollow.pdf}} & $y-y$ & $\dfrac{L}{200}$ \bigstrut \\
                                                                              & $z-z$ & $\dfrac{L}{150}$ \bigstrut \\
    \bottomrule
\end{tabu}
\end{table}

\end{document}

enter image description here

share|improve this answer
    
Thank you. It doesn't work for arbitrary width values, but it works. If nothing else comes up, I will accept your answer. –  pmav99 Aug 11 '12 at 14:46
add comment

For those wondering how to put images in tables in general, the salient point is the bracketed fixup after the {*} in \multirow:

\multirow{2}{*}[fixup]{\includegraphics[width=2in]{...}}

For example:

\multirow{2}{*}[0.5in]{\includegraphics[width=2in]{...}}

By adjusting the fixup you can avoid Latex's default behavior of putting the image way too low in the table.

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.