
Existe alguma maneira de colocar \caption{}
na frente de \begin{longtable}
? Ilustrando com um exemplo, em vez de
\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{c|c|c|c}
\caption{This is a very nice table}
A & B & A & B \\ \hline
\end{longtable}
\end{document}
Eu gostaria de usar algo como
\documentclass{article}
\usepackage{longtable}
\begin{document}
\caption{This is a very nice table}
\begin{longtable}{c|c|c|c}
A & B & A & B \\ \hline
\end{longtable}
\end{document}
Responder1
Você pode fazer isso com \captionof
. Esteja ciente de que aqui são possíveis quebras de página entre a legenda e a tabela longa.
\documentclass{article}
\usepackage{longtable}
\usepackage{caption}
\begin{document}
\captionof{table}{This is a very nice table}
\begin{longtable}{c|c|c|c}
A & B & A & B \\ \hline
\end{longtable}
\addtocounter{table}{-1}
\captionof{table}{This is a very nice table}
\begin{longtable}{c|c|c|c}
A & B & A & B \\ \hline
\end{longtable}
\end{document}