Code snippets for tables:
Standard figure
\begin{table}[htbp] % h:here; t:top; b:bottom; p:page; default:ht
\caption{default}
\centering
\begin{tabular}{lccr}
\hline
- & - & - & - \\
\hline
- & - & - & - \\
- & - & - & - \\
\hline
\end{tabular}
\label{tab:def}
\end{table}%
Side-by-side table
%Preamble
\usepackage[lotdepth]{subfig}
%Document
\begin{table}[htbp] % h:here; t:top; b:bottom; p:page; default:ht
\centering
\subfloat[short for lot subtable1][long subtable1 caption]{
\begin{tabular}{lccr}
\hline
- & - & - & - \\
\hline
- & - & - & - \\
- & - & - & - \\
\hline
\end{tabular}
\label{subtab:tab1}
}
\subfloat[short for lot subtable2][long subtable2 caption]{
\begin{tabular}{lccr}
\hline
- & - & - & - \\
\hline
- & - & - & - \\
- & - & - & - \\
\hline
\end{tabular}
\label{subtab:tab2}
}
\caption[short for lot]{long table caption}
\label{tab:tab1}
\end{table}
\ref{tab:tab1} and \subref{subtab:tab1}
Sideways-table
% Preamble
\usepackage{rotating}
% Document
\begin{sidewaystable}
\caption{Sideways table.}
\centering
\begin{tabular}{lccr}
\hline
- & - & - & - \\
\hline
- & - & - & - \\
- & - & - & - \\
\hline
\end{tabular}
\label{tab:swtab}
\end{sidewaystable}
Multi-page table (longtable)
%Preamble
\usepackage{longtable}
% Document
\begin{center}
\begin{longtable}{|c|c|c|c|}
\caption{A simple longtable example}\\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
\endfoot
\hline \multicolumn{4}{r}{\textit{End of table}} \\
\endlastfoot
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
\end{longtable}
\end{center}
February 24th, 2013 at 6:18 pm
Love your Blog!
February 26th, 2013 at 2:25 pm
Thanks
June 5th, 2013 at 12:31 pm
Hi Tom,,,,
For drawing a table of any sort, style, etc. I am using Excel2LaTeX application, I have tried many dummy sorts of tables, all other things are correct except color of rows and/or columns as defined in excel, but after converting into LaTeX, colors become undefined (means as no any color is used,,, empty) . Although used color packages, so how can we get exact table drawn accordingly into excel?
thanks…..
June 6th, 2013 at 3:43 am
Hey!
Take a look at this post on coloring table rows and columns.
Cheers, Tom.