Thanks to various threads on this site I have almost managed to construct a readable table! In particular I have added \newcolumntype
to allow me to insert \newline
into my tables, and I have constructed a table heading format \head
to allow me to easily use a different format for the heading cells of the table.
I am slightly confused by the behaviour of my head
format. The headings seem to align as desired only when I use the \newcolumntype
to define my columns (i.e. L
or R
rather than l
or r
). Example below.
\documentclass[11pt, a4paper, twoside, fleqn]{article}
\usepackage{xspace}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcommand{\head}[1]{\centering\textbf{#1}}
\newcommand{\COtwo}{CO$_{2}$\xspace}
\begin{document}
\begin{table}
\centering
\footnotesize
\begin{tabular}{ | R{2cm} | r | r | R{2cm} | }
\hline
\head{\COtwo} & \head{\COtwo} & \head{Ozone} & \head{Water\newline Vapour} \tabularnewline [0.5ex]
\hline
1.2 & 1.55555555 & 2.44444444444444444 & 1.3\\
\hline
\end{tabular}
\caption{Blah}
\end{table}
\end{document}
Ends up looking like this:
I can't see why this should be - why can't my \head
command override the default column alignment when using r
? It's not such a big deal to use R
instead of r
, but I am curious as I am relatively new to LaTeX.