1

The following code places the figure and table one after another instead of side by side.

What's going wrong?

\begin{figure}
\begin{minipage}[t]{0.4\linewidth}
\centering
\caption{}\label{fig}
\includegraphics[scale=.4]{image}\label{}
\end{minipage}
\end{figure}
\hfill
\begin{table}
\begin{minipage}{0.5\linewidth}
\begin{center}
\caption{}\label{}
\scalebox{0.9}{
\setlength{\tabcolsep}{.6em}
\begin{tabular}{ |c c c c c | } 

\end{tabular}
}
\end{center}
\end{minipage}
\end{table}
3
  • You shouldn't nest a center environment inside of table or figure, use \centering instead, as center results in unwanted additional vertical space.
    – Skillmon
    Sep 21, 2019 at 7:08
  • And welcome to TeX.SX! In general it is better if you provide a complete minimal working example (MWE) that contains the \documentclass, \begin{document}, \end{document} and every package that is necessary to compile your example but nothing more, similar to my answer below.
    – Skillmon
    Sep 21, 2019 at 7:09
  • 1
    You might be interested in package floatrow. See § 2.3.1, Mixed rows in the documentation (pp. 20-21).
    – Bernard
    Sep 21, 2019 at 9:17

1 Answer 1

3

A figure and table environment always appear in the full width of a line and with nothing next to them. If you want to place the two next to each other, you can't use a figure AND a table environment. If you still want them to float you can use only one of the two environments and use \captionof{<type>}{<caption>} instead (this is provided by the capt-of package, the caption package, or any KOMA-script class).

Small example:

\documentclass[]{article}

\usepackage{capt-of}
\usepackage[]{graphicx}

\begin{document}
\begin{figure}
  \begin{minipage}[t]{.4\linewidth}
    \centering
    \includegraphics{example-image-duck}%
    \caption
      {%
        Image of a duck%
        \label{fig:duck}%
      }%
  \end{minipage}\hfill
  \begin{minipage}[t]{.4\linewidth}
    \centering
    \begin{tabular}{ll}
      Duck type & description \\
    \end{tabular}
    \captionof{table}
      {%
        Different kinds of ducks%
        \label{tab:duck}%
      }
  \end{minipage}
\end{figure}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .