![암호](https://rvso.com/image/266415/%EC%95%94%ED%98%B8.png)
다음 스크린샷을 고려해보세요.
내가 갖고 싶은 기능은 다음과 같습니다.
- 페이지 크기를 축소하면 테이블이 여러 페이지로 나누어질 수 있습니다.
- 읽기 쉽도록 홀수 행의 배경은 짝수 행의 배경과 달라야 합니다.
- 값은 수동으로 데이터를 입력하는 대신 자동으로 계산되어야 합니다.
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}
답변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
한 테이블에서 페이지 나누기를 허용하려면(여러 패스 필요)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
설정이 이루어집니다(이는 열 사양에서도 수행될 수 있음 S[…]
). PGF 수학이 (거의 모든 곳에서) siunitx
형식으로 출력을 제공할 수 있으므로 과학적 표기법으로 숫자를 설정하려고 시도하지 않도록 이러한 설정이 필요합니다 .1.746e-2
\pgfplotstabletypeset
마지막으로!
여기서는 s 설정을 위한 보조 스타일이 column type
사용됩니다.
에서는 매크로를 @secure header
사용하여 의 구문 분석 \multicolumn
에서 내용을 숨깁니다 . siunitx
내용을 중괄호 안에 넣는 일반적인 접근 방식은 {sin}
여기서는 작동하지 않는 것 같습니다.
및 left
열 은 via 의 구문 이 추가된 열(여기에서도 사용할 수 있음 ) 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}