[Tex/LaTex] Minipage: 2 tables side by side isn’t working

minipage

I have the following code to layout two tables side by side:

\begin{minipage}{0.3\textwidth}
\begin{tabular}{c | c | c | c | c | c | c}
F & D & E & G & P & A & L\\
\hline
C & H & I & I & U & G & F\\
\hline
G & Z & G & A & F & Z & U\\
\hline
F & R & \textbf{H} & \textbf{A} & \textbf{U} & \textbf{S} & Z\\
\hline
R & P & L & I & N & F & H\\
\hline
L & U & G & I & A & C & T\\
\hline
A & B & D & N & E & R & Z\\
\end{tabular}

\end{minipage}

\begin{minipage}{0.3\textwidth}
\begin{tabular}{c | c | c | c | c | c | c}
F & D & E & G & P & A & L\\
\hline
C & H & I & I & U & G & F\\
\hline
G & Z & G & A & F & Z & U\\
\hline
F & R & \textbf{H} & \textbf{A} & \textbf{U} & \textbf{S} & Z\\
\hline
R & P & L & I & N & F & H\\
\hline
L & U & G & I & A & C & T\\
\hline
A & B & D & N & E & R & Z\\
\end{tabular}

\end{minipage}

But it doesn't work. The tables are one below the other. What am I doing wrong?

Best Answer

What you are doing wrong is the new line between the minipages. That makes for a new paragraph. Remove it and make them a little wider (your tables are wider than .3\textwidth so they will overlap. This is what the code would look like:

\documentclass{article}
\begin{document}
  \begin{minipage}{0.4\textwidth}
    \begin{tabular}{c | c | c | c | c | c | c}
      F & D & E & G & P & A & L\\
      \hline
      C & H & I & I & U & G & F\\
      \hline
      G & Z & G & A & F & Z & U\\
      \hline
      F & R & \textbf{H} & \textbf{A} & \textbf{U} & \textbf{S} & Z\\
      \hline
      R & P & L & I & N & F & H\\
      \hline
      L & U & G & I & A & C & T\\
      \hline
      A & B & D & N & E & R & Z\\
    \end{tabular}
  \end{minipage}\qquad
  \begin{minipage}{0.4\textwidth}
    \begin{tabular}{c | c | c | c | c | c | c}
      F & D & E & G & P & A & L\\
      \hline
      C & H & I & I & U & G & F\\
      \hline
      G & Z & G & A & F & Z & U\\
      \hline
      F & R & \textbf{H} & \textbf{A} & \textbf{U} & \textbf{S} & Z\\
      \hline
      R & P & L & I & N & F & H\\
      \hline
      L & U & G & I & A & C & T\\
      \hline
      A & B & D & N & E & R & Z\\
    \end{tabular}
  \end{minipage}
\end{document}

The \qquad is added for some extra spacing. The result looks like this:

Tables in minipages side by side