![コード](https://rvso.com/image/266415/%E3%82%B3%E3%83%BC%E3%83%89.png)
次のスクリーンショットを検討してください。
私が欲しい機能は次のとおりです。
- ページ サイズを縮小することができ、表を複数のページに分割できます。
- 読みやすくするために、奇数行の背景は偶数行の背景と異なる必要があります。
- 値は、手動でデータを入力するのではなく、自動的に計算する必要があります。
ムウェ
\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}
答え1
もっと簡単に、電卓三角関数を評価できるパッケージです。また、超表形式このパッケージを使用すると、各テーブルに繰り返しの見出し/フッターを作成できます。
より簡単な例を以下に示します。
コード
\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}
出力
答え2
パッケージ
xcolor
オプションtable
付き\rowcolor
pgfplotstable
(そして内部的にpgfmath
)テーブル全体を構築するのに使われます。このpgfmath
パッケージは三角関数の値(すべて組み込まれています)を作成するのに役立ちますlongtable
1 つのテーブル内で改ページを許可する (複数のパスが必要)siunitx
表に数字をタイプセットする(pgfmath
数字の印刷はすでにうまくいっていますが、表にはあまり適していません)booktabs
素晴らしいルールのために。
\pgfplotstableset
補助スタイル
が先頭に付いたスタイルは、@
私が作成した新しいスタイルです。 も必要ありません@
( のスタイルを私のスタイルと区別するためだけにpgfplotstable
使用します)。また、名前も固定されていません。これらのスタイルは、ハンドラーで使用して、.list
列の作成を容易にします。
この線
@create function/.list={sin,cos,tan,cot,cosec,sec},
メインの列を構築します。csc
関数は PGF で名前が付けられていることに注意してくださいcosec
。列には名前が付けられていますcosec
が、後で を に変更しますcolumn name
。 (空の列名や非数式モードだが数式関数名の代わりに、csc
や などの適切な列名を使用する必要があることにも注意してください。)$\phi$
$\sin \phi$
キーに注意してくださいstring type
。これにより、PGF の数値印刷機能が無効になります (ただし、列の PGF 数学計算は無効になりません)。
longtable
設定
基本キーbegin table
と は、end table
内部テーブル環境を から に設定するために使用されtabular
ますlongtable
。
スタイルevery head row
は、特別な行 (これらは機能です) を設定するために (誤って) 使用されていますlongtable
。longtable
詳細については、マニュアルを参照してください。
\pgfplotstablenew
longtable
91 行 (+ ヘッダー (例:序文))を作成しましょう。
\pgfplotstablenew[
columns={left,sin,cos,tan,cot,sec,cosec,right},
]{91}\myTable
\sisetup
実際のタイプセッティングの前に、特定のsiunitx
設定が行われます (列の指定でもこれを行うことができます)。これらの設定は、PGF 数学が(ほとんどどこでも)の形式で出力する場合があるため、数値を科学的記数法で設定しないようにするS[…]
ために必要です。siunitx
1.746e-2
\pgfplotstabletypeset
ついに!
ここでは、 を設定するための補助スタイルcolumn type
が使用されます。
は、マクロ@secure header
を使用して、 の解析\multicolumn
からコンテンツを隠します。たとえば、コンテンツを中括弧で囲むという通常のアプローチは、ここでは機能していないようです。siunitx
{sin}
およびleft
列では、の構文を介して追加された列right
のみが使用されます(ここでもr
使用できます) 。これは、ヘッダーに空のエントリが必要な理由でもあります。S
\si{\degree}
array
<{…}
\multicolumn{1}{c}{}
コード
\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}