Results 1 to 4 of 4

Math Help - [SOLVED] Latex \tabular

  1. #1
    Member courteous's Avatar
    Joined
    Aug 2008
    From
    big slice of heaven
    Posts
    206

    Question [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)?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    Is this what you are looking for? \begin{tabular}{|c|c||lr|}<br />
\multicolumn{4}{c}{A\hfill B} \\ \hline\hline<br />
&\multicolumn{1}{c}{}&2& \\  \cline{2-4}<br />
\lower1ex\hbox{\huge1}&3&4& \\ \cline{2-4}<br />
&\multicolumn{1}{c}{}&5& \\<br />
\hline<br />
\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}
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member courteous's Avatar
    Joined
    Aug 2008
    From
    big slice of heaven
    Posts
    206

    Smile 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)!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    Quote Originally Posted by courteous View Post
    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|}<br />
\multicolumn{3}{c}{A\hfill B} \\ \hline\hline<br />
&\multicolumn{2}{c|}{2} \\  \cline{2-3}<br />
\lower1ex\hbox{\huge1}& 3 & 4 \\ \cline{2-3}<br />
&\multicolumn{2}{c|}{5} \\<br />
\hline<br />
\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}}|}<br />
\multicolumn{3}{c}{A\hfill B} \\ \hline\hline<br />
&\multicolumn{2}{c|}{2} \\  \cline{2-3}<br />
\lower1ex\hbox{\huge1}&\hspace{6pt}3 &\hspace{6pt}4 \\ \cline{2-3}<br />
&\multicolumn{2}{c|}{5} \\<br />
\hline<br />
\end{tabular}.

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

    Quote Originally Posted by courteous View Post
    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.

    Quote Originally Posted by courteous View Post
    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.

    Quote Originally Posted by courteous View Post
    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.

    Quote Originally Posted by courteous View Post
    \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.

    Quote Originally Posted by courteous View Post
    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.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Split 'tabular' over two pages?
    Posted in the LaTeX Help Forum
    Replies: 1
    Last Post: May 15th 2010, 03:02 AM
  2. LaTex inside of LaTex
    Posted in the LaTeX Help Forum
    Replies: 2
    Last Post: November 12th 2009, 11:07 AM
  3. [SOLVED] Finally in LaTex: Pre-images and indexed set.
    Posted in the Discrete Math Forum
    Replies: 2
    Last Post: October 13th 2008, 07:10 AM
  4. [SOLVED] Logarithims in LaTex
    Posted in the LaTeX Help Forum
    Replies: 0
    Last Post: March 11th 2008, 01:07 PM

Search Tags


/mathhelpforum @mathhelpforum