Latex: Problem with Multirow - latex

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

Did you put \usepackage{multirow} at the beginning of your document?
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:
Fancy Tables 1
Fancy Tables 2
Periodic table in TikZ which might give you some insight about how to do this a bit better than the first two?

Wild guess: You're getting undefined control sequence: multirow because you're lacking a \usepackage{multirow} in the preamble?

Yes, you need the multirow package.
\usepackage{multirow}
\begin{document}
\begin{table}
\centering
\begin{tabular}{l||c|r}
Header 1 & Header 2 & Header 3 \\
\multirow{2}{*}{Hello} & stuff & stuff \\
& Body 2 & Body 3
\end{tabular}
\end{table}
\end{document}
EDIT after edits to question: I got two errors:
\multirow{4}{l}{Framing}. I changed to \multirow{4}{*}{Framing}
Delta_t changed to $Delta_t$.
Otherwise, everything seems fine. You may want to ask tex.stackexchange.com, too.

Related

Aligning two equations with a 'multiline' bracket around them to previous equations

I am trying to align a set of solutions of an equation to previous equations at the position of their equal signs. Next to the set equations is a bracket that goes over both lines. The code I already have is equivalent to the following:
\usepackage{amsmath}
\begin{align*}
x^2 & = 1 \\
\Rightarrow \quad \left\{
\begin{array}{r l}
x & = - 1 \\
x & = 1
\end{array}
\right. \\
x & = 1
\end{align*}
Output
Is there or can I set another marker to use for alignment? Are there other equation environments or solutions for the bracket itself that would make this obsolete?
Additionally, is there an option to reduce the space left to the equal signs of the last two equations to 'normal' size (to comparison I copied the last solution inside the normal equation environment)?
Edit: The last problem can be fixed by using aligned instead of array.
Edit 2: Answer provided here!

Table filling width with 2 columns each as multi-row

I am trying to setup a table with 2 columns. It should fill the whole width of a A4 page.
Each column should contain a \multirow (different number of rows for each column).
The left column should be aligned on the left, the right column should be aligned on the right.
I am struggling with the details of the space filled between the columns. So far I've tried with the usual tabular package, but also with longtable, but I see all sorts of indentation problems. It seems like these packages don't honor the geometry details of the page.
See here:
% \begin{longtable}{#{\extracolsep{\fill}\hspace{\tabcolsep}} l r}
\begin{tabular}{>{\raggedright}p{0.5\linewidth}>{\raggedleft}p{0.5\linewidth}}
\multirow{2}{*}{\begin{tabular}{l}xx \\ zz \\ \end{tabular}} &
\multirow{2}{*}{\begin{tabular}{r}xx \\ zz \\ \end{tabular}} \\
\end{tabular}
% \end{longtable}
I would like to have 2 columns:
one on the far left, aligned on the left
the other on the far right, aligned on the right
no frames, or lines, just the text/words
If you don't need frames and the columns have different number of rows anyway, why not place two minipages besides each other instead of using a table?
\documentclass{article}
\begin{document}
\noindent%
\begin{minipage}{.5\textwidth}
\raggedright
xx
zz
\end{minipage}%
\begin{minipage}{.5\textwidth}
\raggedleft
xx
zz
\end{minipage}%
\end{document}

LaTex table corner cell line not showing

I'm using Overleaf to write a report. I can't seem to get the format just right for the top right corner cell.
I would also like to center "Correlation coefficient"
\begin{table}[h]
\caption{Correlation coefficient between force plate data and kinematic model data}
\label{IMUvsVB}
\begin{center}
\begin{tabular}{|c||c||c|}
\hline
\textbf{Ground reaction} & \multicolumn{2}{l}{\textbf{Correlation coefficient}} \\
\cline{2-3}
& \textbf{IMU based kinematics} & \textbf{Vision based kinematics}\\
\hline
Anteroposterior & 0.91 & 0.96\\
Mediolateral & 0.80 & 0.79\\
Vertical & 0.97 & 0.99\\
Frontal & 0.64 & 0.66\\
Sagittal & 0.91 & 0.94\\
Transverse & 0.82 & 0.84\\
\hline
\end{tabular}
\end{center}
\end{table}
Substitute
\textbf{Ground reaction} & \multicolumn{2}{l}{\textbf{Correlation coefficient}} \\
with
\textbf{Ground reaction} & \multicolumn{2}{c|}{\textbf{Correlation coefficient}} \\
The \multicolumn command needs 3 inputs:
The 1st one is the number of columns to be spanned.
The 2nd is the formatting of the cell (l for left, c for center and r for right). Here you can add also | for a single vertical line or even || for a double vertical line.
The 3rd one is the content of the cell.
Have a look at the documentation here if you need more insights on the usage of \multicolumn.

White space in siunitx columns

I am trying to format a table of numbers with units using the siunitx package to align the numbers on the decimal.
I am having trouble controlling the amount of white space that siunitx is allocating to the display of numbers.
Here is an example. I would like the numbers in the first column to be closer to the right, as they are in the third column, and I would like there to be less space on the left of numbers in the third column. (The vertical lines are ugly, I know, but they show the column widths.)
\documentclass[10pt,a4paper]{article}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{|S|r|S|r|}
\multicolumn{2}{c}{Range} & \multicolumn{2}{c}{Readout} \\
\hline
10 & mV & 0.000049 & mV \\
100 & V & 0.00007 & mV \\
\end{tabular}
\end{document}
EDIT
As a continuation of this question, I am trying to find a way to report numbers and units in the same column, with a single (or at least uniform) space between them. But again whitespace is hard to control. For example,
\begin{tabular}{
S|
S|
S[table-format=1.9]
}
{Range} & {Readout} & {Uncertainty} \\
\hline
10 {mV} & 0.000022~{mV} & 0.000069 {mV}\\
100 {mV} & -0.00001~{mV} & 0.00011 {mV}\\
1 {V} & -0.0000007~{V} & 0.00000029 V\\
10 {V} & -0.000007~{V} & 0.0000029 V\\
100 {V} & -0.000075~{V} & 0.000058 V\\
\end{tabular}
which produces this
Here, in the first column, space is inserted after the numbers depending on how big the mantissa is; in the second column there is too much white space on the left of the numbers; in the third column, the space between the number and unit allows for a certain number of digits.
Also, the use of ~ in the second column seems necessary. Without it, the text is joined directly to the number. I have played with table-align-text-post and -pre, as described in the siunitx docs, but they don't seem to work here. I thought they would.
You can specify how many digits are before and after the decimal marker. The syntax is table-format=<digits before marker>.<digits after the marker>
\documentclass[10pt,a4paper]{article}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{|S[table-format=3.0]|r|S[table-format=1.6]|r|}
\multicolumn{2}{c}{Range} & \multicolumn{2}{c}{Readout} \\
\hline
10 & mV & 0.000049 & mV \\
100 & V & 0.00007 & mV \\
\end{tabular}
\end{document}

Table in Latex Overlapping with Second Column of the Page

I got a problem with tables in LaTeX. I am using a pre-defined format from a conference, which makes a page consists of two columns. My table is too wide to be contained in one column, so it goes to the second column of the page and overlaps with text!
Why is LaTeX allowing this?
Is it possible in the current format, to make the table a block, so that it uses two columns, and the text in the other column dragged down a bit?
Any other suggestion?
This is my code:
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Rule & Factor & Best Value & Delta_t & Delta_{do} & Comments \\
\hline
\multirow{3}{c}{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
\end{tabular}
\caption{The factors of each rule and their parameters.}
\label{table:factors}
\end{table}
Thank you in advance for your help.
Regards,
Rafid
Generally, the starred version of floating environments are used to tell LaTeX to span two columns. So, something like:
\begin{table*}
% Table contents
\end{table*}
The same can be done with figures.
In place of tabular, use tabularx, for example:
\begin{tabularx}{\textwidth}{|c|c|c|c|c|X|}
Sorry, #Rafid, I normally use memoir, which includes it, so I forgot this bit:
\usepackage{tabularx}

Resources