Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am brand new to LaTex, and I am trying to create a report displaying statistical data, for an academic publication.

The table is quite a large one, consisting of several nested columns, and is 23 cells wide in the data region (away from the titles etc). The publication is in A4 format, so the table has to fit into an A4 page (portrait format).

I remember reading somewhere that Serif fonts should NOT be used for tabular data, so at least I know that I have to use a san serif font. However, this is my first foray into using LaTeX, and would appreciate some advice from the more seasoned pros in here.

I would be very grateful if someone could recommend (best practise) font and font size to use for the column headers and cell data for such a table.

I have attached the table I am trying to create, hopefully, that helps.

Statistical Table

share|improve this question
1  
I don't know why sans-serif font should be used for table data. It does not make sense for me. As for the font size: it should not be changed (or changed really slightly to \small if there's no other option), if you can't fit your data into the page, you might use package rotating that provides the environment sidewaystable, if that is not enough, you have to think out a re-structuring of your table such that it fits. It is possible, but it might take a long time and a lot of trials-and-errors to make it work. –  tohecz Mar 25 '12 at 15:59
1  
@tohecz I believe sans-serif is normally used since you don't need your eye to flow over the text (The advantage of serifs) and a good sans-serif is more legible (Why it is used on highway signs: I can look up my citation for that data if you need) –  Canageek Mar 25 '12 at 16:49

1 Answer 1

up vote 12 down vote accepted

None of the following is to contradict tohecz's comment above, especially regarding serif versus sans-serif fonts. But if you can't find a better table design, or can't do a landscape table, then you'll have to do more than just set a font size for the table. You'll probably have to:

  1. Set a smaller font size for the table
  2. Set a smaller column separation inside the tabular environment
  3. Use smaller margins than the LaTeX default

You'll also want to read the documentation on the booktabs package for some advice on table layout, particularly on avoiding excess rules (and probably all vertical ones). And the siunitx package is good for aligning columns of measurements.

One result using booktabs and siunitx, with dummy body text for size comparison:

enter image description here

Annotated code, broken up for legibility and inline comments (but compiles fine in this form):

\documentclass[a4paper]{article}
\usepackage[margin=3cm]{geometry} % reduce margins to 3cm on all sides
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{lipsum}
\setlength{\tabcolsep}{2pt} % reduce column separation from default of 6pt
\begin{document}

\lipsum[1]

\begin{table}
\caption{Some caption}
\centering
\scriptsize
% default tabular column formatting:
%  left-aligned label (date),
%  5 measured values with 2 figures before decimal and 1 after,
%  5 measured values with 3 figures before decimal and none after,
%  centered label (power),
%  5 measured values with 2 figures before decimal and 1 after,
%  5 measured values with 3 figures before decimal and none after,
\begin{tabular}{
l
*{5}{S[table-format=2.1]}
*{5}{S[table-format=3.0]}
c
*{5}{S[table-format=2.1]}
*{5}{S[table-format=3.0]}}
% Place a top-of-table rule across all columns
\toprule
% Leave a blank column, span centered label over 10 columns,
% leave a blank column, span another centered label over 10 columns
& \multicolumn{10}{c}{Male} & & \multicolumn{10}{c}{Female} \\
% Place a mid-table rule over columns 2-11 and 13-22
\cmidrule{2-11} \cmidrule{13-22}
% Leave a blank column, span centered label over 5 columns,
% span centered label over 5 columns, span centered label over 5 columns,
% span centered label over 5 columns
& \multicolumn{5}{c}{Weight} & \multicolumn{5}{c}{Height} &
& \multicolumn{5}{c}{Weight} & \multicolumn{5}{c}{Height} \\
% Place mid-table rules over columns 2-6, 7-11, 13-17, and 18-22
% (trimmed on both left and right ends)
\cmidrule(lr){2-6} \cmidrule(lr){7-11} \cmidrule(lr){13-17} \cmidrule(lr){18-22}
% Enclose all repeated headers in braces to keep siunitx from trying to interpret them
Birthday & {Min} & {Q1} & {Med} & {Q3} & {Max} & {Min} & {Q1} & {Med} & {Q3} & {Max} &
   Power & {Min} & {Q1} & {Med} & {Q3} & {Max} & {Min} & {Q1} & {Med} & {Q3} & {Max} \\
% Place a mid-table rule across all columns
\midrule
Jan 2012
& 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 &
  100 & 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 \\
& 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 &
  120 & 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 \\
& 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 &
  340 & 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 \\
% Place a mid-table rule across all columns
\midrule
Feb 2012
& 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 &
  100 & 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 \\
& 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 &
  120 & 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 \\
& 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 &
  340 & 50.0 & 60.0 & 70.0 & 80.0 & 90.0 & 140 & 150 & 160 & 170 & 180 \\
% Place a bottom-of-table rule across all columns
\bottomrule
\end{tabular}
\end{table}

\end{document}

The resulting table is legible, but just barely fits in the margins provided. If you had more data or bigger margins, this table would rapidly approach what some people refer to as an "eye chart" table. At that point, you'd definitely have to change the requirements or move away from one giant table entirely. Maybe go to one table for males, one for females. Maybe just put a figure in with confidence interval bars or similar.

share|improve this answer
    
Thank you, thank you, thank you!. This is EXACTLY the kind of table I am trying to create. It even looks better than the one in the image I attached. I am going to study your snippet and use it as a starting point. I tried creating a pdf friom the snippet, but run into some probs with packages I dont have. I will read up on the links you provided and try to see if I can get it to work. Thanks once again. –  Homunculus Reticulli Mar 25 '12 at 16:20
    
As far as missing packages go, most people here probably have full installations of TeX Live 2011. On Linux/Unix systems, they'll normally install TL from the original media instead of using whatever the distribution includes (example for Debian/Ubuntu). –  Mike Renfro Mar 25 '12 at 16:39
    
Mike: I have installed the complete tex package for Ubuntu, and I am now able to create the document - I am elated!. I have a few further quick questions: 1. If I want to bolden the numbers in the 'Power' column, how do I do that? 2. After some deliberation, I think its better to create an image from the pdf, so that I can be sure that the report fits into an A4 page in the publication. Do I replace the article class as suggested here: [tex.stackexchange.com/questions/11866/…? –  Homunculus Reticulli Mar 25 '12 at 18:13
    
I forgot to ask you about what I found most bewildering - where is the lorem Ipsum text coming from? (its not in the snippet you pasted) - how do I replace that with my own text?. Last but not the least, I would like to stick a little 'Report generated on YYYYMMDD' on the bottom right handside in the footer of the report. Could you please modify the snipet to show how this can be done?. BTW, thanks (again) for the comments in your snippet. I am learning and understanding a great deal from your snippet. +1 from me. –  Homunculus Reticulli Mar 25 '12 at 18:19
    
please ignore question about the Lorem Ipsum text. I just noticed the \lipsum control sequences. –  Homunculus Reticulli Mar 25 '12 at 20:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.