Packages
xcolor with the option table for \rowcolor
pgfplotstable (and internally pgfmath) that is used to build the entire table. The pgfmath package helps us to create the trigonometric values (which are all built-in)
longtable to allow page-breaks in one table (needs multiple passes)
siunitx to typeset numbers in tables (pgfmath does a good job on number printing already, but that is not very well suited for tables)
booktabs for nice rules.
\pgfplotstableset
Auxiliary styles
Styles prepended with an @ are new styles created by me. Neither is the @ needed (just to separate pgfplotstable’s styles from mine) nor are the names set in stone. These styles are used with the .list handler to ease the creation of the columns.
The line
@create function/.list={sin,cos,tan,cot,cosec,sec},
builds the main columns, note that the csc function is named cosec in PGF. The column is named cosec but I later change the column name to csc. (One may also note that one should use proper column names, e.g. $\phi$ and $\sin \phi$ instead of empty column names and non-math-mode but math-function names.)
Note the string type key, this deactivates PGF printing number features (but not the PGF math calculation of the columns).
longtable setup
The basic keys begin table and end table are used to set the internal table environment from tabular to longtable.
The every head row style is (mis-)used to set up the special rows (these are longtable features). See the longtable manual for more.
\pgfplotstablenew
Let's create 91 rows (+ header (e.g. longtable preamble)):
\pgfplotstablenew[
columns={left,sin,cos,tan,cot,sec,cosec,right},
]{91}\myTable
\sisetup
Certain siunitx settings are made before the actual typesetting (this could have been done in the S[…] column specifications, too). These settings are needed so that siunitx doesn’t try to setup numbers in scientific notation as PGF math may give an output in the form of 1.746e-2 (pretty much everywhere).
\pgfplotstabletypeset
Finally!
Here the auxiliary styles for setting up the column types are used.
The @secure header uses the \multicolumn macro to hide the content from siunitx’s parsing. The usual approach by putting the content in braces, e.g. {sin} doesn’t appear to be working here.
The left and the right column only uses r columns (we could use S here, too) with an appended \si{\degree} via array’s <{…} syntax. This is also the reason the header needs an empty \multicolumn{1}{c}{} entry.
Code
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage{booktabs}
\pgfplotstableset{
% helpers
@create function/.style={
create on use/#1/.style={
create col/expr=#1(\thisrow{left})}},
@secure header/.style={
columns/#1/.append style={
column name=\multicolumn{1}{c}{#1}}},
@set columns to siunitx type 1/.style={
columns/#1/.append style={
string type,
column type={S[table-format=1.4]}}},
@set columns to siunitx type 2/.style={
columns/#1/.append style={
string type,
string replace={inf}{\multicolumn{1}{c}{$\infty$}},
column type={S[table-format=2.4]}}},
@set columns to siunitx type 3/.style={
columns/#1/.append style={
string type,
string replace={inf}{\multicolumn{1}{c}{$\infty$}},
column type={S[table-format=2.3]}}},
@set columns to basic style/.style={
columns/#1/.append style={
column type={r<{\si{\degree}}}}},
@set empty header/.style={
columns/#1/.append style={
column name={\multicolumn{1}{c}{}}}},
%
% the left and right columns
create on use/left/.style={
create col/expr=\pgfplotstablerow},
create on use/right/.style={
create col/expr={90-\thisrow{left}}},
%
% Let's start: the functions
@create function/.list={sin,cos,tan,cot,cosec,sec},
% The longtable setup
begin table=\begin{longtable},
end table=\end{longtable},
every head row/.append style={
before row=\toprule,
after row=%
\midrule \endhead
\midrule
\multicolumn{1}{c}{} & {cos} & {sin} & {cot} & {tan} & {csc} & {sec} & \multicolumn{1}{r}{\dots}\\ \bottomrule
\endfoot
\midrule
\multicolumn{1}{c}{} & {cos} & {sin} & {cot} & {tan} & {csc} & {sec} & \multicolumn{1}{r}{} \\ \bottomrule
\endlastfoot},
every odd row/.style={before row={\rowcolor[gray]{.9}}},
}
\pgfplotstablenew[
columns={left,sin,cos,tan,cot,sec,cosec,right},
]{91}\myTable
\begin{document}
\sisetup{scientific-notation = fixed, fixed-exponent = 0, table-auto-round=true}
\pgfplotstabletypeset[
% the column types
@set columns to siunitx type 1/.list={sin,cos},
@set columns to siunitx type 2=tan,
@set columns to siunitx type 3/.list={cot,sec,cosec},
@set columns to basic style/.list={left,right},
% setup for the headers
@secure header/.list={sin,cos,tan,cot,sec},
@set empty header/.list={left,right},
columns/cosec/.append style={column name={\multicolumn{1}{c}{csc}}},
]\myTable
\end{document}
Output



longtable, (2)xcolorwith thetableoption, (3) eitherfporpgfmath. – Werner Apr 13 '13 at 05:22