GeneralCenter alligning entries of a table

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
shaikster
Posts: 9
Joined: Sat Sep 27, 2008 12:14 am

Center alligning entries of a table

Post by shaikster »

I am having trouble center alligning the contents of my table. I am using the array package. Below is the code.
\begin{center}
\newcommand{\mc}[3]{\multicolumn{#1}{#2}{#3}}
\scriptsize
%\renewcommand{\multirowsetup}{\centering}
%\renewcommand{\multicolumnsetup}{\centering}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}
%\begin{tabular}{|m{0.6in}|m{0.4in}|m{0.4in}|m{0.45in}|m{0.4in}|m{0.45in}|m{0.4in}|m{0.45in}|m{0.4in}|m{0.45in}|}
\hline
% First row
\mc{2}{|c|}{\multirow{2}{*}{2.75xBW=550 lbs}} & \multicolumn{2}{m{0.8in}|}{28 mm ball diamter} & \mc{2}{m{0.8in}|}{56 mm ball diameter} & \mc{2}{m{0.8in}|}{28 mm ball diamter} & \mc{2}{m{0.8in}|}{56 mm ball diameter} \\ \cline{3-10}
%Second row
\mc{2}{|c|}{} & \mc{1}{m{0.4in}|}{CPS4 Stresses in neck region (MPa)} & \mc{1}{m{0.4in}|}{CPS4 Stresses in contact region (MPa)} & \mc{1}{m{0.4in}|}{CPS4 Stresses in neck region (MPa)} & \mc{1}{m{0.4in}|}{CPS4 Stresses in contact region (MPa)} & \mc{1}{m{0.4in}|}{CPE4 Stresses in neck region (MPa)} & \mc{1}{m{0.4in}|}{CPE4 Stresses in contact region (MPa)} & \mc{1}{m{0.4in}|}{CPE4 Stresses in neck region (MPa)} & \mc{1}{m{0.4in}|}{CPE4 Stresses in contact region (MPa)} \\ \hline
\end{tabular}
\end{center}

My objectives are:
(1) To get the first entry which is spanned by 2 columns and 2 rows to be alligned at the center. Presently, it is alligned close to the center of the first row (please look at the picture).
(2) How do I get center allignment horizontally for the contents of the other columns? I can get this by specifying \centering in every entry of the column. Is there a easier way to do this??

I would appreacite all suggestions to solve my problem.

Thank you
Last edited by shaikster on Mon Sep 29, 2008 2:59 pm, edited 1 time in total.

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Center alligning entries of a table

Post by Stefan Kottwitz »

Hi shaikster,

why do you declare c columns but use frequently \mc{1}{m{0.4in}|} ?
You could do it this way:

Code: Select all

\begin{tabular}{|c|>{\centering}m{0.4in}|...}
m gives you middle aligned paragraph cells, >{\centering} centers the content.

Stefan
LaTeX.org admin
shaikster
Posts: 9
Joined: Sat Sep 27, 2008 12:14 am

Re: Center alligning entries of a table

Post by shaikster »

Thank you again Stefan..I was a ble to get the contents of all columns in the center except for the contents of first multicolumn and multirow box..These contents still seem to be alligned more on top rather than the center.

Thank you
Post Reply