Featured Book

LaTeX Beginners Guide

Who is online

In total there are 19 users online :: 1 registered, 0 hidden and 18 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Bing [Bot] and 18 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Centered contents in LaTeX tables

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

Centered contents in LaTeX tables

Postby Bluemilk on Sun Jun 8th, 2008

Hi all,

The headers in my LaTeX tables have quite a bit of text. So I had to use the p command to specify the width of the column. Problem is, in the actual table, the contents of the cell are not centered, that is, I want my \checkmark command to be in the center of that cell. How do I solve this problem?

Code: Select all  •  Open in writeLaTeX
\begin{table}
\begin{center}
\begin{tabular}{lp{2cm}p{2cm}p{2cm}p{2cm}p{2cm}p{2cm}}
\toprule
\multirow{3}{*}{\textbf{Weather}} & \multicolumn{3}{c}{Rain in Spain} & \multicolumn{3}{c}{Rain In Italy} \\ \cmidrule(r){2-4} \cmidrule{5-7} &  Information here & Information here & Information here & Information here & Information here & Information here \\ \midrule
HAHA & & \checkmark & & & & \\
\bottomrule
\end{tabular}
\end{center}
 \caption[MAC finalisation classification scheme]{MAC finalisation classification scheme}
\label{MACclasstable}
 \end{table
}


Added in some arbitrary data in my code. My actual contents are not so nonsensical. :)
Bluemilk
 
Posts: 5
Joined: Sun Jun 8th, 2008

Re: Centered contents in LaTeX tables

Postby Stefan_K on Sun Jun 8th, 2008

Hi Bluemilk,

welcome to the LaTeX Community Forum!

You could use >{\centering\arraybackslash} right before the p column:
Code: Select all  •  Open in writeLaTeX
\begin{tabular}{lp{2cm}>{\centering\arraybackslash}p{2cm}p{2cm}p{2cm}p{2cm}p{2cm}}

You can find more information in the array documentation.

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6269
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Centered contents in LaTeX tables

Postby Bluemilk on Sun Jun 8th, 2008

thanks! that worked like a charm! :)
Bluemilk
 
Posts: 5
Joined: Sun Jun 8th, 2008


Return to General

Who is online

Users browsing this forum: Bing [Bot] and 18 guests