emath saloon

新規発言一覧最新記事過去一覧検索HOME

No.218  Re[5]:\calcvalの戻り値を小数第1位にするには?(Re:5424)
発言者: zyam56
発言日: 2006 12/27 22:41
練達の皆さん、ありがとうございます。
最近Texソース内での数値計算と格闘しています。
eclarithの加減乗除は分かりやすいのですが、perlの方も\calcvalで同じようにできることを
知りました。リャマ本でperlについて少し勉強はじめましたがよく分からないですね。
動機は、数値入力を自動化した比例計算の問題作成ということです。
恥ずかしいのですが拙作をご覧ください。
石原さんのご指摘で実寸が微妙にずれる原因が分かりました。
それにしても、TeX+emath+perl等々で実に多様なことができるものですね。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,10pt,fleqn]{jsarticle} %a4版縦置き
%--------------------------------------------------------
\usepackage{emathPp}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%【5】2006/12/25%%マクロコマンド名【HeikouSenHiA{#1}{#2}{#3}】
%%平行な三直線によって切り取られる線分の比
\def\HeikouSenHiA#1#2#3{%%#1mの離れ具合、#2gの位置、#3hの位置
\unitlength10truemm
\begin{picture}(6,5)(0,0)% 
\def\A{(0,0.5)}\Put\A[w]{\small{$n$}}%
\def\B{(6,0.5)}%\Put\B[e]{\small{$n$}}%
\Add{0.5}{#1}\ANS
\def\C{(0,\ANS)}\Put\C[w]{\small{$m$}}%%
\def\D{(6,\ANS)}%\Put\D[e]{\small{$m$}}%%
\def\E{(0,4.5)}\Put\E[w]{\small{$\ell$}}%%
\def\F{(6,4.5)}%\Put\F[e]{\small{$\ell$}}%
%%%%%%%%%%%%%%%%%%%%
\thicklines
\Drawline{\A\B}
\Drawline{\C\D}
\Drawline{\E\F}
\def\G{(0.5,0)}\Put\G[s]{\small{$g$}}%
\def\H{(#2,5)}%\Put\H[n]{\small{$g$}}%
\Drawline{\G\H}
%%%%%%%%%%%%%%%%%%%%
\def\I{(5,0)}\Put\I[s]{\small{$h$}}%
\def\J{(#3,5)}%\Put\J[n]{\small{$h$}}%
\Drawline{\I\J}
%%%%%%%%%%%%%%%%%%%%
\LandL\A\B\G\H\R%\Put\R[nw]{\footnotesize{$R$}}
\LandL\C\D\G\H\Q%\Put\Q[nw]{\footnotesize{$Q$}}
\LandL\E\F\G\H\P%\Put\P[nw]{\footnotesize{$P$}}
\LandL\A\B\I\J\U%\Put\U[ne]{\footnotesize{$U$}}
\LandL\C\D\I\J\T%\Put\T[nw]{\footnotesize{$T$}}
\LandL\E\F\I\J\S%\Put\S[ne]{\footnotesize{$S$}}
%%%%%%%%%%%%%%%%%%%%
%%左直線%%perlによる計算値を引数として受けとる%%%%%%%%%%%%
\calcval{0.9*(#2-0.5)}\a%点Pのx座標
\calcval{0.1*(#2-0.5)}\b%点Rのx座標
\calcval{#1*(\a-\b)}\x
\calcval{\x / 4}\Ax
\calcval{#1**2+\Ax**2}\Bx
\calcval[2.1f]{\Bx**0.5}\Cx
%%%%%%%%%%%%%%%%%%%%
\thinlines
\Hen_ko<0.4>\R\Q{\small{$ \Cx cm $}}
%%%%%%%%%%%%%%%%%%%%
\calcval{(\a-\b)**2+4**2}\Dx
\calcval{\Dx**0.5}\Ex
\calcval[2.1f]{\Ex-\Cx}\Fx
%%%%%%%%%%%%%%%%%%%%
\thinlines
\Hen_ko<0.4>\P\Q{\small{$ \Fx cm $}}
%%右直線%%perlによる計算値を引数として受けとる%%%%%%%%%%%%
\calcval{0.9*#3+0.5}\c%点Sのx座標
\calcval{4.5+0.1*#3}\d%点Uのx座標
\calcval{(\d-\c)**2+4**2}\Gx
\calcval[2.1f]{\Gx**0.5}\Kotae
%%%%%%%%%%%%%%%%%%%%
\thinlines
\Hen_ko<0.7>\U\S{\small{$ \Kotae cm $}}
%%%%%%%%%%%%%%%%%%%%
\Hen_ko<0.4>\T\U{\small{$ x cm $}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{picture}
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
3学年数学 練習問題{\LARGE{マクロ作成テスト版}}
\begin{flushright}
\underline{\hspace{0.8cm}}組 {\small{番号\underline{\hspace{1cm}}}\small{氏名\underline{\hspace{4cm}}}}
\end{flushright}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\abovedisplayskip=4.0pt plus 2.0pt minus 8.0pt 
%\belowdisplayskip=4.0pt plus 2.0pt minus 8.0pt 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{enumerate}
\item マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版\\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%作成マクロコマンド実行%%%%%%
%%%***********************%%%%%
\HeikouSenHiA{1.3}{3}{3.5}
%%%***********************%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{enumerate}
\end{document}

▼関連発言

207:Re[2]:\calcvalの戻り値を小数第1位にするには?(Re:5424) [石原 守] 12/27 09:35
 ├210:Re[3]:\calcvalの戻り値を小数第1位にするには?(Re:5424) [田中徹] 12/27 12:20
 └213:Re[3]:\calcvalの戻り値を小数第1位にするには?(Re:5424) [tDB] 12/27 13:50
  ├214:    補足 [tDB] 12/27 13:53
  └216:Re[4]:\calcvalの戻り値を小数第1位にするには?(Re:5424... [石原 守] 12/27 16:40
   └218:Re[5]:\calcvalの戻り値を小数第1位にするには?(Re:542.. [zyam56] 12/27 22:41
    └219:Re[6]:\calcvalの戻り値を小数第1位にするには?(Re:5.. [石原 守] 12/28 19:55
     └220:Re[7]:\calcvalの戻り値を小数第1位にするには?(Re.. [zyam56] 12/28 20:29
      └221:Re[8]:\calcvalの戻り値を小数第1位にするには?(.. [田中徹] 12/29 01:05
       └222:Re[9]:\calcvalの戻り値を小数第1位にするには?.. [zyam56] 12/29 10:18<-last

Pass 保存


CGIROOM