を使用して三角関数の値の表を作成することができましたexpl3
。ただし、すべての値の小数点以下の桁数が 4 桁になるように、末尾にゼロを埋め込む必要があります。 でこれを行う簡単な方法はありますかexpl3
、それともこれを処理するために独自のマクロを作成する必要がありますか?
これは私が先ほど投稿した同様の質問に関連しています:三角関数の pgfmath の精度を向上させる簡単な方法はありますか?
これが私の MWE です:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\mynum{0}
\def\myvoffset{0pt}
\usepackage{xparse}
\ExplSyntaxOn
\def\aetan#1{\fp_eval:n { round ( tand ( #1 ), 4 )}}
\def\aesin#1{\fp_eval:n { round ( sind ( #1 ), 4 )}}
\def\aecos#1{\fp_eval:n { round ( cosd ( #1 ), 4 )}}
\def\aemod#1{\fp_eval:n { #1 - round0 ( #1 / 5 , 0 ) * 5}}
\ExplSyntaxOff
\usepackage[margin=0.5in]{geometry}
\begin{document}
Using \LaTeX3
\begin{tikzpicture}
\coordinate(UL) at (0,0);
\node at (UL) {Degrees};
\node[anchor=west] at ($(UL.west)+(1cm,0)$) {$\sin$};
\node[anchor=west] at ($(UL.west)+(2.75cm,0)$) {$\cos$};
\node[anchor=west] at ($(UL.west)+(4.50cm,0)$) {$\tan$};
\foreach \myn in {1,2,3,...,45}
{
\ifnum\aemod{(\myn-1)}=0\relax
\xdef\myvoffset{\dimexpr\myvoffset+1.350\baselineskip}%%
\else
\xdef\myvoffset{\dimexpr\myvoffset+1.00\baselineskip}%%
\fi
\coordinate (DEG/\myn) at ($(UL.west)-(0,\myvoffset)$);
\coordinate (DEG/S/\myn) at ($(DEG/\myn)+(1cm,0)$);
\coordinate (DEG/C/\myn) at ($(DEG/S/\myn)+(1.75cm,0)$);
\coordinate (DEG/T/\myn) at ($(DEG/C/\myn)+(1.75cm,0)$);
\node[anchor=east] at (DEG/\myn) {$\myn^\circ$};
\node[anchor=west] at (DEG/S/\myn) {\texttt{\aesin{\myn}}};
\node[anchor=west] at (DEG/C/\myn) {\texttt{\aecos{\myn}}};
\node[anchor=west] at (DEG/T/\myn) {\texttt{\aetan{\myn}}};
}
\end{tikzpicture}
\end{document}
答え1
解決策ではありませんが、解決策のようなものを見つけました。パッケージを次のようにexpl3
使用します。siunitx
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{siunitx}
\sisetup{add-decimal-zero,
round-precision=4,
round-mode=places,
round-integer-to-decimal,
detect-all}
\def\mynum{0}
\def\myvoffset{0pt}
\usepackage{xparse}
\ExplSyntaxOn
\def\aetan#1{\num{\fp_eval:n { round ( tand ( #1 ), 4 )}}}
\def\aesin#1{\num{\fp_eval:n { round ( sind ( #1 ), 4 )}}}
\def\aecos#1{\num{\fp_eval:n { round ( cosd ( #1 ), 4 )}}}
\def\aemod#1{\fp_eval:n { #1 - round0 ( #1 / 5 , 0 ) * 5}}
\ExplSyntaxOff
\usepackage[margin=0.5in]{geometry}
\begin{document}
Using \LaTeX3
\begin{tikzpicture}
\coordinate(UL) at (0,0);
\node at (UL) {Degrees};
\node[anchor=west] at ($(UL.west)+(1cm,0)$) {$\sin$};
\node[anchor=west] at ($(UL.west)+(2.75cm,0)$) {$\cos$};
\node[anchor=west] at ($(UL.west)+(4.50cm,0)$) {$\tan$};
\foreach \myn in {1,2,3,...,45}
{
\ifnum\aemod{(\myn-1)}=0\relax
\xdef\myvoffset{\dimexpr\myvoffset+1.350\baselineskip}%%
\else
\xdef\myvoffset{\dimexpr\myvoffset+1.00\baselineskip}%%
\fi
\coordinate (DEG/\myn) at ($(UL.west)-(0,\myvoffset)$);
\coordinate (SIN/\myn) at ($(DEG/\myn)+(1cm,0)$);
\coordinate (COS/\myn) at ($(SIN/\myn)+(1.75cm,0)$);
\coordinate (TAN/\myn) at ($(COS/\myn)+(1.75cm,0)$);
\node[anchor=east] at (DEG/\myn) {$\myn^\circ$};
\node[anchor=west] at (SIN/\myn) {\texttt{\aesin{\myn}}};
\node[anchor=west] at (COS/\myn) {\texttt{\aecos{\myn}}};
\node[anchor=west] at (TAN/\myn) {\texttt{\aetan{\myn}}};
}
\end{tikzpicture}
\end{document}