Latex error: \begin{document} ended by \end{table}

I'm getting the following error from my Latex code:

\begin{document} ended by \end{table}

But the error is not what the message says, because the begin{document} is ended by \end{document}. The problem is with the command \begin{table}, when I turn it in comment, the table works fine, but when I turn it on, the table disappear and the message appears.

\begin{table}[ht]
\begin{center}
\begin{tabular}{cc}
\hline
\multicolumn{2}{c}{\textbf{Variância das séries}} \\
\hline
\hline
1ª diferença & 0,003638648 \\
\hline
\caption{Variância das séries}
\end{tabular}
\end{center}
\end{table}


And these are the packages that I'm using

\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{tikz,blindtext}
\usepackage[T1]{fontenc}
\usepackage{palatino}
\usepackage{chngpage,calc}
\usepackage{hyperref}
\usepackage{kpfonts}
\usepackage{conf}
\usepackage{graphicx}
\usepackage[portuguese, english, brazil]{babel}
\usepackage{setspace}
\usepackage{cite}


Anyone can help me?

• Hi Filipe, welcome to TeX.sx! As far as I can see, \caption is in the wrong place - move it outside the tabular environment. You can also use \centering instead of \begin{center}...\end{center}. :) Jul 2, 2012 at 1:37

The error you mentioned is actually the last error in the compilation process and comes as a consequence of this one:

! Missing \endgroup inserted.
<inserted text>
\endgroup
l.27 \caption{Variância das séries}


\caption is in the wrong place, we need to move it outside the tabular environment. A MWE is as follows:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}

\begin{document}

\begin{table}[ht]
\centering
\begin{tabular}{cc}
\hline
\multicolumn{2}{c}{\textbf{Variância das séries}} \\
\hline
\hline
1ª diferença & 0,003638648 \\
\hline
\end{tabular}
\caption{Variância das séries}
\label{tab:varianciaseries}
\end{table}

\end{document}


The output:

Note that I added a \label{tab:varianciaseries} to the code, so you can refer to this table later in the document by simply using it:

De acordo com a Tabela~\ref{tab:varianciaseries}, ...


Hope it helps. :)