How do I put a table and a figure side by side with minipage?
I have made it work, but then the figure's caption is table, because table was the surrounding tag.
\begin{table}[ht]
\begin{minipage}[b]{0.45\linewidth}
\centering
\begin{tabular}{ | l | r | r | r |}
\hline
Student & Hours/week & Grade \\ \hline \hline
Ada Lovelace & 2 & A \\ \hline
Linus Thorvalds & 8 & A \\ \hline
Bruce Willis & 12 & F \\ \hline
Richard Stallman & 10 & B \\ \hline
Grace Hopper & 12 & A \\ \hline
Alan Turing & 8 & C \\ \hline
Bill Gates & 6 & D \\ \hline
Steve Jobs & 4 & E \\ \hline
\end{tabular}
\caption{Student Database}
\label{table:student}
\end{minipage}
\end{table}
\begin{figure}[ht]
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=40mm]{figures/studentdatabasegraph.png}
\caption{2-D scatterplot of the Student Database}
\label{ }
\end{minipage}
\end{figure}
Best Answer
Table and figure caption can be put in the same floating environment, but there is a big but: LaTeX places figures and tables independently and does not synchronize the numbering of the figure caption in the table float with the other figures. Therefore, the numbering of the figures can be out of order.
Example file:
Nicer table
Different alignment