# How to include a multipage table from an external file

I usually save my tables as standalone PDFs, generated by compiling a standalone document and then include them in the main file via \includegraphics{pdf.name}

However, I now have a two-pages table made with longtable and I would like to include it with the same method, saving it as a separate PDF and then including it with includegraphics.

This does not seem to work and has many issues:

1. standalone class do not work with longtables
2. If I save the table as a normal article then it can't be included with includegraphics

So my question is: How should I proceed to include a multi-page table from an external file? Is it even possible?

-
Use standalone with article option when you are building the long table. In the main input file load docmute package, and import the table via \input command. –  cyanide-based food Dec 15 '13 at 17:46

This would be a perfect application of the standalone bundle.

You can store your longtable table in (say), mytablefile.tex, and then input it into your main file using input.

Here are two files that demonstrate the idea- note that mytablefile.tex uses the standalone documentclass while mainfile.tex uses standalone package. This is a very simple demonstration, but you can do some more sophisticated things- explore the manual and this site for more details.

Note that with your current approach your table will not inherit the font style of your main document- furthermore, it will likely be scaled and may look out of place- the technique I have demonstrated does not have this problem.

# mainfile.tex

% arara: pdflatex
\documentclass{article}

\usepackage{standalone}
\usepackage{longtable}

\begin{document}
\input{mytablefile}
\end{document}

# mytablefile.tex

% arara: pdflatex
\documentclass[varwidth]{standalone}

\usepackage{longtable}

\begin{document}

\begin{longtable}{cc}
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
1 & 2 \\
\end{longtable}
\end{document}
-
thanks, worked. As a small side question, this is doable only including the .tex file directly, it would not be possible to do with a pdf, is this correct? –  JackO Dec 15 '13 at 21:40
@JackO including the pdf suffers from the drawbacks detailed in my answer; if you generate a 'stand alone' pdf file, you will have to insert the breaks yourself, perhaps using the pdfpages packages or something similar. –  cmhughes Dec 15 '13 at 22:16