2

I want to set three tables to stand in a row, with each of them has its own name above it.
Let me show you what I mean...

I wrote this code:

\begin{center}
    $R_1$\\
    \vspace{3 mm}
    \begin{tabular}{ |c|c| } 
        \hline
        \textbf{course} & \textbf{type} \\ 
        \hline
        Databases & Basic \\ 
        \hline
        Math & Advanced \\
        \hline
    \end{tabular}

    $R_2$ \\
    \vspace{3 mm}
    \begin{tabular}{ |c|c| } 
        \hline
        \textbf{course} & \textbf{deg} \\ 
        \hline
        Databases & 1 \\ 
        \hline
        Math & 1 \\
        \hline
        Math & 2 \\
        \hline
    \end{tabular}

    $R_3$ \\
    \vspace{3 mm}
    \begin{tabular}{ |c|c| } 
        \hline
        \textbf{course} & \textbf{course\_num} \\ 
        \hline
        Databases & 55281 \\ 
        \hline
        Math & 55570 \\
        \hline
    \end{tabular}
\end{center}

Which produces exactly what I want, except it shows every table above the other:

enter image description here

and the result I'm aiming for is tables that stands one next to each other:

enter image description here

Is there some kind of trick that will allow me to do that?

  • 1
    Get rid of those empty lines, meaning a new paragraph for LaTeX. If you want the tables to be somehow separated, mask the blank lines with a comment char (%). – Johannes_B Nov 1 '14 at 21:35
  • But that messes up the tables' head-titles (R_1, R_2, R_3)... – so.very.tired Nov 1 '14 at 21:37
  • 1
    Ah, minipages. Set each tabular and the according description in a minipage of it's own. – Johannes_B Nov 1 '14 at 21:38
3

One possibility is to put your table into table like:

\begin{center}
\begin{tabular}{c@{\quad}c@{\quad}c}
    $R_1$   &   $R_2$   &   $R_3$   \\
\begin{tabular}[t]{|c|c|}
    \hline
\textbf{course}     & \textbf{type} \\  \hline
        Databases   & Basic         \\  \hline
        Math        & Advanced      \\  \hline
\end{tabular}
    &   \begin{tabular}[t]{|c|c|}
        \hline
    \textbf{course} & \textbf{deg}  \\  \hline
        Databases   & 1             \\  \hline
        Math        & 1             \\  \hline
        Math        & 2             \\  \hline
    \end{tabular}
        &   \begin{tabular}[t]{|c|c|}
            \hline
        \textbf{course} & \textbf{course\_num}  \\  \hline
        Databases       & 55281                 \\  \hline
        Math            & 55570                 \\  \hline
            \end{tabular}
\end{tabular}
\end{center}

Not tested, but this should work as you expect.

3

I Took Johannes_B's advice, and here's the refined version:

\begin{minipage}[t]{0.32\textwidth} \centering
    $R_1$\\
    \vspace{3 mm}
    \begin{tabular}{ |c|c| } 
        \hline
        \textbf{course} & \textbf{type} \\ 
        \hline
        Databases & Basic \\ 
        \hline
        Math & Advanced \\
        \hline
    \end{tabular}
\end{minipage}
\begin{minipage}[t]{0.30\textwidth} \centering
    $R_2$ \\
    \vspace{3 mm}
    \begin{tabular}{ |c|c| } 
        \hline
        \textbf{course} & \textbf{deg} \\ 
        \hline
        Databases & 1 \\ 
        \hline
        Math & 1 \\
        \hline
        Math & 2 \\
        \hline
    \end{tabular}
\end{minipage}
\begin{minipage}[t]{0.30\textwidth} \centering
    $R_3$ \\
    \vspace{3 mm}
    \begin{tabular}{ |c|c| } 
        \hline
        \textbf{course} & \textbf{course\_num} \\ 
        \hline
        Databases & 55281 \\ 
        \hline
        Math & 55570 \\
        \hline
    \end{tabular}
\end{minipage}

This produced the following result:

enter image description here

Thanks, Johannes_B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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