Wednesday, March 30, 2011

latex Table. A multicolumn example

I give a simple example and a more complicated one that needs to use sideways table (because it is too big).

%Example 0. See here
http://andrewjpage.com/index.php?/archives/43-Multirow-and-multicolumn-spanning-with-latex-tables.html

%Example A.

\begin{table}
\caption{Post-treatment Egg Count Varability (Simulated Data). We postulate that the data on a
single farm contains $n=13$ samples from the fixed $p$ model. This table presents such samples at three instances for horses in Table \ref{tbl:prevar} with $p=.95$.\label{tbl:postvar}} %postvar = varab ility in post-treatment count
%we want Hello centered so use c
\begin{center}
\begin{tabular}{cc|ccc}
& & \multicolumn{3}{|c|}{Hello}\\
horse & pre & post (sim 1) & post (sim 2) & post (sim 3) \\ \hline
1 & 3250 & 163 & 167 & 163 \\
2 & 450 & 28 & 26 & 26 \\
3 & 445 & 25 & 21 & 21 \\
4 & 300 & 20 & 17 & 14 \\
5 & 260 & 16 & 9 & 16 \\
6 & 1420 & 73 & 65 & 78 \\
7 & 505 & 20 & 20 & 27 \\
8 & 45 & 4 & 4 & 3 \\
9 & 1230 & 70 & 60 & 59 \\
10 & 325 & 12 & 19 & 14 \\
11 & 325 & 18 & 9 & 22 \\
12 & 100 & 2 & 1 & 2 \\
13 & 80 & 4 & 1 & 1
\end{tabular}
\end{center}
\end{table}

%Example B.
\usepackage{rotate}

You can get away without sideways table here
 \begin{table}
\caption{Post-treatment Egg Count Varability (Simulated Data). We postulate that the data on a
single farm contains $n=13$ samples from the fixed $p$ model. This table presents such samples at three instances for horses in Table \ref{tbl:prevar} with $p=.95$.\label{tbl:postvar}} %postvar = varab ility in post-treatment count
%we want Hello centered so use c
\begin{center}
\begin{tabular}{cc|ccc|ccc|}
& & \multicolumn{3}{|c|}{Hello} & \multicolumn{3}{|c|}{Hello}\\
horse & pre & post (sim 1) & post (sim 2) & post (sim 3) & post (sim 1) & post (sim 2) & post (sim 3) \\ \hline
1 & 3250 & 163 & 167 & 163 & 168 & 210 & 93\\
\end{tabular}
\end{center}
\end{table}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.