LaTeX forum ⇒ Graphics, Figures & TablesData Alignment and Improvements for a Table

Information and discussion about graphics, figures & tables in LaTeX documents.
adhraklasoon
Posts: 6
Joined: Sun Sep 09, 2012 6:08 pm

Data Alignment and Improvements for a Table

Postby adhraklasoon » Sat Oct 13, 2012 11:50 pm

Hi,

I have a table that looks half decent. A fellow member actually helped me out with another table and I tried to copy-paste some of the code to this one. But the alignment of the data is not OK. Its left aligned on 2 rows and center aligned in the others. I want it center aligned for all rows but don't know how to fix it. Help!

Also, any tips for making the table look more professional would be highly appreciated.

Thank you in advance!
Cheers
Sonia
Attachments
samplefile2.tex
(1.42 KiB) Downloaded 157 times

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Sun Oct 14, 2012 1:00 am

I believe it was me who answered your previous question. Since it's late right now I only have this advice for now: I used the siunitx package to align the data. If you haven't yet you should read its documentation about tabular material: siunitx

Good night
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Mon Oct 15, 2012 10:40 am

Here is what I would do. Use siunitx' possibility to treat numbers with uncertainties and choose a suiting table-format and make the mid rule span the whole table:

  1. \documentclass{article}
  2.  
  3. \usepackage{booktabs,siunitx}
  4. \setlength\heavyrulewidth{1pt}
  5.  
  6. \begin{document}
  7.  
  8. \begin{table}[ht]
  9. \centering
  10. \sisetup{
  11. separate-uncertainty = true,
  12. table-space-text-post = *,
  13. table-align-text-post = false,
  14. range-phrase = --,
  15. range-units = single
  16. }
  17. \begin{tabular}{l*3{S[table-format=3.1(3)]}}
  18. \toprule
  19. & {\SIrange{50}{59}{yr} (50s)}
  20. & {\SIrange{60}{69}{yr} (60s)}
  21. & {\SIrange{70}{79}{yr} (70s)} \\
  22. \midrule
  23. \textit{Male} & {$n=40$} & {$n=50$} & {$n=49$} \\
  24. Age, yr & 55.2(31) & 65.5(29) & 73.7(29) \\
  25. Height, \si{cm} & 174.6(61) & 174.2(57) & 171.3(74)* \\
  26. Body mass, \si{kg} & 78.3(114) & 78.9(105) & 78.4(125) \\
  27. \midrule
  28. \textit{Female} & {$n=42$} & {$n=52$} & {$n=50$} \\
  29. Age, yr & 54.7(29) & 65.4(29) & 73.7(24) \\
  30. Height, \si{cm} & 162.9(69) & 163.2(62) & 160.8(57)* \\
  31. Body mass, \si{kg} & 66.8(117) & 67.9(100) & 64.7(109) \\
  32. \bottomrule
  33. \end{tabular}
  34. \caption[Subject characteristics: age, height, body mass]{Subject characteristics:
  35. Values are Mean $\pm$ SD; $n$=number of subjects; Males are significantly
  36. taller ($P<0.05$) and heavier ($P<0.05$) than women in all age groups.
  37. *Significantly different from all other groups ($P<0.05$). }
  38. \label{subject-characs}
  39. \end{table}
  40.  
  41. \end{document}


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests