# How to apply \raggedright to my table headings?

Can somebody show me how to apply \raggedright to my table headings in this example?

\documentclass[a4paper,12pt]{article}

\usepackage{tabularx}
\usepackage{booktabs}

\usepackage{siunitx}

\begin{document}
\begin{table}[t]
\caption{}
\label{}
\begin{tabularx}{\textwidth}{X X X X}
\toprule
Time of induction (\SI{}{\minute}) & Mean $\text{A}_{414}$ & Corrected $\text{A}_{414}$ (minus t=0 value) & Units of $\beta$-galactosidase per \SI{}{ml} of {\it E. coli} culture\\
\midrule
0   &   0.057   &   0       &   0   \\
1   &   0.060   &   0.003   &   \num{1.3e-7}\\
2   &   0.069   &   0.012   &   \num{5.0e-7}\\
3   &   0.083   &   0.026   &   \num{1.1e-6}\\
4   &   0.120   &   0.063   &   \num{2.6e-6}\\
5   &   0.123   &   0.066   &   \num{2.8e-6}\\
7   &   0.191   &   0.134   &   \num{5.6e-6}\\
10  &   0.310   &   0.253   &   \num{1.1e-5}\\
12  &   0.399   &   0.342   &   \num{1.4e-5}\\
15  &   0.491   &   0.434   &   \num{1.8e-5}\\
30  &   1.179   &   1.122   &   \num{4.7e-5}\\
45  &   1.585   &   1.528   &   \num{6.4e-5}\\
0c  &   0.056   &   0       &   \num{0}\\
15c     &   0.057   &   0.001   &   \num{0}\\
45c     &   0.055   &   0       &   \num{0}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

-
You want only the headings to be ragged right? –  Gonzalo Medina Sep 10 '11 at 14:49
@Gonzalo Medina: Correct, thank you, I've edited the question to reflect that. –  ptrcao Sep 10 '11 at 14:55

You can use \multicolumn to override the original column specification:

\toprule
\multicolumn{1}{>{\raggedright}X}{Time of induction (\SI{}{\minute})} & \multicolumn{1}{>{\raggedright}X}{Mean $\text{A}_{414}$} & \multicolumn{1}{>{\raggedright}X}{Corrected $\text{A}_{414}$ (minus t=0 value)} & \multicolumn{1}{>{\raggedright}X}{Units of $\beta$-galactosidase per \SI{}{ml} of {\it E. coli} culture}\\
\midrule


>{decl.} inserts decl. directly in front of the entry of the column. Analogously, <{decl.} used after a column format declaration inserts decl. right after the entry of the column.

-
Beautiful! That worked, thanks for the prompt response. Can explain the use of the greater than > symbol? And why did you have to introduce \multicolumn? –  ptrcao Sep 10 '11 at 14:58
@ptrcao: I added some comment to my answer explaining >{...}. As I said in my answer, I used \multicolumn to easily override the original column format declaration. –  Gonzalo Medina Sep 10 '11 at 15:08
@ptrao: tabularx requires the array package, so it loads it by default. The notation @Gonzalo used can be seen by reading page 2 of the array package documentation. –  Werner Sep 10 '11 at 15:13
@Werner: Thanks for the link. Regarding \multicolumn, I meant that I noticed it was being used in a redundant way, to specify a \multicolumn spanning only 1 column. My understanding is that \multicolumn is normally used to span multiple columns. So I thought Gonzalo was using it purely as a workaround to force some kind of override. Does that makes any sense...? –  ptrcao Sep 10 '11 at 15:21
@ptrcao: \multicolumn can be used to span multiple columns, but it can also be used to override the declared format for one column, as I did in my answer. –  Gonzalo Medina Sep 10 '11 at 15:26