[Tex/LaTex] Setting three tables next to each other

tables

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?

Best Answer

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.

Related Question