Discussion:
How to get tables as graphics
Cecil Westerhof
2020-05-27 17:42:35 UTC
I have the following code:
\documentclass{article}

\begin{document}

\begin{table}
\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & A & \\
\hline
& & & A \\
\hline
& A & & \\
\hline
\end{tabular}
\end{table}

\begin{table}
\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & & A \\
\hline
& A & & \\
\hline
& & A & \\
\hline
\end{tabular}
\end{table}

\end{document}

Works reasonable, but I have two problems with it:
- I want the tables beside each-other instead of the second below the
first.
- I want a png file that exactly contains the two tables and not a
complete A4 page.

How would I accomplish this?
--
Cecil Westerhof
Senior Software Engineer
samcarter8
2020-05-27 18:13:59 UTC
Post by Cecil Westerhof
- I want the tables beside each-other instead of the second below the
first.
Put them in one table environment (or leave it out completly) without
empty lines between them. If they are small enough to fit in one line,
they will then appear in one line
Post by Cecil Westerhof
- I want a png file that exactly contains the two tables and not a
complete A4 page.
Have a look at the standalone documentclass

\documentclass[convert]{standalone}
\begin{document}

\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & A & \\
\hline
& & & A \\
\hline
& A & & \\
\hline
\end{tabular}
\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & & A \\
\hline
& A & & \\
\hline
& & A & \\
\hline
\end{tabular}

\end{document}
Cecil Westerhof
2020-05-27 20:10:15 UTC
Post by samcarter8
Post by Cecil Westerhof
- I want the tables beside each-other instead of the second below the
first.
Put them in one table environment (or leave it out completly) without
empty lines between them. If they are small enough to fit in one line,
they will then appear in one line
Post by Cecil Westerhof
- I want a png file that exactly contains the two tables and not a
complete A4 page.
Have a look at the standalone documentclass
That works like a charm. I now have:
\documentclass{standalone}

\begin{document}

\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & A & \\
\hline
& & & A \\
\hline
& A & & \\
\hline
\end{tabular}
\hspace{2cm}
\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & & A \\
\hline
& A & & \\
\hline
& & A & \\
\hline
\end{tabular}

\end{document}

I still have one little problem. ;-)

I have several sets of tables. I could create a LaTeX document for
every set, but it would really be nice if I could have one document
that creates the different sets of tables as different graphics.
Would this be possible?
--
Cecil Westerhof
Senior Software Engineer
Rolf Niepraschk
2020-05-29 18:18:29 UTC
Am 27.05.20 um 22:10 schrieb Cecil Westerhof:
...
Post by Cecil Westerhof
I still have one little problem. ;-)
I have several sets of tables. I could create a LaTeX document for
every set, but it would really be nice if I could have one document
that creates the different sets of tables as different graphics.
Would this be possible?
Try the following:

% ---------------------- allGraphics.tex -------------
\documentclass{article}
\usepackage[active,tightpage,displaymath]{preview}

\begin{document}

\PreviewEnvironment{tabular}

\begin{table}
\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & A & \\
\hline
& & & A \\
\hline
& A & & \\
\hline
\end{tabular}
\end{table}

\begin{table}
\begin{tabular}{|l|l|l|l|}
\hline
AD & KH & QS & JC \\
\hline
& & & A \\
\hline
& A & & \\
\hline
& & A & \\
\hline
\end{tabular}
\end{table}

\end{document}
% ------------------------------------------------

Eeach tabular environment leads to a single page in the resulting pdf
document. The individual graphic can be used in another document using e.g.

\includegraphics[pages=2]{allGraphics.pdf}

...Rolf