I would like to generate a pdf document by compiling a table using pdflatex. For that I checked this but the result there is a complete a4 page. is there a way to generate a pdf that has the size of the table. For example let's assume we have the following table saved in tab1.tex from here:

\caption{Last Job Summary Statistics}
                    &        Mean&          SD&         Min&         Max&Non-missing Obs\\
Held more than one job&        0.08&        0.28&           0&           1&        6010\\
Total hours from all jobs&       41.82&       12.55&           0&         150&        5089\\
Lost last job       &        0.78&        0.42&           0&           1&        6025\\
Quit last job       &        0.05&        0.21&           0&           1&        6025\\
Last job ended temporarily&        0.16&        0.36&           0&           1&        6025\\
Last job notice in weeks&        1.85&        5.60&           0&          97&        4959\\
Tenure (years) in last job&        4.65&        6.37&           0&          48&        5974\\
Received severance pay&        0.19&        0.39&           0&           1&        5959\\
Amount of severance pay&    26156.30&    75819.30&           1&     1000000&        1399\\
Expect to be recalled to last job&        0.14&        0.35&           0&           1&        5979\\
\multicolumn{6}{l}{\footnotesize Estimates weighted using sample weights}\\

compiling this with:

pdflatex '\documentclass{article}\begin{document}\input{tab1}\end{document}'

produces: enter image description here

what we would like to have is the trimmed pdf file containing only the table that would look like:

enter image description here

Does anybody have an idea of how to generate the pdf of a table like above?

  • have a look at the standalone class :) and for your decimal columns, have a look at siunitx – cmhughes Apr 6 '16 at 12:58

One additional step, but might be of interest anyway:

Add \pagestyle{empty} to the preamble, so you have

pdflatex '\documentclass{article}\pagestyle{empty}\begin{document}\input{tab1}\end{document}'

and then run

pdfcrop article.pdf

where article.pdf is the file made by pdflatex. This produces a file article-crop.pdf. pdfcrop is a command line tool included in TeX Live and MikTeX. Without arguments it will crop away the outer whitespace from a PDF.


try this


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.