# LaTeX Table Generator

I'm new in Latex and I should deal with huge number of tables in different ways and limited time, for that I used LaTeX Table Generator website to make the process easier.

Could you guys tell me what I can add to the code which generated by the website without changing in the code formula to generate the tables with unified size and unified font size.

code examples:

\usepackage{graphicx}
\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|r|}
\hline
\multicolumn{3}{|c|}{Item}        \\ \hline
Animal & Description & Price (\$) \\ \hline Gnat & per gram & 13.65 \\ \hline & very long text & 0.01 \\ \hline \end{tabular} } \end{table}  Example 2 \usepackage{multirow} \usepackage{graphicx} \begin{table}[h] \resizebox{\textwidth}{!}{% \begin{tabular}{|l|l|r|} \hline \multicolumn{1}{|c|}{Animal} & Description & Price (\$) \\ \hline
\multirow{2}{*}{Gnat}        & per gram    & 13.65      \\ \cline{2-3}
& each        & 0.01       \\ \hline
Gnu                          & stuffed     & 92.50      \\ \hline
\end{tabular}
}
\end{table}


Thank you.

• Remove the \resizeboxes, replacing with a suitable font size command if necessary (e.g. \small). The third argument of the \resizebox (the tabular itself) should be retained. – Paul Gessler Jun 19 '14 at 11:58
• does the generator really add \resizebox{\textwidth}{!}{% that's a bug:-) – David Carlisle Jun 19 '14 at 12:26
• You can also automate the table creation. If you have a list of CSV values, you could use the csvtools package. You can also use the pgfplotstable package. – user10274 Jun 19 '14 at 12:32
• If you have your tables on a spreadsheet software like excel you can use excel2Latex too. – Smarzaro Nov 18 '14 at 1:57

I'm not sure which table generator you're using, but always having the \resizeboxes is a really bad idea. As you've noticed, you get inconsistent font sizes and distorted rules. You might want to check if there is an option to turn this off in whichever software/web app/etc. you're using for this.

The immediate fix is to comment out the \resizebox line and its corresponding closing brace, like this:

\begin{table}[h]
%\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|r|}
\hline
\multicolumn{3}{|c|}{Item}        \\ \hline
Animal & Description & Price (\$) \\ \hline Gnat & per gram & 13.65 \\ \hline & very long text & 0.01 \\ \hline \end{tabular} %} \end{table}  This will get rid of the drastic resizing. If the table ends up being too wide for the text, you can insert \small or any other font size command inside the tabular environment. This will allow more controlled adjustment of the font size, so it's at least consistent with other font sizes in your document. In the full code, I also show some capabilities of the excellent booktabs package for better layout of tables. Some table code generators support booktabs natively (excel2latex and probably others) or you can add the markup manually. \documentclass{article} \usepackage{booktabs,multirow} \setcounter{totalnumber}{4} % just so they all fit on the page \begin{document} Example 1: \begin{table}[h] %\resizebox{\textwidth}{!}{% \begin{tabular}{|l|l|r|} \hline \multicolumn{3}{|c|}{Item} \\ \hline Animal & Description & Price (\$) \\ \hline
Gnat   & per gram    & 13.65      \\ \hline
& very long text       & 0.01       \\ \hline
\end{tabular}
%}
\end{table}

Example 2 (also illustrating \verb+\centering+):
\begin{table}[h]
\centering
%\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|r|}
\hline
\multicolumn{1}{|c|}{Animal} & Description & Price (\$) \\ \hline \multirow{2}{*}{Gnat} & per gram & 13.65 \\ \cline{2-3} & each & 0.01 \\ \hline Gnu & stuffed & 92.50 \\ \hline \end{tabular} %} \end{table} After \verb+booktabs+-ification (optional): \begin{table}[h] \centering \begin{tabular}{llr} \toprule \multicolumn{3}{c}{Item} \\ \cmidrule(lr){1-3} Animal & Description & Price (\$) \\ \midrule
Gnat   & per gram       & 13.65      \\
& very long text & 0.01       \\ \bottomrule
\end{tabular}
\end{table}

\begin{table}[h]
\centering
\begin{tabular}{llr}
\toprule
Animal                & Description & Price (\\$) \\ \midrule
\multirow{2}{*}{Gnat} & per gram    & 13.65      \\
& each        & 0.01       \\ \addlinespace
Gnu                   & stuffed     & 92.50      \\ \bottomrule
\end{tabular}
\end{table}

\end{document}