latexmultirow

Latex: Problem with Multirow



I am creating a table with mulitrow but I am getting a problem. As far as I understand, this is the form of the multirow:

\multirow{count}{alignment}{content}

where count is the number of rows to merge, alignment is either l, c, r, or *, and content is the content of the row. I tried the following:

\multirow{3}{*}{Framing}

but I am getting a problem. Rather than seeing the word "Framing" in the cell, I see "3*Framing" which gives the indication that the \multirow element isn't working. Any idea?

Also, how is it possible to align a text in a cell vertically?

UPDATE: I thought the \usepackage{multirow} would solve it, but I still see problems: First, I can't make vertical alignments. Second, I get some strange thing with the "Framing" cell. Instead of getting "Framing" aligned to the left, I get one virtual row containing the letter "l" and then after two virtual rows I get the word "Framing"!! It is something like this:

______________
|     l       |
|             |
|     Framing |
|             |
|             |
|             |
|             |
______________

This is my table for those who asked about it:

\begin{table*}\tiny
    \centering
    \begin{tabular}{|c|c|c|c|c|p{2in}|}
        \hline

        Rule & Factor & Best Value & \Delta_t & \Delta_{do} & Comments \\

        \hline

        % Diagonal Dominance Rule
        \multirow{3}{*}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between the prominent line of the object and
                                                                          the diagonal lines \\                                     % TODO: What object? Make sure it is clear.
                                            & Line Distance & 0 & 0.25 & 1 & The distance, in screen coordinates, from the
                                                                             prominent line of the object to the diagonal lines. \\ % TODO: Need to define screen coordinates
                                            & Corner Distances & 0 & 0.1 & 0.7 & The distance, in screen coordinates, from the
                                                                                 end of the prominent line of the object to the corners of the screen. \\

        \hline

        % Framing Rule
        \multirow{4}{l}{Framing} & Left Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance between the
        left side of the frame covering the object and the left or the right side of the intended frame, whichever closer. \\
                                & Right Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance between the
        right side of the frame covering the object and the left or the right side of the intended frame, whichever closer. \\
                                & Top Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance between the
        top side of the frame covering the object and the upper or the lower side of the intended frame, whichever closer. \\
                                & Bottom Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance between the
        bottom side of the frame covering the object and the upper or the lower side of the intended frame, whichever closer. \\

        \hline
    \end{tabular}
    \caption{The factors of each rule and their parameters.}
    \label{table:factors}
\end{table*}

Regards,
Rafid


Solution

    1. Did you put \usepackage{multirow} at the beginning of your document?

    2. There are probably good examples out there to follow. I've never used this package but in a short time (seconds) was able to find this PAGE via google. Does following along with that example help you?


    Update: after seeing your actual table, I hate to say it but think your spacing glitch is due to the spill over in the "comments" column into multiple lines. I truncated your comments and got this (column 1 is now vertically centered as desired):

    \begin{table*}\tiny
      \centering
      \begin{tabular}{|c|c|c|c|c|p{3cm}|}
        \hline
        Rule & Factor & Best Value & \Delta_t & \Delta_{do} & Comments \\
        \hline
    
        % Diagonal Dominance Rule
        \multirow{3}{*}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between... \\
                                            & Line Distance & 0 & 0.25 & 1 & The distance, in... \\
                                            & Corner Distances & 0 & 0.1 & 0.7 & The distance, in... \\
        \hline
    
        % Framing Rule
        \multirow{4}{*}{Framing} & Left Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance... \\
                                 & Right Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance... \\
                                 & Top Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance... \\
                                 & Bottom Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance... \\
        \hline
      \end{tabular}
    
      \caption{The factors of each rule and their parameters.}
      \label{table:factors}
    
    \end{table*}
    

    Regarding the {l} argument, I think the link I posted originally is perhaps wrong. LaTeX spits out some errors for me when I try replacing * with l for the \multirow argument. I get this on a test table:

    ! Missing number, treated as zero.
    <to be read again> 
                       l
    l.12 \multirow{4}{l}{Batch}
                                & MM & Min-Min \\
    ! Illegal unit of measure (pt inserted).
    <to be read again> 
                       l
    l.12 \multirow{4}{l}{Batch}
                                & MM & Min-Min \\
    

    After finding THIS, I think the second argument in \multirow is not for an alignment but for a width. The LyX wiki linked says the format is like so:

    \multirow{number of rows}{cell width}{cell entry}
    

    We've been assuming that {cell width} was actuall {alignment} and I think the link from earlier makes that confusing. See the note at the LyX wiki about spacing; you can use the following where needed to make it do your bidding:

    \renewcommand{\multirowsetup}{\centering}
    

    And replace \centering with \raggedleft or \raggedright where needed. I still think you're going to run into trouble with the multiple lines. I've at least shown that ditching them makes the spacing work as desired... how to force them to be centered with your default example is beyond me, I'm afraid. But perhaps now you know where the problem lies?

    I guess if you really, really, really wanted to you could split your sentence up, figure out how many rows it takes, and adjust your \multirow argument accordingly for the increase in rows. Though you'd also probably need a nested multirow structure:

    |                   | item 1, 2 rows | comment 1 line 1              |
    |  multirow, 4 rows |                | comment 1 line 2 (spill over) |
    |                   | item 2, 2 rows | comment 2 line 1              |
    |                   |                | comment 2 line 2 (spill over) |
    

    Does that make sense? Column 1 would span all rows for its section, subsequent rows would span the number of rows required by the split up comments, and each line needed by the comments (some take up 3 or 4) would be on their own separate lines and just appear to be continuous. Not sure if the sentence spacing would look weird, though.

    Nuff rambling. There's your food for thought.


    One Last Update: One last hope way to go about this might be with TikZ tables. Essentially, your nodes are like "cells." Then just put them together and make it look like a table. Perhaps a horrible proposal, but I assure you that you'll have all the flexibility you need with cell spacing and such. Some ideas: