Graphics, Figures & Tablescenteralising the content in table heading

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

centeralising the content in table heading

Post by dmuthu_cse »

Hello all,

I am trying to center my table headings.. which is present in first row.

But, when i try to do this with

Code: Select all

\begin{tabular}{|c|c|c|} \hline
Socket outlets& 6A & 16A \\ \hline
Bed rooms &	2-3 & 1 \\ \hline
Living rooms & 2-3 &	2 \\ \hline
Bath rooms & 1 & 1  \\ \hline
\end{tabular}
\end{table}
The total column gets centralised. In the above ex: I wanted to center "Socket outlets".. but
Bed rooms, Living rooms also gets centralised...

Any suggestions to solve. Thanks in advance.

Regards,
Muthu.

Recommended reading 2024:

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

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

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

centeralising the content in table heading

Post by josephwright »

\multicolumn is what you want:

Code: Select all

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ l c c }
  \toprule
  \multicolumn{1}{c}{Socket outlets} & 6A & 16A \\ 
  \midrule
  Bed rooms &   2-3 & 1 \\ 
  Living rooms & 2-3 &   2 \\
  Bath rooms & 1 & 1  \\ 
  \bottomrule
\end{tabular}
\end{document}
\multicolumn has independent alignment, so can be used to override the situation in a single cell. I've also used the booktabs package above, as printed tables should not normally look like grids.
--
Joseph Wright
Joseph Wright
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

Re: centeralising the content in table heading

Post by dmuthu_cse »

Dear Joseph,

Thanks.. It is working fine..

Regards,
Muthu
Post Reply