Graphics, Figures & TablesReference longtable in extended document

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
chemphysman
Posts: 1
Joined: Wed Mar 03, 2010 2:51 pm

Reference longtable in extended document

Post by chemphysman »

I have a large document which is based around an initial file such as report.tex (below) which includes a subsequent file.tex.

If in file.tex I then insert a longtable using \afterpage and the table ends up on a page with no other text then I receive an error when trying to reference to it. Any ideas why?

Thanks in advance.

report.tex

Code: Select all

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{longtable}
\usepackage{afterpage}
\begin{document}
\include{file}
\end{document}
file.tex

Code: Select all

Some text which references Table \ref{longtable}.
\afterpage{\input{table}}
table.tex

Code: Select all

\begin{center}
\begin{longtable}{ l l } 
\caption[Some longtable]{Some longtable \label{longtable}} \\

% First header
\hline
\multicolumn{1}{l}{$r_{\textrm{e}}$}
 & \multicolumn{1}{l}{Restraint} \\
\hline
\endfirsthead

% Subsequent Headers
\multicolumn{2}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\multicolumn{1}{l}{$r_{\textrm{e}}$} & \multicolumn{1}{l}{Restraint} \\
\hline
\endhead

% Footer
\multicolumn{2}{r}{{Continued on next page}} \\ \hline
\endfoot

% Final Footer
\hline
\endlastfoot

% Data
109.6 & 109.6(5) \\

\hline
\end{longtable}
\end{center}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply