Graphics, Figures & TablesCentre a table column heading?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Centre a table column heading?

Post by stinkinrich88 »

Hello,

How do I centre the column headings in a table, please?

Thank you,

Richard

Oh, p.s. Do you think column headings should be centred? It's a very simple table containing text for my final year project report.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centre a table column heading?

Post by localghost »

stinkinrich88 wrote:[...] Oh, p.s. Do you think column headings should be centred? It's a very simple table containing text for my final year project report.
I wonder what keeps you from presenting the code for that table. It would make things easier to see.


Best regards
Thorsten¹
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Centre a table column heading?

Post by stinkinrich88 »

Apologies, the code is below:

Code: Select all

\begin{tabular}{|l|l|p{4.8cm}|}
	\hline
	col1 & col2 & col3 \\ \hline
	1 & Some text & A sentence in this cell. \\ \hline
	2 & More text & \multirow{2}{4.8cm}{A sentence text describing two rows} \\ \cline{1-2}
	3 & More text & \\ \hline
\end{tabular}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centre a table column heading?

Post by localghost »

You can center the column headings with a trick.

Code: Select all

\begin{tabular}{|c|l|p{4.8cm}|} \hline
   col1 & \multicolumn{1}{c|}{col2} & \multicolumn{1}{c|}{col3} \\ \hline
   1 & Some text & A sentence in this cell. \\ \hline
   2 & More text & \multirow{2}{4.8cm}{A sentence text describing two rows} \\ \cline{1-2}
   3 & More text & \\ \hline
\end{tabular}
Think about tables without vertical lines and take a look at the booktabs package.
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Re: Centre a table column heading?

Post by stinkinrich88 »

ahh neat-o, thanks! I tried something like this before but the vertical lines were a *tiny* bit out of line. Thank you very much, I'll definitely take a look at that package, too!
Post Reply