2

I have a complex excel table that I would like to include in my paper. I have converted the table as a pdf file and I am including into my paper as follows:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
    \begin{table}[H]
    \begin{center}
        \includepdf{tables/table1.pdf}
    \end{center}
\end{table}
\end{document}

Unfortunately, this table suffers from two problems:

  • The table is positioned on top of existing text.
  • The table is not centered as I expected. Instead, left justified. Would some LaTeX gurus please explain to me how:
  • To properly add a pdf table to LaTeX.
  • How to make sure that LaTeX treat the table as a table (for reference and caption purpose).
  • Am I doing this right? It seems that most forums suggest that I use tools such as Excel2LaTeX to convert my excel file to LaTeX code. In my view, this will make the task more complex as I need to change the table several time and formatting is time-consuming.
  • 5
    I'd assume \includegraphics from the graphicx package is more suitable. Also, the \centering command instead of a center environment will reduce extra whitespace above and below the PDF. The H position for a table is likely being ignored, since it's not a standard position, and even the standard h position is often changed to ht. – Mike Renfro Mar 31 '17 at 03:07
  • @MikeRenfro thanks for the suggestions. After using \includegraphics and \centering command, I noticed that now the pdf image is no longer overlapping with the text. However, it is skewed to the right in way that hides half of the image. Any suggestion to solve this? – Dillion Ecmark Mar 31 '17 at 03:44
  • 3
    You can use the width option for includegraphics, but keep in mind: you cannot fit an elephant into a suitcase. – Johannes_B Mar 31 '17 at 05:36

1 Answers1

2

Use either:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf{tables/table1}
\end{document}

That will add tables/table1.pdf on its own page or use

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\begin{table}
  \centering% do not use center environment!
  \includegraphics[width=\textwidth,height=.9\textheight,keepaspectratio]{tables/table1}
  \caption{This is a table}
\end{table}

\lipsum[2]
\end{document}

That will add a float with the table in the text area of your document, printed where the float parameters allow to print it.

Note, using a current LaTeX release, \begin{figure}[H] even results in an error message unless you use a package, that provides option H to floats.

Schweinebacke
  • 26,336