[Tex/LaTex] tabular can’t caption is separated


I'm creating a table like this:

\begin{tabular}{@{} *5l @{}}\toprule
\emph{header1} & \emph{header2} & \emph{header3} \\\midrule
item1 & v1  & v2   \\
item2 & v1  & v2   \\
item2 & v1  & v2   \\

This way the caption gets separated from the table and if it reaches the end of the page the table might go to the next page while its caption remains on the previous page. If I move the caption inside tabular I get an error:

You can't use `\hrule' here except with leaders.
\caption@hrule ->\hrule

and if I use \caption instead:

Package caption Error: \caption outside float

I've added these lines to use caption for my tables:


Best Answer

Have you considered using the booktabs package?

This is your example a little re-arranged:



\renewcommand{\thetable}{\Roman {table}}


    \caption{Table's caption}\label{tab:label}
        \emph{header1} & \emph{header2} & \emph{header3} \\
        item1 & v1  & v2   \\
        item2 & v1  & v2   \\
        item2 & v1  & v2   \\


enter image description here

Related Question