3

I have a PDF document, which contains a table over multiple pages. I need to include this PDF as a single long/multipage table in the PDF document.

I tried:

\begin{table}[]
    \includegraphics[clip, trim=2cm 2cm 2cm 2cm, page=1, width=\textwidth]{table.pdf} 
    \includegraphics[clip, trim=2cm 2cm 2cm 2cm, page=2, width=\textwidth]{table.pdf} 
    \caption{Example}
\end{table}

The result looks as follows:

Latex table

The 2nd page of the PDF goes into the footer of the page.

A solution for multipage figures can be seen here: https://stackoverflow.com/a/1089881/605890

You can find a mwe here: https://github.com/boldt/latex-table

3
  • a table environment is a box, which can not break, just remove it May 28, 2014 at 18:58
  • But I need it as a table; and to be listed in the list of tables. The solution from Heiko Oberdiek is already really good.
    – Dennis
    May 29, 2014 at 13:40
  • yes the first of Heiko's suggestions was what I intended by my comment:-) May 29, 2014 at 13:47

2 Answers 2

7

There are many ways.

\includegraphics with \captionof

The table document is trimmed via pdfcrop table.pdf.

The caption is added by \captionof. The continued caption uses an empty optional argument of \captionof to avoid another entry in the list of tables.

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\listoftables

\bigskip
\begingroup
  \centering
  \includegraphics[page=1, width=\linewidth]{table-crop.pdf}
  \captionof{table}{Example}
  \newpage
  \includegraphics[page=2, width=\linewidth]{table-crop.pdf}%
  \addtocounter{table}{-1}%
  \captionof{table}[]{Example (cont.)}
  \par
\endgroup
\end{document}

Page 1

Page 2

Package pdfpages

Multiple documents can also be included via package pdfpages:

\includepdf[pages=-]{table.pdf}

But the placement of the caption is not so easy.

CSV data

If you are the creator of the table, then you can save it as .csv file and import it in LaTeX. Example with package csvsimple and longtable:

\documentclass{article}
\usepackage{longtable}
\usepackage{csvsimple}
\begin{document}
\csvreader[
  longtable=lll,
  head,
  table head={%
    \bfseries Name & \bfseries Value & \bfseries Text\\\hline\endhead
    \caption{Example}\endlastfoot
  },
]{test-table.csv}{
  Name=\colname,
  Value=\colvalue,
  Text=\coltext
}{%
  \colname & \colvalue & \coltext
}
\end{document}

And the data file test-table.csv:

Name,Value,Text
Test 1,1,A
Test 2,2,B
Test 3,3,A
Test 4,4,B
Test 5,5,A
Test 6,6,B
Test 7,7,A
Test 8,8,B
Test 9,9,A
Test 10,10,B
Test 11,11,A
Test 12,12,B
Test 13,13,A
Test 14,14,B
Test 15,15,A
Test 16,16,B
Test 17,17,A
Test 18,18,B
Test 19,19,A
Test 20,20,B

Result

Advantages are more control over the table layout, page breaks, ...

3
  • I am not the creator of the table, so I don't want to tex the whole table. I like the captionof solution. I like to trim the pdf with latex itself trim=2cm 2cm 2cm 2cm. It works really good. I changes figure to table. Is there any way to have a caption on all pages? Like "Table 1", "Table 1 cont." ... whatever?
    – Dennis
    May 29, 2014 at 13:38
  • @Dennis: \captionof can also be used to generate the following captions, see the updated example. May 29, 2014 at 18:15
  • first solution works definitely in the most reliable way.
    – joaoal
    Jan 23, 2020 at 10:58
0

I used this one because I needed it on my table list.

\begin{table}[ht]
\caption{Example of table.}
\label{tbl:table-crop}
\tiny
\centering
\rowcolors{1}{}{lightgray}
\includegraphics[page=1, width=\linewidth]{table-crop.pdf}
\par\medskip\ABNTEXfontereduzida\selectfont\textbf{Fonte:} Myself (2022) \par\medskip
\end{table}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .