Graphics, Figures & TablesRemoving column separators from table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
krislodz
Posts: 42
Joined: Sun Nov 08, 2009 1:13 pm

Removing column separators from table

Post by krislodz »

Hello,

I would like to create a table where the last row contains just one column, as sort of sum as shown on the example below:

Code: Select all

\begin{tabular}{|l|l|}
  \hline
  Product & Price \\ \hline
  Sugar & 2.5 \\ \hline
  Butter & 4.1 \\ \hline
  Milk & 1.2 \\ \hline
  & TOTAL: 7.7 \\
  \hline
\end{tabular}
I would like to have just TOTAL column in last row. Is there simple solution?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Removing column separators from table

Post by gmedina »

Hi,

you could use a \multicolumn and a \cline commands. Perhaps you could be interested in some of the features offered by the booktabs package to improve your tables. In the following code I produced two variations of your table; the second one uses booktabs (and is, of course, nothing more than a suggestion):

Code: Select all

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{|l|l|}
  \hline
  Product & Price \\ \hline
  Sugar & 2.5 \\ \hline
  Butter & 4.1 \\ \hline
  Milk & 1.2 \\ \hline
  \multicolumn{1}{l|}{}& TOTAL: 7.7 \\
  \cline{2-2}
\end{tabular}

\vspace{1cm}

\begin{tabular}{ll}
  \toprule
  \textbf{Product} & \textbf{Price} \\ 
  \cmidrule(r{8pt}){1-1}\cmidrule{2-2}
  Sugar & 2.5 \\ 
  Butter & 4.1 \\ 
  Milk & 1.2 \\   
  \cmidrule(l{15pt}r{15pt}){1-2}
  \multicolumn{2}{c}{\hspace*{-1.3pt}TOTAL: 7.7}\\
  \bottomrule
\end{tabular}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
krislodz
Posts: 42
Joined: Sun Nov 08, 2009 1:13 pm

Re: Removing column separators from table

Post by krislodz »

Thanks a lot, second example is nice, not for what i am doing now, but maybe for future.
Post Reply