Beautiful tables in Latex
Producing tables is latex is not an easy task. Fortunately I found a very handy macro that transforms Excel tables into Latex code. It is written by Joachim Marder and can be obtained here. If you use OpenOffice you can take a look at calc2latex. With the table creation problem solved, now we can focus on improving the style. We are going to need the following packages:
\usepackage[dvipsnames,usenames]{color} \usepackage{array} \usepackage{colortbl} \usepackage{booktabs}
Next we specify some formatting commands:
%increase the column separation and the cell height \renewcommand{tabcolsep}{0.25cm} \renewcommand{arraystretch}{2} %We can define our custom colors in RGB format \definecolor{tableheading}{rgb}{0.82,0.82,0.82} \definecolor{softblue}{rgb}{0.8,0.8,1} %Change the bar color \arrayrulecolor{ForestGreen}
… and voila! Latex has produced a very stylish table.
This is the full latex source code:
\documentclass[12pt,a4paper]{report} \usepackage[utf8x]{inputenc} \usepackage{ucs} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{makeidx} \usepackage[dvipsnames,usenames]{color} \usepackage{array} \usepackage{colortbl} \usepackage{booktabs} \renewcommand{tabcolsep}{0.25cm} \renewcommand{arraystretch}{2} \definecolor{tableheading}{rgb}{0.82,0.82,0.82} %definecolor{totalcolor}{rgb}{1,0.7,0.7} %definecolor{firstcolumncolor}{rgb}{0.7,1,0.7} \definecolor{softblue}{rgb}{0.8,0.8,1} \arrayrulecolor{ForestGreen} \begin{document} % Table generated by Excel2LaTeX from sheet 'material' \begin{table}[!h] \centering \begin{tabular}{ccccc} \toprule \rowcolor{tableheading} {bf ID} & {bf Description} & {bf Price} & {bf Redeem period} & {bf Redeemed cost} \ \midrule M1 & PC 1 & 500,00 & 9,00 & 150,00 \ \midrule M2 & PC 2 & 500,00 & 9,00 & 150,00 \ \midrule M3 & Server 1 & 1.000,00 & 9,00 & 250,00 \ \midrule \textit{Total} & & & & multicolumn{1}{>{columncolor{softblue}}c}{550,00} \ \bottomrule \label{tab:test} \end{tabular} \caption{Test table} \end{table} \end{document}
Get Jorge Martinez de Salinas delivered by email