summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pst-tools/pst-tools-doc.tex
blob: 1c4e3a7358241fd5fbe4e76facb651ef909a9312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%% $Id: pst-func-doc.tex 599 2011-11-03 19:38:28Z herbert $
\documentclass[11pt,english,BCOR10mm,DIV12,bibliography=totoc,parskip=false,
   smallheadings, headexclude,footexclude,oneside]{pst-doc}
\usepackage[utf8]{inputenc}
\usepackage{pst-tools}
\let\pstToolsFV\fileversion
\renewcommand\bgImage{}

\lstset{language=PSTricks,
    morekeywords={psPrintValue},basicstyle=\footnotesize\ttfamily}
%
\begin{document}

\title{\texttt{pst-tools}}
\subtitle{Helper functions; v.\pstToolsFV}
\author{Herbert Vo\ss}
\docauthor{}
\date{\today}
\maketitle

\tableofcontents
\psset{unit=1cm}


\section{\Lcs{psPrintValue}}\label{sec:printValue}
This macro allows to \Index{print} single values of a math function. It has the syntax

\begin{BDef}
\Lcs{psPrintValue}\OptArgs\Largb{PostScript code}\\
\Lcs{psPrintValue}\OptArg{algebraic,\ldots}\Largb{x value, algebraic code}
\end{BDef}

Important is the fact, that \Lcs{psPrintValue} works on \PS\ side. For \TeX\ it is only a box of
zero dimension. This is the reason why you have to put it into a box, which reserves horizontal
space.

There are the following valid options for \Lcs{psPrintValue}:

\noindent\medskip
\begin{tabularx}{\linewidth}{@{}l|>{\ttfamily}l>{\ttfamily}lX@{}}
\textrm{name} & \textrm{value}  & \textrm{default}\\\hline
\Lkeyword{PSfont}        & PS font name & Times & only valid \PS font names are possible, e.g. 
    \Lps{Times-Roman}, \Lps{Helvetica}, \Lps{Courier}, \Lps{AvantGard}, \Lps{Bookman}\\
\Lkeyword{postString} & <string>     & \{\}     & will be appended to the number string\\
\Lkeyword{trimSpaces} & <boolean>     & false     & will strip spaces on the right\\
\Lkeyword{fontscale} & <number>     & 10     & the font scale in pt\\
\Lkeyword{valuewidth} & <number>     & 10     & the width of the string for the converted 
    real number; if it is too small, no value is printed\\
\Lkeyword{decimals}  & <number>     & -1     & the number of printed decimals, a negative value
    prints all possible digits.\\ 
\Lkeyword{xShift}  & <number>     & 0     & the x shift in pt for the output, relative to the current point.\\ 
\Lkeyword{algebraic}  & <boolean>     & false     & function in algebraic notation.\\ 
\end{tabularx}

\begin{center}
\psset{fontscale=12}
\makebox[2em]{x(deg)} \makebox[5em]{$\sin x$} \makebox[4em]{$\cos x$}\hspace{1em}
\makebox[5em]{$\sqrt x$}\makebox[7em]{$\sin x+\cos x$}\makebox[6em]{$\sin^2 x+\cos^2 x$}\\[3pt]
\multido{\iA=0+10}{18}{
  \makebox[1em]{\iA}
  \makebox[5em]{\psPrintValue[PSfont=Helvetica,xShift=-10]{\iA\space sin}}
  \makebox[4em][r]{\psPrintValue[PSfont=Courier,fontscale=10,decimals=3,xShift=-20]{\iA\space cos}}\hspace{1em}
  \makebox[5em]{\psPrintValue[dot,valuewidth=15,linecolor=blue,PSfont=AvantGarde]{\iA\space sqrt}}
  \makebox[7em]{\psPrintValue[PSfont=Times-Italic]{\iA\space dup sin exch cos add}}
  \makebox[6em]{\psPrintValue[PSfont=Palatino-Roman]{\iA\space dup sin dup mul exch cos dup mul add}}\\}
\end{center}

\bigskip

\begin{lstlisting}
\psset{fontscale=12}
\makebox[2em]{x(deg)} \makebox[5em]{$\sin x$} \makebox[4em]{$\cos x$}\hspace{1em}
\makebox[5em]{$\sqrt x$}\makebox[7em]{$\sin x+\cos x$}\makebox[6em]{$\sin^2 x+\cos^2 x$}\\[3pt]
\multido{\iA=0+10}{18}{
  \makebox[1em]{\iA}
  \makebox[5em]{\psPrintValue[PSfont=Helvetica,xShift=-10]{\iA\space sin}}
  \makebox[4em][r]{\psPrintValue[PSfont=Courier,fontscale=10,decimals=3,xShift=-20]{\iA\space cos}}\hspace{1em}
  \makebox[5em]{\psPrintValue[dot,valuewidth=15,linecolor=blue,PSfont=AvantGarde]{\iA\space sqrt}}
  \makebox[7em]{\psPrintValue[PSfont=Times-Italic]{\iA\space dup sin exch cos add}}
  \makebox[6em]{\psPrintValue[PSfont=Palatino-Roman]{\iA\space dup sin dup mul exch cos dup mul add}}\\}
\end{lstlisting}

With enabled \Lkeyword{algebraic} option there must be two arguments, separated by a comma.
The first one is the x value as a number, which can also be PostScript code, which leaves a
number on the stack. The second part is the function described in algebraic notation.
Pay attention, in algebraic notation angles must be in radian and not degrees.

\begin{center}
\psset{algebraic, fontscale=12}% All functions now in algebraic notation
\makebox[2em]{x(deg)} \makebox[5em]{$\sin x$} \makebox[4em]{$\cos x$}\hspace{1em}
\makebox[5em]{$\sqrt x$}\makebox[7em]{$\sin x+\cos x$}\makebox[6em]{$\sin^2 x+\cos^2 x$}\\[3pt]
\multido{\rA=0+0.1}{18}{\makebox[1em]{\rA}
  \makebox[5em]{\psPrintValue[PSfont=Helvetica,xShift=-10]{\rA, sin(x)}}
  \makebox[4em][r]{\psPrintValue[PSfont=Courier,fontscale=10,decimals=3,xShift=-20]{\rA,cos(x)}}\hspace{1em}
  \makebox[5em]{\psPrintValue[dot,valuewidth=15,linecolor=blue,PSfont=AvantGarde]{\rA,sqrt(x)}}
  \makebox[7em]{\psPrintValue[PSfont=Times-Italic]{\rA,sin(x)+cos(x)}}
  \makebox[6em]{\psPrintValue[PSfont=Palatino-Roman]{\rA,sin(x)^2+cos(x)^2}}\\}
\end{center}

\bigskip

\begin{lstlisting}
\psset{algebraic, fontscale=12}% All functions now in algebraic notation
\makebox[2em]{x(deg)} \makebox[5em]{$\sin x$} \makebox[4em]{$\cos x$}\hspace{1em}
\makebox[5em]{$\sqrt x$}\makebox[7em]{$\sin x+\cos x$}\makebox[6em]{$\sin^2 x+\cos^2 x$}\\[3pt]
\multido{\rA=0+0.1}{18}{\makebox[1em]{\rA}
  \makebox[5em]{\psPrintValue[PSfont=Helvetica,xShift=-10]{\rA, sin(x)}}
  \makebox[4em][r]{\psPrintValue[PSfont=Courier,fontscale=10,decimals=3,xShift=-20]{\rA,cos(x)}}\hspace{1em}
  \makebox[5em]{\psPrintValue[dot,valuewidth=15,linecolor=blue,PSfont=AvantGarde]{\rA,sqrt(x)}}
  \makebox[7em]{\psPrintValue[PSfont=Times-Italic]{\rA,sin(x)+cos(x)}}
  \makebox[6em]{\psPrintValue[PSfont=Palatino-Roman]{\rA,sin(x)^2+cos(x)^2}}\\}
\end{lstlisting}



\begin{center}
foo \makebox[2em][l]{\psPrintValue[dot]{3.14 10 mul round 10 div}}bar\\3pt
foo \makebox[2em][l]{\psPrintValue[dot,PSfont=Symbol,
  postString=\string\260]{3.14 10 mul round 10 div}}bar\\3pt
foo \makebox[3.5em][l]{\psPrintValue[dot,PSfont=Symbol,decimals=6,
  postString=\string\260]{3.14 dup mul}}bar
\end{center}

\bigskip

\begin{lstlisting}
foo \makebox[2em][l]{\psPrintValue[dot]{3.14 10 mul round 10 div}}bar\\3pt
foo \makebox[2em][l]{\psPrintValue[dot,PSfont=Symbol,
  postString=\string\260]{3.14 10 mul round 10 div}}bar\\3pt
foo \makebox[3.5em][l]{\psPrintValue[dot,PSfont=Symbol,decimals=6,
  postString=\string\260]{3.14 dup mul}}bar
\end{lstlisting}






\clearpage
\section{List of all optional arguments for \texttt{pst-tools}}

\xkvview{family=pst-tools,columns={key,type,default}}




\bgroup
\raggedright
\nocite{*}
\bibliographystyle{plain}
\bibliography{pst-tools-doc}
\egroup

\printindex



\end{document}