TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
I have moved caption everywhere in the code – Nano Barrios Mar 19 at 5: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 at 5:29
    
on a sidenote: rule of thumb as I know it: tables: captions above, image: captions below. – naphaneal Mar 19 at 9:25
up vote 6 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.