Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Latex - tables taking up too much room

  1. May 24, 2012 #1
    Hi,
    when i have multiple tables together the spacing between them is large and takes up unnecessary room. I have 5 tables which span the entire width and are one ontop of the other. If i was to put these tables into word they would fit into the one page. However, on latex the are spread over two pages due to the huge gaps between them (they dont even make it look nice). How do i get around this issue and force them to be closer together?
    Thanks in advance
     
  2. jcsd
  3. May 27, 2012 #2

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Can you show us the tex?
    I cannot tell what you've done from the description. We only need the bit with the tables and the header to support them.

    Generally:

    Word uses smaller margins than LaTeX defaults, so you can fit more horizontally across the page.

    In LaTeX a table is an environment and so has the same external spacings as any environment (iirc: 0.5 line above and below). It also has internal padding.

    It can be prettier if you float the tables - you can get into trouble if you try for too much fine control over how LaTeX places things.
     
  4. May 27, 2012 #3
    Okay thanks. here is an example of a table:


    \begin{table}[htp]
    \caption{Caption goes here}
    \begin{center}
    \begin{tabular}{c c c c c c}

    \hline\hline
    Plan (\%) & 1 & 2& 3 & 4 & 5\\
    \hline
    Max & 108.7 & 108.1 & 109.2 & 108.7 & 109 \\
    Min & 86.2 & 88.4 & 91.6 & 92.3 & 89.6 \\
    \end{tabular}
    \label{p5}
    \end{center}
    \end{table}

    I dont mind how many fit in one line - its how many fits in a page - i personally think it looks silly when there is huge gaps

    Thanks
     
  5. May 27, 2012 #4

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Well I can fit six of those on one page of a standard A4 layout in the default article single-page style. They look OK to me - about 2.5-3 lines between them.

    I can pack them closer by including more than one tabular environment inside a table environment.

    [later] Hmmm ... fiddling around I managed to get BIG spaces so I only had four to a page. That was ugly! But I saw what happened - if there are few tables, they will get spaced out. If I add more floating tables they got packed together again. If there was text, it ended up shifting the tables around too. Maybe that's what happened with you?

    If your tables have a natural grouping and you want them all together, try putting them all in the same table float.
     
  6. May 27, 2012 #5
    i didnt include all the info but you appear to see what my probem in anyway...

    Do you mean do this:

    \begin{table}[htp]
    \caption{Caption goes here}
    \begin{center}
    \begin{tabular}{c c c c c c}

    \hline\hline
    Plan (\%) & 1 & 2& 3 & 4 & 5\\
    \hline
    Max & 108.7 & 108.1 & 109.2 & 108.7 & 109 \\
    Min & 86.2 & 88.4 & 91.6 & 92.3 & 89.6 \\
    \end{tabular}
    \label{p5}
    \end{center}

    \caption{Caption goes here}
    \begin{center}
    \begin{tabular}{c c c c c c}

    \hline\hline
    Plan (\%) & 1 & 2& 3 & 4 & 5\\
    \hline
    Max & 108.7 & 108.1 & 109.2 & 108.7 & 109 \\
    Min & 86.2 & 88.4 & 91.6 & 92.3 & 89.6 \\
    \end{tabular}
    \label{p5}
    \end{center}
    \end{table}

    I tried to do the minipage environment thing but it didnt work for me. It just kind of did two tables side by side and overlapping. But yeah all my tables are connected so i want them to be all next to each other.

    Thanks
     
  7. May 27, 2012 #6

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    I think you need to put tex inside code tags - but you have the idea - except you only need one center environment inside the table environment.
    Code (Text):
    \begin{table}[htp]
      \begin{center}
        \caption{Caption1 goes here}
        \begin{tabular}{c c c c c c}
    \hline\hline
    Plan (\%) &  1       &  2       &  3       &    4      &  5     \\
    \hline
    Max &  108.7 &  108.1 &  109.2 &  108.7 &  109  \\
    Min &  86.2   &  88.4  &  91.6   &  92.3  &  89.6 \\
        \end{tabular}
     
        \caption{Caption 2goes here}
        \begin{tabular}{c c c c c c}
    \hline\hline
    Plan (\%) &  1       &  2       &  3       &    4      &  5     \\
    \hline
    Max         &  108.7 &  108.1 &  109.2 &  108.7 &  109  \\
    Min          &  86.2   &  88.4  &  91.6   &  92.3  &  89.6 \\
        \end{tabular}
      \end{center}
    \end{table}
    ... each environment starts and ends with a paragraph break, except tabular, they can add up. You can also create your own special table environment to tell it not to do this... for advanced users though, I've never needed to.
     
    Last edited: May 27, 2012
  8. Jun 2, 2012 #7
    Fantastic!! this works exactly how i wanted it to!! thanks :)
     
  9. Jun 2, 2012 #8

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    No worries.

    Of course you don't have to float the tables :)
     
  10. Jun 4, 2012 #9
    what do you mean by float the tables?
     
  11. Jun 4, 2012 #10

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    "floating" is when the position of a page element is not fixed. You float a table with the \begin{table} ... the table won't always appear right where you insert the \begin.

    This is useful because it allows LaTeX to adjust where it puts tables in the text for different page sizes, if you have 2 columns, if you add more text later, or whatever. With more wysiwyg publishing tools you fix the position of tables and graphics and "wrap" text around them, instead, but html prefers to use floats so, for eg, web pages can adjust to different screen sizes.

    I suspect the floating algorithm is what has been messing with the spacing - I was getting 4 tables to a page: evenly spaced on the page. But it went compact when I changed the number of tables and/or the amount of additional text.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Latex - tables taking up too much room
  1. LaTeX help (Replies: 2)

Loading...