3

I have a tabular with 4 sub-figures and I want to set the caption for each figure respectively. I'm using the subcaption package but I'm getting the following error on compilation: package floatrow error: caption(s) lost. Can anyone tell where the problem is?

{\centering
\begin{table}[ht]

 \begin{tabular}{ll}

    \begin{subfigure}{}
      \includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{figure} \label{fig:taba2}
    \end{subfigure} &

    \begin{subfigure}{}
      \includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{fd} \label{fig:taba3} 
    \end{subfigure}\\ \newline

    \begin{subfigure}{}
      \includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{figure}\label{fig:taba4} 
    \end{subfigure} &

    \begin{subfigure}{}
      \includegraphics[width=0.5\columnwidth]{include/case_study/fig/QQ_Velocity.png} \caption{figure}  \label{fig:taba5}
    \end{subfigure}\\

 \end{tabular}
 \caption{A table with figures}
   \label{tab:mytable}
\end{table}
}

1 Answer 1

1

I can't reproduce your error. However, you have errors in defining of subfigure. For it you need to declare its width, for example

\begin{subfigure}{0.5\textwidth}\centering

In it you than can set width of figure relative to subfigure width, for example:

\includegraphics[width=\linewidth]{example-image} 

Also the \centering should be inside of table environment. Complete code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\usepackage[active,floats,tightpage]{preview}
    \setlength\PreviewBorder{3em}

    \begin{document}
\begin{table}[ht]
\centering
 \begin{tabular}{cc}
\begin{subfigure}{0.5\textwidth}
  \includegraphics[width=\linewidth]{example-image} \caption{figure} \label{fig:taba2}
\end{subfigure} &
    \begin{subfigure}{0.5\textwidth}
      \includegraphics[width=\linewidth]{example-image} 
    \caption{fd} \label{fig:taba3}
    \end{subfigure}     \\
%
\begin{subfigure}{0.5\textwidth}
  \includegraphics[width=\linewidth]{example-image} \caption{figure}\label{fig:taba4}
\end{subfigure} &
    \begin{subfigure}{0.5\textwidth}
      \includegraphics[width=\linewidth]{example-image} 
    \caption{figure}  \label{fig:taba5}
    \end{subfigure}
 \end{tabular}
 \caption{A table with figures}
   \label{tab:mytable}
\end{table}
    \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 .