LaTeX forum ⇒ Graphics, Figures & TablesCentering while text wrapping in table

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

Centering while text wrapping in table

Postby yotama9 » Mon Nov 09, 2009 5:42 pm

Hi guys.

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

Thanks.

Yotam

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Postby gmedina » Mon Nov 09, 2009 5:54 pm

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

  1. \documentclass{article}
  2. \usepackage{array}
  3. \usepackage{lipsum}
  4.  
  5. \begin{document}
  6.  
  7. \begin{tabular}{>{\centering\arraybackslash}p{4cm}}
  8. \lipsum[1]
  9. \end{tabular}
  10.  
  11. \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

Postby yotama9 » Thu Nov 12, 2009 11:30 am

gmedina, the solution you gave me worked perfectly.

The table was:
  1. \begin{table} %table pKa* calculation
  2. \begin{center}
  3. \begin{tabular}{|c|p{1.8cm}|c|c|c|c|c|c|c|}
  4. \hline
  5. molecule
  6. &solution composition&$pK_a$
  7. &$\lambda^{acid}_g$ &$\lambda^{acid}_{ex}$ &$\lambda^{base}_g$ &$\lambda^{base}_{ex}$
  8. &$pK_a^*$ &$-\Delta pK_a ^*$
  9. \\ \hline
  10. \cellcolor[gray]{0.8}
  11. &$X_{weight}^\ce{MeOH}$ &\cellcolor[gray]{0.8} &\multicolumn{4}{c}{nm} &\cellcolor[gray]{0.8} &\cellcolor[gray]{0.8} \\ \hline
  12.  
  13. \multirow{6}{*}{APMS}
  14. &0 &3.4
  15. &349 &378 &398 &476
  16. &16.3 &0\\ \cline{2-9}
  17. ...
  18. \end{table}

and I fixed it to:
  1. \begin{table} %table pKa* calculation
  2. \begin{center}
  3. \begin{tabular}{|c|>{\centering\arraybackslash}p{1.8cm}|c|c|c|c|c|c|c|}
  4. \hline
  5. molecule
  6. &solution composition&$pK_a$
  7. &$\lambda^{acid}_g$ &$\lambda^{acid}_{ex}$ &$\lambda^{base}_g$ &$\lambda^{base}_{ex}$
  8. &$pK_a^*$ &$-\Delta pK_a ^*$
  9. \\ \hline
  10. \cellcolor[gray]{0.8}
  11. &$X_{weight}^\ce{MeOH}$ &\cellcolor[gray]{0.8} &\multicolumn{4}{c}{nm} &\cellcolor[gray]{0.8} &\cellcolor[gray]{0.8} \\ \hline
  12.  
  13. \multirow{6}{*}{APMS}
  14. &0 &3.4
  15. &349 &378 &398 &476
  16. &16.3 &0\\ \cline{2-9}
  17. ...
  18. \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

Postby gmedina » Thu Nov 12, 2009 4:32 pm

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,...


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests