2

I don't understand why I can't have a caption here:

\begin{table}[H]
\begin{tabular}{cc}
\hline
\textbf{Ejemplo 3} &  \includegraphics[width=8cm,height=4cm]{figura/07.jpg} \\
\includegraphics[width=6cm,height=4cm]{figura/07_1.jpg} & \includegraphics[width=6cm,height=4cm]{figura/07_2.JPG} \\
\hline 
\textbf{Foto 7} & \includegraphics[width=8cm,height=4cm]{figura/48.jpg}\\
\includegraphics[width=6cm,height=4cm]{figura/48_1.jpg} & \includegraphics[width=6cm,height=4cm]{figura/48_2.JPG}\\
\hline
\label{casosop2}
\end{table}
\caption{caption}
\end{tabular}

I get the following error:

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.84 \end{table}

If I remove the caption line, I get no problems.

Au101
  • 10,278
  • I have moved caption everywhere in the code – Nano Barrios Mar 19 '16 at 05:08
  • 2
    Well an obvious problem is that your \end{tabular} and \end{table} are the wrong way around. You should have \end{tabular} first and then \end{table}. Anyway, I understand that you're frustrated, but please don't pepper your post with multiple exclamation marks etc. we don't like being shouted at and in any case Stackexchange sees itself as an encyclopaedic knowledge base, rather than a help group or anything – Au101 Mar 19 '16 at 05:29
  • on a sidenote: rule of thumb as I know it: tables: captions above, image: captions below. – naphaneal Mar 19 '16 at 09:25

1 Answers1

6

A couple of things:

  • Grouping follows a hierarchy: If you open up a table and inside it a tabular, you have to close the tabular before closing the table.

  • Your \caption should be inside the table environment, not inside the tabular. That's just how it is, unless you're using longtable.

  • Place your \label after the \caption (and not inside the tabular). Here's what generates your table:

enter image description here

\documentclass{article}

\usepackage{graphicx,float}

\begin{document}

\begin{table}[H]
  \begin{tabular}{cc}
    \hline
    \textbf{Ejemplo 3} &  \includegraphics[width=8cm,height=4cm]{example-image-a} \\
    \includegraphics[width=6cm,height=4cm]{example-image-b} & \includegraphics[width=6cm,height=4cm]{example-image-c} \\
    \hline
    \textbf{Foto 7} & \includegraphics[width=8cm,height=4cm]{example-image-a}\\
    \includegraphics[width=6cm,height=4cm]{example-image-b} & \includegraphics[width=6cm,height=4cm]{example-image-c}\\
    \hline
  \end{tabular}
  \caption{caption}
  \label{casosop2}
\end{table}

\end{document}
Werner
  • 603,163