Graphics, Figures & TablesCentering while text wrapping in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

Centering while text wrapping in table

Post by yotama9 »

Hi guys.

Is there a way to wrap a text while centerting the whole column in a table?

Thanks.

Yotam

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

Centering while text wrapping in table

Post by gmedina »

Perhaps a more descriptive query would help us to provide effective help. Anyway, the array package offers some features that could help:

Code: Select all

\documentclass{article}
\usepackage{array}
\usepackage{lipsum}

\begin{document}

\begin{tabular}{>{\centering\arraybackslash}p{4cm}}
  \lipsum[1]
\end{tabular}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

Centering while text wrapping in table

Post by yotama9 »

gmedina, the solution you gave me worked perfectly.

The table was:

Code: Select all

\begin{table} %table pKa* calculation
    \begin{center}
	\begin{tabular}{|c|p{1.8cm}|c|c|c|c|c|c|c|}
	   \hline
	   molecule
	   &solution composition&$pK_a$
	   		&$\lambda^{acid}_g$	&$\lambda^{acid}_{ex}$	&$\lambda^{base}_g$	&$\lambda^{base}_{ex}$
	   			&$pK_a^*$	&$-\Delta pK_a ^*$
	   \\ \hline
	   \cellcolor[gray]{0.8}
	   &$X_{weight}^\ce{MeOH}$	&\cellcolor[gray]{0.8}	&\multicolumn{4}{c}{nm}	&\cellcolor[gray]{0.8}				&\cellcolor[gray]{0.8} \\ \hline
	   
	   \multirow{6}{*}{APMS}
	   &0		&3.4
	   		&349				&378				&398				&476
	   			&16.3		&0\\ \cline{2-9}
...
\end{table}
and I fixed it to:

Code: Select all

\begin{table} %table pKa* calculation
    \begin{center}
	\begin{tabular}{|c|>{\centering\arraybackslash}p{1.8cm}|c|c|c|c|c|c|c|}
	   \hline
	   molecule
	   &solution composition&$pK_a$
	   		&$\lambda^{acid}_g$	&$\lambda^{acid}_{ex}$	&$\lambda^{base}_g$	&$\lambda^{base}_{ex}$
	   			&$pK_a^*$	&$-\Delta pK_a ^*$
	   \\ \hline
	   \cellcolor[gray]{0.8}
	   &$X_{weight}^\ce{MeOH}$	&\cellcolor[gray]{0.8}	&\multicolumn{4}{c}{nm}	&\cellcolor[gray]{0.8}				&\cellcolor[gray]{0.8} \\ \hline
	   
	   \multirow{6}{*}{APMS}
	   &0		&3.4
	   		&349				&378				&398				&476
	   			&16.3		&0\\ \cline{2-9}
...
\end{table}
Can you please explain the syntax or point to someplace were there is an explanation?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Centering while text wrapping in table

Post by gmedina »

yotama9 wrote:...Can you please explain the syntax or point to someplace were there is an explanation?
The first pages of the array package documentation contain an explanation.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply