Considere a seguinte captura de tela.
Os recursos que desejo ter são:
- Posso diminuir o tamanho da página e a tabela pode ser dividida entre as páginas.
- O fundo das linhas ímpares deve ser diferente do fundo das linhas pares para facilitar a leitura.
- Os valores devem ser calculados automaticamente e não por entrada de dados manual.
MWE
\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage[nomessages]{fp}
\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{pgffor}
\begin{document}
\topskip=0pt
\begin{longtable}{*2{|>{$\displaystyle}c<{$}}|}\hline
\theta & \sin \theta\\
\foreach \x in {0,10,...,360}{\x & \FPeval\temp{round(\x:3)}\temp\\}
\end{longtable}
\end{document}
Responder1
Mais facilmente, você pode usar ocalculadorapacote que permitirá avaliar as funções trigonométricas. Também osupertabularO pacote permitirá que você faça o cabeçalho/rodapé repetido em cada tabela.
Aqui está um exemplo mais simples:
Código
\documentclass{article}
\usepackage[nomessages]{fp}
\usepackage[table]{xcolor}
\usepackage{calculator}
\usepackage{forloop}
\usepackage{supertabular}
\usepackage{longtable}
\usepackage{fullpage}
\begin{document}
\newcounter{theangle}
\tablefirsthead{
\cline{2-4}
\rowcolor{white}
\multicolumn{1}{c|}{ } &
\cos \theta & \sin \theta & \tan \theta &
\multicolumn{1}{c}{ } \\
\hline
}
\tablehead{
\rowcolor{white}
\multicolumn{5}{c}{Table continued \ldots}\\
\cline{2-4}
\rowcolor{white}
\multicolumn{1}{c|}{ } &
\cos \theta & \sin \theta & \tan \theta &
\multicolumn{1}{c}{ } \\
\hline
}
\tablelasttail{
\rowcolor{white}
\multicolumn{1}{c|}{ } &
\cos \theta & \sin \theta & \tan \theta &
\multicolumn{1}{c}{ }\\
\cline{2-4}
}
\tabletail{
\hline
\rowcolor{white}
\multicolumn{1}{c|}{ } &
\cos \theta & \sin \theta & \tan \theta &
\multicolumn{1}{c}{ } \\
\cline{2-4}
\rowcolor{white}
\multicolumn{5}{c}{Continued on next page \ldots}\\
}
\rowcolors{2}{gray!50}{white}
\begin{center}
\begin{supertabular}{*5{|>{$}c<{$}}|}
\forloop{theangle}{0}{\value{theangle} < 360}{
\arabic{theangle}^\circ &
\DEGREESCOS{\value{theangle}}{\solx} \solx &
\DEGREESSIN{\value{theangle}}{\solx} \solx &
\DEGREESTAN{\value{theangle}}{\solx} \solx &
\arabic{theangle}^\circ\\
\addtocounter{theangle}{4}
}
\end{supertabular}
\end{center}
\end{document}
Saída
Responder2
Pacotes
xcolor
com a opçãotable
de\rowcolor
pgfplotstable
(e internamentepgfmath
) que é usado para construir a tabela inteira. Opgfmath
pacote nos ajuda a criar os valores trigonométricos (todos integrados)longtable
para permitir quebras de página em uma tabela (precisa de várias passagens)siunitx
para compor números em tabelas (pgfmath
já faz um bom trabalho na impressão de números, mas isso não é muito adequado para tabelas)booktabs
para regras legais.
\pgfplotstableset
Estilos auxiliares
Os estilos prefixados com @
são novos estilos criados por mim. Nem é @
necessário (apenas para separar pgfplotstable
os estilos do meu) nem os nomes são gravados em pedra. Esses estilos são usados com o .list
manipulador para facilitar a criação das colunas.
A linha
@create function/.list={sin,cos,tan,cot,cosec,sec},
constrói as colunas principais, observe que a csc
função é nomeada cosec
em PGF. A coluna tem um nome cosec
, mas depois altero column name
para csc
. (Pode-se também notar que deve-se usar nomes de colunas apropriados, por exemplo, $\phi$
e $\sin \phi$
em vez de nomes de colunas vazios e nomes de funções não matemáticas, mas de modo não matemático.)
Observe a string type
chave, isso desativa os recursos de impressão de número de PGF (mas não o cálculo matemático de PGF das colunas).
longtable
configurar
As chaves básicas begin table
e end table
são usadas para definir o ambiente da tabela interna de tabular
para longtable
.
O every head row
estilo é (mal) usado para configurar as linhas especiais (estes são longtable
recursos). Veja o longtable
manual para mais.
\pgfplotstablenew
Vamos criar 91 linhas (+ cabeçalho (por exemplo, longtable
preâmbulo)):
\pgfplotstablenew[
columns={left,sin,cos,tan,cot,sec,cosec,right},
]{91}\myTable
\sisetup
Certas siunitx
configurações são feitas antes da composição propriamente dita (isso também poderia ter sido feito nas S[…]
especificações da coluna). Essas configurações são necessárias para que siunitx
não tente configurar números em notação científica, pois a matemática PGF pode fornecer uma saída na forma de 1.746e-2
(praticamente em todos os lugares).
\pgfplotstabletypeset
Finalmente!
column type
Aqui são usados os estilos auxiliares para configurar os s.
O @secure header
usa a \multicolumn
macro para ocultar o conteúdo da siunitx
análise. A abordagem usual, colocando o conteúdo entre colchetes, por exemplo, {sin}
não parece estar funcionando aqui.
A left
e a right
coluna usa apenas r
colunas (poderíamos usar S
aqui também) com uma sintaxe \si{\degree}
via anexada . Este também é o motivo pelo qual o cabeçalho precisa de uma entrada vazia.array
<{…}
\multicolumn{1}{c}{}
Código
\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}