Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've checked out related questions here, and found similar answers via Google, and still can't figure out why the following code does not produce two side-by-side tables. They are narrow enough to fit on the page, but for any variation of textwidth, using either parbox or minipage, I always get the tables stacked vertically on top of each other instead of left to right.

I must be missing something obvious, but this is driving me nuts. What have I done wrong?

\documentclass{article}
\usepackage[margin=1in]{geometry}
\begin{document}

\begin{table}[h]
 \begin{minipage}{0.4\textwidth}
  \centering
  \begin{tabular}{|l|l|c|}\hline
    Site & Species & Abundance \\\hline
    S1 & A.rubrum & 25 \\
    S1 & A.saccharum & 5 \\
    S2 & Q.rubrum & 45 \\\hline
  \end{tabular}
  \caption{Long-form data}
  \label{tab:long-form}
\end{minipage}

\begin{minipage}{0.5\textwidth}
 \centering
 \begin{tabular}{|l|c|c|c|}\hline
  Sites & A.rubrum & A.sacch & Q.rubrum \\\hline
  S1    & 25 & 5 & 0 \\
  S2    & 0 & 0 & 45 \\\hline
 \end{tabular}
 \caption{Wide-form data}
 \label{tab:wide-form}
\end{minipage}

\end{table}

\end{document}
share|improve this question
    
This isn't related to your question, but you might consider following the advice in the booktabs package's manual for making good looking tables. –  TH. Mar 27 '11 at 11:14
    
@TH: Yes, you're right, and normally I would. In this particular instance, the tables are meant to be examples of spreadsheet data, so I've added extra lines to make it look closer to what you see in Excel. That may still be excessive, though! –  Tyler Mar 27 '11 at 13:43

1 Answer 1

up vote 6 down vote accepted

The empty line between the minipages generates a new paragraph. This pushes the second one down. Simply remove that line or end it with % will avoid the paragraph.

share|improve this answer
    
Ack! I can't tell you how much time I spent staring at that code, trying and retrying every variation I could think of. Thank you!!! –  Tyler Mar 26 '11 at 23:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.