5

I have am creating a number of latex tables from another program and want to automatically view them after they are created. They are automatically created without a \begin{document} but instead with \begin{table}. Is there any way to compile the table files without imputing them into another latex document or editing the .tex file to include \begin{document} etc. ?

Ex. I would like to compile and view the following .tex file without having to edit it. Is this possible?

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Last Job Summary Statistics}
\begin{tabular}{l*{1}{ccccc}}
\hline\hline
                    &        Mean&          SD&         Min&         Max&Non-missing Obs\\
\hline
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\\
\hline\hline
\multicolumn{6}{l}{\footnotesize Estimates weighted using sample weights}\\
\end{tabular}
\end{table}
  • Are you using Windows, Linux or Mac? – jotagah Oct 27 '14 at 2:26
  • 1
    why *{1}{ccccc} not *{5}{c} ? – David Carlisle Oct 27 '14 at 2:28
  • Windows and the below answer works great. – ZyzotPerplex Oct 27 '14 at 2:50
8

If the posted code is tab1.tex then a command line of

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

produces article.pdf that looks like:

enter image description here

(You might need different quote or to use \\ for each \ depending on your commandline shell, the above is bash)

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.