# Math Help - [SOLVED] Latex \tabular

1. ## [SOLVED] Latex \tabular

I am having difficulties getting to grips with {tabular} environment in LaTeX. With the following code ...
Code:
\begin{tabular}{l*6r}
A&&&B\\\hline\hline
\multirow{3}{*}{\huge1} & \multicolumn{2}{4}{2} \\
& 3 & 4 \\
& \multicolumn{2}{3}{5} \\\hline
\end{tabular}
... I get output like this:

But, what I'm trying to get is this:

Also, I'm not sure about the use of
Code:
{l*6r}
and
Code:
{*}
in the \multirow command. I saw examples using "*", stating that it "makes the cell as wide as needed". Also, where should I put \huge for 1 (this gives an error, though it's working)?

2. Is this what you are looking for? $\begin{tabular}{|c|c||lr|}
\multicolumn{4}{c}{A\hfill B} \\ \hline\hline
&\multicolumn{1}{c}{}&2& \\ \cline{2-4}
\lower1ex\hbox{\huge1}&3&4& \\ \cline{2-4}
&\multicolumn{1}{c}{}&5& \\
\hline
\end{tabular}$

Code:
\begin{tabular}{|c|c||lr|}
\multicolumn{4}{c}{A\hfill B} \\ \hline\hline
&\multicolumn{1}{c}{}&2& \\  \cline{2-4}
\lower1ex\hbox{\huge1}&3&4& \\ \cline{2-4}
&\multicolumn{1}{c}{}&5& \\ \hline
\end{tabular}

3. ## Questions

You have even pulled off somewhat harder version. How would you make "3 || 4" centered under 2, like this (I'm sorry for the first (inaccurate) drawing):

What part of your code does it even make "3 || 4" move towards left?

I will try(!) to dissect your code line-by-line:
Code:
\begin{tabular}{|c|c||lr|}
\multicolumn{4}{c}{A\hfill B} \\ \hline\hline
&\multicolumn{1}{c}{}&2& \\  \cline{2-4}
\lower1ex\hbox{\huge1}&3&4& \\ \cline{2-4}
&\multicolumn{1}{c}{}&5& \\ \hline
\end{tabular}
First line clear.
Code:
\multicolumn{4}{c}{A\hfill B} \\ \hline\hline
What does \hfill ("horizontal fill"?) do? Inserts empty spaces, and thus moves B to the right?

Code:
&\multicolumn{1}{c}{}&2& \\  \cline{2-4}
Why do you use \multicolumn for the second "cell", if you pass '1' as the argument? The first line is {|c|c||lr|}: why isn't 2 left-alligned?

Code:
\lower1ex\hbox{\huge1}&3&4& \\ \cline{2-4}
\lower1ex and \hbox ("horizontal box"?), what are they for?

Code:
&\multicolumn{1}{c}{}&5& \\ \hline
Same question as for the second line: why \multicolumn{1}?

In genuine hope of not nagging (too much)!

4. Originally Posted by courteous
How would you make "3 || 4" centered under 2, like this (I'm sorry for the first (inaccurate) drawing):
That's easy: $\begin{tabular}{|c|c||c|}
\multicolumn{3}{c}{A\hfill B} \\ \hline\hline
&\multicolumn{2}{c|}{2} \\ \cline{2-3}
\lower1ex\hbox{\huge1}& 3 & 4 \\ \cline{2-3}
&\multicolumn{2}{c|}{5} \\
\hline
\end{tabular}$
. But it looks a bit pinched. Spreading it out a bit is quite tricky, but it can be done: $\begin{tabular}{|c|c@{\hspace{12pt}}||c@{\hspace{1 2pt}}|}
\multicolumn{3}{c}{A\hfill B} \\ \hline\hline
&\multicolumn{2}{c|}{2} \\ \cline{2-3}
\lower1ex\hbox{\huge1}&\hspace{6pt}3 &\hspace{6pt}4 \\ \cline{2-3}
&\multicolumn{2}{c|}{5} \\
\hline
\end{tabular}$
.

(Press the "quote" button to see the code for each of those.)

Originally Posted by courteous
What part of your code does it even make "3 || 4" move towards left?
The previous version used four columns. The second column contained only the 3, the numbers 2, 4 and 5 were in the third column, and the fourth column was empty. The versions above use only three columns, which makes them simpler.

Originally Posted by courteous
What does \hfill ("horizontal fill"?) do? Inserts empty spaces, and thus moves B to the right?
It pads out the line with enough space to fill the width of the table, with the A at the left and the B at the right.

Originally Posted by courteous
Why do you use \multicolumn for the second "cell", if you pass '1' as the argument? The first line is {|c|c||lr|}: why isn't 2 left-alligned?
The \multicolumn spans only one column, and inserts an empty cell there. But it is re-formatted to suppress the double vertical bar to its right. The 2 is left-aligned, but it's in the next column.

Originally Posted by courteous
\lower1ex and \hbox ("horizontal box"?), what are they for?
If they weren't there, the base of the huge 1 would be aligned with the base of the 3 and 4 in the same row. If you want the 1 to look vertically centred, you have to lower it by putting it in an \hbox along with a \lower command.

Originally Posted by courteous
Code:
&\multicolumn{1}{c}{}&5& \\ \hline
Same question as for the second line: why \multicolumn{1}?
As before, we need to suppress the || to the right of that column.