Debian Codegraph @

texmf-dist/source/latex/graphpaper/graphpaper.dtx

raw
1 %\iffalse
2 % !TEX encoding = UTF-8 Unicode
3 % !TEX TS-program = pdflatex
4 %<*internal>
5 \begingroup
6 %^^A Load the docstrip package (DO NOT USE \input{...})
7 \input docstrip.tex
8 \keepsilent
9 %^^A\usedir{tex/latex/graphpaper}
10 %^^A insert this text at the beginning of the generated file
11 \preamble
12 ________________________________________
13 The graphpaper class for generating several types of graph paper
14 Copyright (C) 2020 - 2022 C. Beccari & F. Biccari
15 All rights reserved
16
17 License information appended
18
19 \endpreamble
20 %^^A insert this text at the end of the generated file
21 \postamble
22 Copyright (C) 2020 - 2022 Claudio Beccari & Francesco Biccari
23
24 Distributable under the LaTeX Project Public License,
25 version 1.3c or higher (your choice). The latest version of
26 this license is at: http://www.latex-project.org/lppl.txt
27
28 This work is "author-maintained".
29
30 This work consists of this file graphpaper.dtx,
31 and the derived files graphpaper.cls and graphpaper.pdf.
32
33 \endpostamble
34 %^^A
35 %^^A DocStrip can silently overwrite an already existing cls file
36 \askforoverwritefalse
37 %^^A
38 %^^A Generates the cls file from the dtx file, stripping out all
39 %^^A the documentation. The option "class" tells to DocStrip to
40 %^^A extract only the code marked with the "class" tag.
41 \generate{\file{graphpaper.cls}{\from{graphpaper.dtx}{class}}}
42 %
43 \def\tmpa{plain}
44 \ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
45 \endgroup
46 %</internal>
47 %\fi
48 %^^A %
49 %^^A ----------------------------------------------------------------------
50 %^^A Here starts the second part
51 %^^A ProvidesFile must be (more or less) the first command for a class dtx.
52 %^^A It populates the variables \filename, \filedate, and \fileversion
53 %^^A
54 % \iffalse
55 %<*driver>
56 \ProvidesFile{graphpaper.dtx}
57 %</driver>
58 %<class>\NeedsTeXFormat{LaTeX2e}[2021-10-10]
59 %<class>\ProvidesClass{graphpaper}%
60 %<*class>
61 [2022-04-23 1.1 A LaTeX class to generate several types of graph papers]
62 %</class>
63 %<*driver>
64 \documentclass[11pt,a4paper]{ltxdoc}
65 \usepackage[T1]{fontenc}
66 \usepackage{lmodern}
67 \usepackage[a4paper,lines=50]{geometry}
68 \usepackage{multicol}
69 \hfuzz 10pt
70 \let\originalmeta\meta
71 \renewcommand\meta[1]{{\normalfont\originalmeta{#1}}}
72 \renewcommand\marg[1]{\texttt{\{\meta{#1}\}}}
73 \newcommand\Marg[1]{\texttt{\{#1\}}}
74 \newcommand\opz[1]{\texttt{[\meta{#1}]}}
75 \newcommand\Opz[1]{\texttt{[#1]}}
76 \newcommand\amb[1]{\texttt{\slshape#1}}\let\env\amb
77 \renewcommand\cs[1]{{\normalfont\ttfamily\char92#1}}
78 \newcommand\Benv[1]{\texttt{\char92begin\{#1\}}}
79 \newcommand\Eenv[1]{\texttt{\char92end\{#1\}}}
80 \newcommand\eTeX{$\varepsilon$-\TeX}
81 \providecommand\prog{}
82 \renewcommand\prog[1]{\textsf{#1}}
83 \newcommand\pack[1]{\texttt{\itshape#1}}
84 \newcommand\class[1]{\texttt{#1}}
85 %
86 \newenvironment{ttsintassi}{\begin{lrbox}{0}
87 \minipage{\dimexpr\linewidth-2\fboxrule-2\fboxsep}\ttfamily\obeylines}%
88 {\endminipage\end{lrbox}\center\fbox{\box0}\endcenter}
89 \let\ttsyntax\ttsintassi \let\endttsyntax\endttsintassi
90 %
91 \usepackage{color}
92 \definecolor{sfondoblu}{rgb}{0.94,0.97,1}
93 \usepackage{listings}
94 \lstset{language=[LaTeX]TeX,
95 basicstyle=\footnotesize\ttfamily,
96 keywordstyle=\color{blue}\bfseries,
97 commentstyle=\color{gray},
98 backgroundcolor=\color{sfondoblu},
99 frameround=tttt,
100 frame=tlrb,
101 escapechar=|,
102 morekeywords={bilinear, semilogx, semilogy, loglog, polar, logpolar, smith, setgridcolor, setmajorlinethickness, setmediumlinethickness, setminorlinethickness, setminimumdistance, setxside, setyside, customcode},
103 columns=flexible
104 }
105 \begin{document}
106 \GetFileInfo{graphpaper.dtx}
107 \title{Documentation of the \class{graphpaper} \LaTeX\ class}
108 \author{Claudio Beccari \and Francesco Biccari\thanks{Corresponding author: [email protected]}}
109 \date{Version number \fileversion; last revised on \filedate.}
110 \maketitle
111 \setcounter{tocdepth}{2}
112 \renewcommand{\columnseprule}{0.4pt}
113 \setlength{\columnsep}{1.5cm}
114
115 \addtocontents{toc}{\protect\begin{multicols}{2}}
116 {\small
117 \tableofcontents}
118
119 \DocInput{graphpaper.dtx}
120 \addtocontents{toc}{\protect\end{multicols}}
121 \end{document}
122 %</driver>
123 % \fi
124 %^^A \CheckSum{100}
125 %\begin{abstract}
126 % This document describes how to use the \LaTeX\ document class \class{graphpaper}.
127 % It allows to print several types of graph papers: bilinear,
128 % semilogarithmic, bilogarithmic, polar, Smith charts.
129 %\end{abstract}
130 %
131 %\section{Legal terms}
132 % This file is part of the |graphpaper| bundle.
133 %
134 % This work may be distributed and/or modified under the
135 % conditions of the \LaTeX\ Project Public License, either version 1.3c
136 % of this license or (at your option) any later version.
137 % The latest version of this license is at:
138 % http://www.latex-project.org/lppl.txt
139 %
140 % This work has the LPPL maintenance status ``maintained''.
141 %
142 % This work consists of this file graphpaper.dtx,
143 % and the derived files graphpaper.cls and graphpaper.pdf.
144 %
145 % The list of derived (unpacked) files belonging to the distribution
146 % and covered by the LPPL is contained in the README file.
147 %
148 %\section{Installation}
149 % The simplest way to install \class{graphpaper} is by the package manager of your \TeX\
150 % distribution (\TeX\ Live or MiK\TeX). For manual installation see the README file.
151 %
152 %
153 % \newpage
154 % \section{How to use graphpaper}
155 % \label{sec:howto}
156 %
157 % \class{Graphpaper} is a \LaTeX\ class and it is loaded as usual:
158 %
159 % \iffalse
160 %<*example>
161 % \fi
162 \begin{lstlisting}
163 \documentclass|\opz{options}|{graphpaper}
164 \end{lstlisting}
165 % \iffalse
166 %</example>
167 % \fi
168 %
169 % It has three class options to specify the paper format:
170 % \texttt{a4paper} (default), \texttt{a3paper}, \texttt{letterpaper}.
171 % The paper orientation cannot be changed and it is always set
172 % to landscape.
173 %
174 % \class{Graphpaper} provides the following commands (to be used
175 % inside the body of the document) in order to compose graph papers.
176 % At the end of the execution of these commands, a new page
177 % is always started.
178 %
179 % \iffalse
180 %<*example>
181 % \fi
182 \begin{lstlisting}
183 \bilinear
184
185 \semilogx|\marg{decades along x}|
186
187 \semilogy|\marg{decades along y}|
188
189 \loglog|\opz{0/1}||\marg{decades along x}||\marg{decades along y}|
190
191 \polar
192
193 \logpolar|\marg{decades along radius}|
194
195 \smith
196 \end{lstlisting}
197 % \iffalse
198 %</example>
199 % \fi
200 % The commands \cs{bilinear}, \cs{semilogx}, and \cs{semilogy} are self
201 % explanatory.
202 % The optional parameter in the \cs{loglog} command chooses wether the
203 % decade length along the abscissa and ordinate axes must have the same
204 % dimension. It can assume the value 0 (free dimensions) or 1 (same
205 % dimensions), 0 being the default.
206 % The commadns \cs{polar}, \cs{logpolar}, \cs{smith} are used to plot
207 % polar, logpolar, and Smith chart graph papers. The mandatory argument
208 % of \cs{logpolar} specifies the number of decades.
209 %
210 % There are several commands to change the appearance of the graph papers.
211 % They must be inserted before the graph paper command which we want they
212 % affect.
213 %
214 % The following ones are specific to bilinear, semilog and loglog papers
215 % only:
216 % \iffalse
217 %<*example>
218 % \fi
219 \begin{lstlisting}
220 \setxside|\marg{length}|
221
222 \setyside|\marg{length}|
223
224 \setminimumdistance|\marg{length}|
225 \end{lstlisting}
226 % \iffalse
227 %</example>
228 % \fi
229 % \cs{setxside} and \cs{setyside} allow to specify the dimensions of the
230 % rectangle of the grid. The default values are (260\,mm, 180\,mm) for
231 % A4 paper, (250\,mm, 190\,mm) for letter paper, and (380\,mm, 280\,mm)
232 % for A3 paper.
233 %
234 % \cs{setminimumdistance} specifies the minimal optical distance
235 % between two lines. Default is 1\,mm. In this way, the number of
236 % subdivision is automatically composed.
237 %
238 % The following commands are instead general settings for all graph
239 % papers:
240 % \iffalse
241 %<*example>
242 % \fi
243 \begin{lstlisting}
244 \setgridcolor|\marg{color}|
245
246 \setmajorlinethickness|\marg{length}|
247
248 \setmediumlinethickness|\marg{length}|
249
250 \setminorlinethickness|\marg{length}|
251
252 \customcode|\opz{0/1}\marg{picture environment commands}|
253 \end{lstlisting}
254 % \iffalse
255 %</example>
256 % \fi
257 %
258 % \cs{setgridcolor} sets the color of the grid. The argument must be a
259 % color defined or predefined by the color or |xcolor| package. The
260 % default color is the typical red-orange color used in many graph papers,
261 % Pantone 2011 U corresponding to RGB (250,153,89).
262 %
263 % \cs{setmajorlinethickness}, \cs{setmediumlinethickness},
264 % \cs{setminorlinethickness} can be used to change the thickness of the
265 % lines. The default values are 1\,pt, 0.6\,pt, 0.25\,pt, respectively.
266 %
267 % \cs{customcode} accepts all the commands accepted by the picture
268 % environment. This snippet of code is inserted inside the picture
269 % environment used to draw the subsequent graph paper.
270 % The origin of the coordinate system in the case of rectangular graph
271 % papers is the lower left vertex. The \cs{unitlength} is set to 1\,mm.
272 % For circular plots (both polar and Smith) the origin is in the center
273 % of the circle and the \cs{unitlength} is set to 1/140 of the paper height
274 % currently in use.
275 %
276 % The \cs{customcode} command can be used, for example, to add a logo
277 % or to draw on the graph paper.
278 % Its optional argument is by default set to 0. If it is set to 1, the
279 % content of the \cs{customcode} is erased after its usage in a
280 % graphpaper.
281 %
282 %
283 %\StopEventually{}
284 %
285 %\iffalse
286 %<*class>
287 %\fi
288 %\clearpage
289 %\section{The implementation}
290 % This class file has been already identified by the commands extracted
291 % by the |DocStrip| package, during the |.dtx| file compilation.
292 % Therefore the commands \cs{NeedsTeXFormat} and \cs{ProvidesClass} are
293 % already present in the |.cls| file.
294 %
295 % \subsection{Loaded packages, class options, and initial settings}
296 % The |xkeyvalue| package is used in order to define the class options:
297 % \begin{macrocode}
298 \RequirePackage{xkeyval}
299 % \end{macrocode}
300 % Three class options are implemented and they allows only to change the
301 % paper format (A4, A3, letter). The orientation of the paper is fixed
302 % to landscape.
303 %
304 % \begin{macrocode}
305 \def\GP@paper{1}
306 \define@key[GRP]{}{a4paper}[]{\PassOptionsToPackage{a4paper}{geometry}}
307 \define@key[GRP]{}{letterpaper}[]{\PassOptionsToPackage{letterpaper}{geometry}%
308 \def\GP@paper{2}}
309 \define@key[GRP]{}{a3paper}[]{\PassOptionsToPackage{a3paper}{geometry}%
310 \def\GP@paper{3}}
311 \DeclareOptionX*{\ClassError{graphpaper}{Option '\CurrentOption'%
312 \MessageBreak is not valid}{Remove '\CurrentOption' %
313 from class options}}
314 \ProcessOptionsX[GRP]<>
315 % \end{macrocode}
316 %
317 % The class is based on the \class{article} class. The default paper
318 % is A4.
319 % \begin{macrocode}
320 \LoadClass[a4paper,11pt]{article}
321 % \end{macrocode}
322 %
323 % Some packages are loaded. \pack{euclideangeometry} loads \pack{curve2e}
324 % which in turns loads \pack{pict2e}; all of them are \env{picture}
325 % environment extensions.
326 % \begin{macrocode}
327 \RequirePackage[landscape]{geometry}
328 \RequirePackage{euclideangeometry,graphicx,xcolor}
329 % \end{macrocode}
330 %
331 % Default line color (Pantone 2011~U).
332 % \begin{macrocode}
333 \definecolor{gridcolor}{RGB}{250,153,89}
334 % \end{macrocode}
335 %
336 % Default thickness of the lines used for main divisions and subdivisions.
337 % The ISO-UNI standards prescribe a geometric progression with $\sqrt{2}$
338 % ratio, but it is not respected here.
339 % It must be keep in mind also that a safe minimum thickness for an offset
340 % monochromatic printer is about 0.25\,pt, whereas a safe minimum
341 % thickness for a laser printer is about 0.5\,pt.
342 % \begin{macrocode}
343 \newlength\lwa
344 \setlength{\lwa}{1pt}
345 \newlength\lwb
346 \setlength{\lwb}{0.6pt}
347 \newlength\lwc
348 \setlength{\lwc}{0.25pt}
349 % \end{macrocode}
350 %
351 % Minimum distance between two subdivision lines. A necessary parameter
352 % for automatic choice of number of subdivisions. Default 1\,mm.
353 % \begin{macrocode}
354 \newlength\mindistanceunit
355 \setlength{\mindistanceunit}{1mm}
356 % \end{macrocode}
357 %
358 % Definition of the width and height of the main rectangle within which
359 % the bilinear, semilog and loglog grid is composed.
360 % \begin{macrocode}
361 \newlength\xsideunit
362 \newlength\ysideunit
363 \if\GP@paper1
364 \setlength{\xsideunit}{260mm}
365 \setlength{\ysideunit}{180mm}
366 \fi
367 \if\GP@paper2
368 \setlength{\xsideunit}{250mm}
369 \setlength{\ysideunit}{190mm}
370 \fi
371 \if\GP@paper3
372 \setlength{\xsideunit}{380mm}
373 \setlength{\ysideunit}{280mm}
374 \fi
375 % \end{macrocode}
376 %
377 %\subsection{Rectangular graph papers}
378 %
379 % As we will see below, the commands to compose the bilinear, semilog
380 % and loglog graph papers are just proper calls of the low-level command
381 % \cs{carta}.
382 %
383 %\subsubsection{Service macros for rectangular graph papers}
384 %
385 % First of all, four macros are defined. They are used by the
386 % \cs{carta} service command only.
387 %
388 % Two of them are simply two identical classical |whiledo| commands:
389 % the first cycles on the counter \cs{J} while the second one on the
390 % counter \cs{K}.
391 % They are two because in this way two nested |whiledo| commands can be
392 % implemented.
393 % These \cs{WhileDo} commands have four parameters:
394 % 1. the incremental step of the counter between cycles (default 1);
395 % 2. the initial value of the counter;
396 % 3. the final value of the counter;
397 % 4. the code to execute at each cycle.
398 % \begin{macrocode}
399 \newcount\J
400 \newcount\K
401
402 \newcommand\WhileDoOne[4][1]{%
403 \J=#2 \fpdowhile{\J=<#3 }{#4\advance\J by #1\relax}}
404
405 \newcommand\WhileDoTwo[4][1]{%
406 \K=#2 \fpdowhile{\K=<#3 }{#4\advance\K by #1\relax}}
407 % \end{macrocode}
408 %
409 %
410 % The other two commands are used to draw a periodic set of equidistant
411 % lines in log scale.
412 % These two commands are practically identical, the only difference is
413 % that they act on different axes.
414 % These commands have six parameters:
415 % 1. number of lines to draw (distance between these lines is the fifth
416 % parameter);
417 % 2. value at which the first line must be drawn (x-value for vertical
418 % lines, y-value for horizontal lines);
419 % 3. thickness;
420 % 4. tick length;
421 % 5. distance between two lines (typically the length of a decade:
422 % y-decade for horizontal lines, x-decade for vertical lines);
423 % 6. line length (typically the length of the graph paper sides:
424 % x-side for horizontal lines and y-side for vertical lines).
425 %
426 % \begin{macrocode}
427 \newcommand\hlines[6]{%
428 \multiput(-#4,\fpeval{ln(#2) * #5 / ln(10)})(0,#5){#1}%
429 {\linethickness{#3}\line(1,0){\fpeval{#6 + 2*#4}}}%
430 }
431
432 \newcommand\vlines[6]{%
433 \multiput(\fpeval{ln(#2) * #5 / ln(10)},-#4)(#5,0){#1}%
434 {\linethickness{#3}\line(0,1){\fpeval{#6 + 2*#4}}}%
435 }
436 % \end{macrocode}
437 %
438 %\subsubsection{Command for rectangular graph papers}
439 %
440 % Here starts the definition of the \cs{carta} command. Its syntax is
441 %\begin{ttsyntax}
442 %\cs{carta}\opz{0 or1}\marg{no. x decades}\marg{no. of y decades}
443 %\end{ttsyntax}
444 % If an axis has zero decades, the scale is linear.
445 % For example, \cs{carta}\Marg{0}\Marg{0} composes a bilinear graph
446 % paper, \cs{carta}\Marg{2}\Marg{0} composes a semilog graph paper with
447 % linear y-axis and two decades along x-axis, and so on.
448 % Its optional argument can be 0 or 1. If it is set to 0, and both the
449 % numbers of decades are greater than zero (which means the resulting
450 % graph paper is loglog), then the length of x-axis and y-axis decades
451 % are set to be equal.
452 %
453 % Declaration of the command and its arguments.
454 % \begin{macrocode}
455 \NewDocumentCommand{\carta}{O{0} m m}{%
456 % \end{macrocode}
457 %
458 % Typographical settings and definition of the main features of the
459 % graphpaper. \cs{xlength} and \cs{ylength} represent the lengths,
460 % expressed in mm, of the rectangle dimensions. \cs{minimumdistance}
461 % is the minimum distance at which two subdivision lines can be drawn.
462 % \begin{macrocode}
463 \newpage
464 \parindent=0pt
465 \pagestyle{empty}%
466 \color{gridcolor}%
467 \setlength{\unitlength}{1mm}%
468 \def\ticklength{2}
469 \def\minorticklength{1.2}
470 \def\minimumdistance{\fpeval{(\mindistanceunit/1mm)}}
471 \def\xlength{\fpeval{round(round(\xsideunit/1cm) * 10)}}
472 \def\ylength{\fpeval{round(round(\ysideunit/1cm) * 10)}}
473 % \end{macrocode}
474 %
475 % \cs{xlinsq} and \cs{ylinsq} represent the number of big divisions
476 % (cm) on horizontal and vertical axes for linear scales, respectively.
477 % \begin{macrocode}
478 \def\xlinsq{\inteval{\xlength/10}}
479 \def\ylinsq{\inteval{\ylength/10}}
480 % \end{macrocode}
481 %
482 % Implementation of the same decade length between x-axis and y-axis
483 % for loglog graph paper. This is obtained properly changing the
484 % values of \cs{xlength} and \cs{ylength}, making them equal.
485 % \begin{macrocode}
486 \edef\decx{#2}% decades along x
487 \edef\decy{#3}% decades along y
488 \unless\ifnum#2=0 \unless\ifnum#3=0 \ifnum#1=1%
489 \fptest{\decx/\decy < \xlength/\ylength}%
490 {\def\xlength{\fpeval{\ylength*\decx/\decy}}}
491 {\def\ylength{\fpeval{\xlength*\decy/\decx}}}
492 \fi\fi\fi
493 % \end{macrocode}
494 %
495 % Using the values of the paper width and height together with the
496 % length of the graph paper rectangle sides, the margins are calculated
497 % and passed to the geometry package in order to center the grid with
498 % respect to the page.
499 % \begin{macrocode}
500 \ifcsname ml\endcsname\relax\else\newlength\ml\fi
501 \ifcsname mr\endcsname\relax\else\newlength\mr\fi
502 \ifcsname mt\endcsname\relax\else\newlength\mt\fi
503 \ifcsname mb\endcsname\relax\else\newlength\mb\fi
504 \unless\ifcsname mr\endcsname\newlength\mr\fi
505 \unless\ifcsname mt\endcsname\newlength\mt\fi
506 \unless\ifcsname mb\endcsname\newlength\mb\fi
507 \setlength{\ml}{\fpeval{(\paperwidth/1mm - \xlength)/2}mm}
508 \setlength{\mr}{\fpeval{(\paperwidth/1mm - \xlength)/2}mm}
509 \setlength{\mt}{\fpeval{(\paperheight/1mm - \ylength)/2}mm}
510 \setlength{\mb}{\fpeval{(\paperheight/1mm - \ylength)/2}mm}
511 \newgeometry{left=\ml,right=\mr,top=\mt,bottom=\mb}
512 % \end{macrocode}
513 %
514 % Here starts the drawing of the graph paper by the |picture| environment.
515 % \begin{macrocode}
516 \begin{picture}(\xlength,\ylength)
517 % \end{macrocode}
518 %
519 % If the horizontal axis is linear, vertical lines are drawn by
520 % simple \cs{multiput} commands. Otherwise, if the scale is logarithmic,
521 % the vertical lines are drawn by the \cs{vlines} command defined above.
522 % \begin{macrocode}
523 \ifnum#2=0\relax
524 % vertical lines on linear abscissa. Main lines every 10 mm.
525 % Second level lines every 5 mm, Third level lines every 1 mm,
526 % according to the \minimumdistance value
527 \multiput(0,0)(10,0){\inteval{\xlinsq + 1}}{%
528 \linethickness{\lwa}\squarecap\line(0,1){\ylength}}
529 \ifnum\fpeval{\minimumdistance <= 5}=1
530 \multiput(5,0)(10,0){\xlinsq}{%
531 \linethickness{\lwb}\line(0,1){\ylength}}\fi
532 \ifnum\fpeval{\minimumdistance <= 1}=1
533 \multiput(0,0)(1,0){\xlength}{%
534 \linethickness{\lwc}\line(0,1){\ylength}}\fi
535 \else
536 % vertical lines on log abscissa
537 \edef\decxx{\fpeval{\decx + 1}}%
538 \edef\xstep{\fpeval{\xlength / \decx}}
539 % main lines: one for each decade (10) plus one at the end
540 \vlines{\decxx}{1}{\lwa}{\ticklength}{\xstep}{\ylength}
541 % second-level lines: one every unit (1), for each decade
542 \WhileDoOne{2}{9}{\vlines{\decx}{\J}{\lwb}{%
543 \minorticklength}{\xstep}{\ylength}}
544 % third-level lines: for each decade (10) and for each unit (1):
545 % 20, 10, 5, 2 are progressively tested and adopted if the distance
546 % between two subsequent nearest lines is less to \minimumdistance
547 \WhileDoTwo{1}{9}{%
548 \edef\xmindivfloat{%
549 \fpeval{(\K+1)*(1-10^-(\minimumdistance/\xstep))}}
550 % xmindiv corresponds to 1/20 of unit
551 \def\xmindiv{20}
552 % xmindivfloat corresponds to the distance of two
553 % subdivision with respect to the unit
554 \ifnum\fpeval{\xmindivfloat <= 0.5}=1 \def\xmindiv{10}\fi
555 \ifnum\fpeval{\xmindivfloat <= 0.2}=1 \def\xmindiv{4}\fi
556 \ifnum\fpeval{\xmindivfloat <= 0.1}=1 \def\xmindiv{2}\fi
557 \ifnum\fpeval{\xmindivfloat <= 0.05}=1 \def\xmindiv{1}\fi
558 \ifnum\fpeval{\xmindiv == 20}=1\relax
559 \else\WhileDoOne[\xmindiv]{\xmindiv}{19}{%
560 \vlines{\decx}{(\K+\J/20)}{\lwc}{0}{\xstep}{\ylength}}\fi}
561 \fi
562 % \end{macrocode}
563 %
564 % If the vertical axis is linear, horizontal lines are drawn by
565 % simple \cs{multiput} commands. Otherwise, if the scale is logarithmic,
566 % the horizontal lines are drawn by the \cs{hlines} command defined above.
567 % \begin{macrocode}
568 \ifnum#3=0\relax
569 % horizontal lines on linear ordinates. Main lines every 10 mm.
570 % Second level lines every 5 mm, Third level lines every 1 mm,
571 % according to the \minimumdistance value
572 \multiput(0,0)(0,10){\inteval{\ylinsq + 1}}{%
573 \linethickness{\lwa}\squarecap\line(1,0){\xlength}}
574 \ifnum\fpeval{\minimumdistance <= 5}=1
575 \multiput(0,5)(0,10){\ylinsq}{%
576 \linethickness{\lwb}\line(1,0){\xlength}}\fi
577 \ifnum\fpeval{\minimumdistance <= 1}=1
578 \multiput(0,0)(0,1){\ylength}{%
579 \linethickness{\lwc}\line(1,0){\xlength}}\fi
580 \else
581 % horizontal lines on log ordinates
582 \edef\decyy{\fpeval{\decy + 1}}%
583 \edef\ystep{\fpeval{\ylength / \decy}}
584 % main lines: one for each decade (10) plus one at the end
585 \hlines{\decyy}{1}{\lwa}{\ticklength}{\ystep}{\xlength}
586 % second-level lines: one every unit (1), for each decade
587 \WhileDoOne{2}{9}{\hlines{\decy}{\J}{\lwb}{%
588 \minorticklength}{\ystep}{\xlength}}
589 % third-level lines: for each decade (10) and for each unit (1):
590 % 20, 10, 5, 2 are progressively tested and adopted if the distance
591 % between two subsequent nearest lines is less to \minimumdistance
592 \WhileDoTwo{1}{9}{\edef\ymindivfloat{%
593 \fpeval{(\K+1)*(1-10^-(\minimumdistance/\ystep))}}
594 % ymindiv corresponds to 1/20 of unit
595 \def\ymindiv{20}
596 % ymindivfloat corresponds to the distance of two subdivisions
597 % with respect to the unit
598 \ifnum\fpeval{\ymindivfloat <= 0.5}=1 \def\ymindiv{10}\fi
599 \ifnum\fpeval{\ymindivfloat <= 0.2}=1 \def\ymindiv{4}\fi
600 \ifnum\fpeval{\ymindivfloat <= 0.1}=1 \def\ymindiv{2}\fi
601 \ifnum\fpeval{\ymindivfloat <= 0.05}=1 \def\ymindiv{1}\fi
602 \ifnum\fpeval{\ymindiv == 20}=1\relax
603 \else\WhileDoOne[\ymindiv]{\ymindiv}{19}{%
604 \hlines{\decy}{(\K+\J/20)}{\lwc}{0}{\ystep}{\xlength}}\fi}
605 \fi
606 % \end{macrocode}
607 %
608 % Custom code provided by the user. After executing the code to compose
609 % the rectangular graph paper and the user custom code, the latter is
610 % reset if the \cs{GP@customcodereset} is true.
611 % \begin{macrocode}
612 \GP@custom
613 \end{picture}
614 \ifGP@customcodereset\def\GP@custom{}\fi}
615 % \end{macrocode}
616 %
617 %
618 %
619 %\subsection{Circular graph papers}
620 %
621 % The \class{Graphpaper} class provides commands to draw three different
622 % circular graph papers: linear polar chart, log polar chart, Smith chart.
623 %
624 %\subsubsection{Service macros for Smith charts}
625 %
626 % Here follows a list of service macros used by circular graph papers.
627 %
628 % Definition of the counter \cs{I}, used both in polar paper and Smith chart.
629 % \begin{macrocode}
630 \newcount\I
631 % \end{macrocode}
632 %
633 % |Rbox| composes a tick and a label in a rotated box. It is used to
634 % compose the ticks and labels along the external circle of circular
635 % graph papers. It accepts three arguments: The first one is
636 % optional and represents
637 % the angle of rotation (default 0); the second one is optional too,
638 % it is inserted by round parentheses, and it represents the position of the
639 % box which can be given in cartesian $(x,y)$ or polar coordinates $(\theta:\rho)$
640 % (default 0:0); the third one is mandatory and
641 % contains the label.
642 % \begin{macrocode}
643 \NewDocumentCommand\Rbox{O{0} D(){0:0} m}{%
644 \fptest{#1>=0}{\edef\RotLab{\fpeval{#1-90}}}{\edef\RotLab{\fpeval{#1+90}}}%
645 \put(#2){\color{black}\segment(0,0)(#1:1)\put(#1:1){%
646 \rotatebox{\RotLab}{\makebox(0,0)[c]{%
647 \fptest{#1>=0}{\Pbox[b]}{\Pbox[t]}{\scriptstyle#3}[0]}}%
648 }%
649 }\ignorespaces}
650 % \end{macrocode}
651 %
652 % |\Xcircle| macro (used only for Smith charts) assumes that the scale
653 % factor |\Scala| ($s$) has already been defined and it takes only one
654 % mandatory parameter ($x$). It draws a circle with
655 % center $(sx/(x+1),0)$ and radius $s/(x+1)$. ($x$ represents the real
656 % part (resistance) of the normalised impedance.)
657 % \begin{macrocode}
658 \NewDocumentCommand\Xcircle{m}{%
659 \edef\Czero{0,0}\edef\Rzero{\Scala}%
660 \edef\Rdue{\fpeval{1/(#1+1)*\Scala}}%
661 \edef\Cdue{\fpeval{\Rzero-\Rdue},0}%
662 \Circlewithcenter\Cdue radius\Rdue\ignorespaces}
663 % \end{macrocode}
664 %
665 % |\Ycircle| macro (used only for Smith charts) assumes that the scale
666 % factor |\Scala| ($s$) has already been defined.
667 % It assumes that the circle diameter is 100|\unitlength|s long and it
668 % takes only one
669 % mandatory parameter ($y$). It draws an arc of a circle with
670 % center $(s,s/y)$, starting point at $(s,0)$ (and therefore radius
671 % $s/y$) and with an angle calculated in order to have the end point on
672 % the external circle. ($y$ represents the imaginary part (reactance)
673 % of the normalised impedance.)
674 % \begin{macrocode}
675 \NewDocumentCommand\Ycircle{m s}{%
676 \edef\Czero{0,0}\edef\Rzero{\Scala}% external circle center and radius
677 \edef\Rdue{\fpeval{\Scala/abs(#1)}}% Small circle radius
678 \edef\Cdue{\Rzero,\fpeval{\Scala/#1}}% Small circle center
679 \edef\Cuno{\Rzero,0}% First intersection point
680 \ModAndAngleOfVect\Cdue to\Mod and\Alfa % Small circle center polar coordinates
681 \IntersectionOfLines(\Czero)(\Cdue)and(\Cuno)(\fpeval{\Alfa+90}:1)to\Inter
682 \SymmetricalPointOf\Cuno respect\Inter to\Idue
683 \ModAndAngleOfVect\Idue to\Mdue and\Adue
684 \SubVect\Cdue from\Idue to\IIdue
685 \ModAndAngleOfVect\IIdue to\Mod and\Alfa
686 \fptest{#1>0}{\edef\Alfa{\fpeval{270-\Alfa}}\Arc(\Cdue)(\Idue){\Alfa}}%
687 {\edef\Alfa{\fpeval{270+\Alfa}}\Arc(\Cdue)(\Cuno){\Alfa}}%
688 \IfBooleanT{#2}{\Rbox[\Adue](\Idue){\color{black}#1}}\relax
689 \ignorespaces}
690 % \end{macrocode}
691 %
692 % The following two macros are used to compose the resistance axis
693 % below the Smith chart.
694 %
695 % |CalcRxx| macro (used only for Smith charts) assumes that the scale
696 % factor |Scala| ($s$) has already been defined.
697 % First, it calculates the reflection coefficient
698 % $\Gamma = s \frac{x-1}{x+1}$ from resistance $x$.
699 % A tick and a label are inserted for this value of $x$.
700 % \begin{macrocode}
701 \newcommand\CalcRxx[1]{%
702 \edef\Rxx{\fpeval{\Scala*(#1 - 1)/(#1 + 1)}}%
703 \segment(\Rxx,\LowResZero)(\Rxx,\LowResUno)\relax
704 \Pbox(\Rxx,\LowResUno)[t]{$\color{black}\scriptsize#1$}[0]\ignorespaces}
705 % \end{macrocode}
706 %
707 % |GradResist| macro (used only for Smith charts)
708 % draws the graduated axis for resistance and executes the |CalcRxx|
709 % for several values of resistance in order to compose the ticks and
710 % the labels.
711 % \begin{macrocode}
712 \newcommand\GradResist[1]{%
713 \color{black}
714 \edef\LowResZero{-#1}\edef\LowResUno{\fpeval{\LowResZero-1}}%
715 \I=0\edef\Auxx{0}\relax
716 \fpdowhile{\I<=10}{\CalcRxx{\Auxx}%
717 \advance\I by1\edef\Auxx{\fpeval{\Auxx+0.1}}\ignorespaces}
718 \CalcRxx{1.5}\I=2\edef\Auxx{2}\relax
719 \fpdowhile{\I<=9}{\CalcRxx{\Auxx}%
720 \advance\I by1\edef\Auxx{\fpeval{\Auxx+1}}\ignorespaces}
721 \CalcRxx{15}\CalcRxx{30}%
722 \edef\Rxx{\Scala}%
723 {\segment(-\Rxx,\LowResZero)(\Rxx,\LowResZero)%
724 \segment(\Rxx,\LowResZero)(\Rxx,\LowResUno)%
725 \Pbox(\Rxx,\LowResUno)[t]{\infty}[0]}}
726 % \end{macrocode}
727 %
728 % |GradPolar| macro (used only for polar charts)
729 % draws the graduated axis for log polar charts.
730 % \begin{macrocode}
731 \newcommand{\GradPolar}[1]{%
732 \color{black}
733 \edef\yline{\fpeval{-1.2 * \Scala}}
734 \linethickness{\lwa}
735 \segment(-\Scala,\yline)(\Scala,\yline)
736 \edef\ytickstart{\yline}
737 \edef\ytickstop{\fpeval{\yline-2}}
738 \edef\yytickstop{\fpeval{\yline-1}}
739 \segment(\Scala,\ytickstart)(\Scala,\ytickstop)
740 \segment(-\Scala,\ytickstart)(-\Scala,\ytickstop)
741 \fptest{#1=0}{%
742 \segment(0,\ytickstart)(0,\ytickstop)
743 \edef\plstep{\fpeval{\Scala/10}}
744 \linethickness{\lwb}
745 \multiput(\plstep,\yline)(\plstep,0){9}{\line(0,-1){1}}
746 \multiput(-\plstep,\yline)(-\plstep,0){9}{\line(0,-1){1}}%
747 }{%
748 \I=0
749 \fpwhiledo{\I<#1}{%
750 \linethickness{\lwa}
751 \edef\xtick{\fpeval{\I*\Scala/#1}}
752 \segment(\xtick,\ytickstart)(\xtick,\ytickstop)
753 \segment(-\xtick,\ytickstart)(-\xtick,\ytickstop)
754 \J=2
755 \fpwhiledo{\J<=9}{%
756 \linethickness{\lwb}
757 \edef\xtick{\fpeval{\Scala/#1 * (\I + ln(\J)/ln(10))}}
758 \segment(\xtick,\ytickstart)(\xtick,\yytickstop)
759 \segment(-\xtick,\ytickstart)(-\xtick,\yytickstop)
760 \advance\J by1\relax}
761 \advance\I by1\relax}}
762 }
763 % \end{macrocode}
764 %
765 %
766 %\subsubsection{Polar graph papers}
767 %
768 % The polar graph papers are composed by the command \cs{PolarChart}.
769 % The syntax is
770 %\begin{ttsyntax}
771 % \cs{PolarChart}\opz{diameter}\marg{decades}
772 %\end{ttsyntax}
773 % where \meta{diameter} is the dimension (plus some extra space for
774 % labels and margins) of the polar chart. Its default value
775 % corresponds to the \cs{paperheight} (the minimum dimension of the
776 % paper).
777 % The mandatory parameter \meta{decades} must be an integer number.
778 % Its value corresponds to the number of decades of the radial
779 % coordinate for the log polar graph paper.
780 % If its value is zero, the chart is linear.
781 % The maximum number of allowed decades is set by the macro \cs{NDecMax}:
782 % its default value is~2.
783 %
784 % Declaration of the command and its arguments.
785 % \begin{macrocode}
786 \NewDocumentCommand\PolarChart{O{\paperheight} m}{%
787 % \end{macrocode}
788 %
789 % Typographical settings and definition of the main features of the graphpaper.
790 % \cs{xlength} and \cs{ylength} represent the lengths of the rectangle
791 % dimensions in which the polar graph is plot.
792 % The origin of the coordinate system is in the center of the page.
793 % \begin{macrocode}
794 \newpage
795 \parindent=0pt
796 \pagestyle{empty}%
797 \ifcsname pmargin\endcsname\relax\else\newlength\pmargin\fi
798 \setlength{\pmargin}{20pt}
799 \newgeometry{left=\pmargin,right=\pmargin,top=\pmargin,bottom=\pmargin}
800 \def\factor{140}
801 \unitlength=\fpeval{#1/\factor}pt
802 \def\xlength{\fpeval{(\textwidth-0.01pt)/\unitlength}}
803 \def\ylength{\fpeval{(\textheight-0.01pt)/\unitlength}}
804 \begin{picture}(\xlength,\ylength)%
805 (\fpeval{-\xlength/2},\fpeval{-\ylength/2})%
806 \color{gridcolor}%
807 \edef\Scala{50}% The scale factor
808 % \end{macrocode}
809 %
810 %
811 % Circle stroking. In linear scale 10 radial units are present,
812 % therefore, 10 circles are drawn with tick lines,
813 % medium lines circles every 0.5 unit and thin lines circles every
814 % 0.1 unit.
815 % \begin{macrocode}
816 \fptest{#2=0}{% start circle linear radius sequence.
817 \I=1
818 \fpdowhile{\I=<100}{\edef\R{\fpeval{0.01*\Scala*\I}}%
819 {\fptest{\fpeval{\I-10(round(\I/10,0))}=0}{\linethickness{\lwa}%
820 }%
821 {\fptest{\fpeval{\I-5(round(\I/5,0))}=0}{\linethickness{\lwb}}%
822 {\linethickness{\lwc}}%
823 }\Circlewithcenter0,0radius\R
824 }\advance\I by1\relax}%
825 }% end circle linear radius sequence
826 {%
827 \edef\LnDieci{\fpeval{ln(10)}}%
828 \edef\ScalaDecade{\fpeval{\Scala/#2}}%
829 \fptest{#2<3}{%
830 \newcount\Dec \Dec=1\relax
831 \fpdowhile{\Dec=<#2}{%
832 \linethickness{\lwa}%
833 \edef\R{\fpeval{\Dec*\ScalaDecade}}%
834 \Circlewithcenter0,0radius\R% Thick circles
835 % First band from 1 to 4 (excluded)
836 \edef\LPLA{1}%
837 \fpdowhile{\LPLA<4}{
838 \edef\Logaritmo{\fpeval{\Dec-1+(ln(\LPLA))/\LnDieci}}%
839 \edef\R{\fpeval{\ScalaDecade*\Logaritmo}}%
840 \fptest{\R>0}{\fptest{\LPLA=round(\LPLA,0)}%
841 {\linethickness{\lwb}}{\linethickness{\lwc}}%
842 \Circlewithcenter0,0radius\R}{}%
843 \edef\LPLA{\fpeval{\LPLA+0.2}}}%
844 % Second band from 4 to 10 included
845 \edef\LPLA{4}%
846 \fpdowhile{\LPLA=<10}{%
847 \edef\Logaritmo{\fpeval{\Dec-1+(ln(\LPLA))/\LnDieci}}%
848 \edef\R{\fpeval{\ScalaDecade*\Logaritmo}}%
849 \fptest{\R>0}{\fptest{\LPLA=round(\LPLA,0)}%
850 {\linethickness{\lwb}}{\linethickness{\lwc}}%
851 \Circlewithcenter0,0radius\R}{}%
852 \edef\LPLA{\fpeval{\LPLA+0.5}}}%
853 \advance\Dec by1\relax}%
854 }{%
855 \ClassWarning{GraphPaper}{Logarithmic polar graph paper:\MessageBreak
856 too many decades: \number#2\space\MessageBreak
857 Reduce their number}%
858 }}% End logarithmic circle radius sequence
859 \ignorespaces
860 %
861 % \end{macrocode}
862 %
863 % Radial lines. \cs{I} represents the angle in degrees and it runs
864 % from 0 to 359. Tick lines every 10$^\circ$; medium lines every 5$^\circ$
865 % for units 2, 7, 8, 9, 10; thin lines every 2$^\circ$ for units 3, 4, 5, 6;
866 % thin lines every 1$^\circ$ for units 7, 8, 9, 10.
867 % \begin{macrocode}
868 \I=0\edef\R{\Scala}%
869 \fpdowhile{\I<360}{\edef\A{\fpeval{\I}}%
870 \fptest{\fpeval{\I-10(round(\I/10,0))}=0}%
871 {\linethickness{\lwa}\segment(0,0)(\A:\R)
872 \Rbox[\A](\A:\R){\color{black}\A}}% multiple of 10
873 {\fptest{\fpeval{\I-5(round(\I/5,0))}=0}%
874 {\linethickness{\lwb}%
875 \segment(\A:5)(\A:10)
876 \segment(\A:30)(\A:\R)}% multiple of 5
877 {\linethickness{\lwc}%
878 \fptest{\fpeval{\I-2(round(\I/2,0))}=0}%
879 {\segment(\A:10)(\A:\R)}% multiple of 2
880 {\segment(\A:30)(\A:\R)}% multiple of 1
881 }%
882 }%
883 \advance\I by 1\relax
884 }\ignorespaces
885 % \end{macrocode}
886 %
887 % Graduated axis.
888 % \begin{macrocode}
889 \GradPolar{#2}
890 % \end{macrocode}
891 %
892 % Custom code provided by the user. After executing the code to compose
893 % the rectangular graph paper and the user custom code, the latter is
894 % reset if the \cs{GP@customcodereset} is true.
895 % \begin{macrocode}
896 \GP@custom
897 \end{picture}
898 \ifGP@customcodereset\def\GP@custom{}\fi}
899 % \end{macrocode}
900 %
901 %
902 %\subsubsection{Smith chart graph paper}
903 %
904 % The Smith chart graph paper is composed by the command \cs{SmithChart}:
905 %\begin{ttsyntax}
906 % \cs{SmithChart}\oarg{diameter}
907 %\end{ttsyntax}
908 % where
909 % \meta{diameter} is the dimension (plus some extra space for labels and
910 % margins) of the Smith chart. Its default value corresponds to the
911 % \cs{paperheight} (the minimum dimension of the paper).
912 %
913 % \begin{macrocode}
914 \NewDocumentCommand\SmithChart{O{\paperheight}}{%
915 \newpage
916 \parindent=0pt
917 \pagestyle{empty}%
918 \ifcsname pmargin\endcsname\relax\else\newlength\pmargin\fi
919 \setlength{\pmargin}{20pt}
920 \newgeometry{left=\pmargin,right=\pmargin,top=\pmargin,bottom=\pmargin}
921 \def\factor{140}
922 \unitlength=\fpeval{#1/\factor}pt\relax
923 \def\xlength{\fpeval{(\textwidth-0.01pt)/\unitlength}}
924 \def\ylength{\fpeval{(\textheight-0.01pt)/\unitlength}}
925 \begin{picture}(\xlength,\ylength)%
926 (\fpeval{-\xlength/2},\fpeval{-\ylength/2})%
927 \color{gridcolor}%
928 \edef\Scala{50}% scale factor based on the main circle but valid
929 % for everything inside the graph paper.
930 {\color{black}\Pbox(0,0){}[4]}% Black dot in the origin
931 % images of the vertical cartesian lines
932 \I=0\relax
933 \fpdowhile{\I=<6}{\edef\Aux{\fpeval{\I/20}}{%
934 \fptest{\I=0}{\color{black}}{\color{gridcolor}}\thicklines\Xcircle{\Aux}}%
935 \advance\I by1\edef\Aux{\fpeval{\I/20}}\Xcircle{\Aux}%
936 \advance\I by1\ignorespaces}%fino a 0.4
937 \fpdowhile{\I=<16}{\edef\Aux{\fpeval{\I/20}}\relax
938 {\thicklines\Xcircle{\Aux}}\advance\I by2\edef\Aux{\fpeval{\I/20}}\relax
939 \Xcircle{\Aux}\advance\I by2\ignorespaces}% fino a 1
940 \fpdowhile{\I=<36}{\edef\Aux{\fpeval{\I/20}}\relax
941 {\thicklines\Xcircle{\Aux}}\advance\I by4\edef\Aux{\fpeval{\I/20}}\relax
942 \Xcircle{\Aux}\advance\I by4\ignorespaces}% fino a 2
943 \fpdowhile{\I=<96}{\edef\Aux{\fpeval{\I/20}}\relax
944 {\thicklines\Xcircle{\Aux}}\advance\I by8\edef\Aux{\fpeval{\I/20}}\relax
945 \Xcircle{\Aux}\advance\I by8\ignorespaces}%fino a 5
946 \fpdowhile{\I=<296}{\edef\Aux{\fpeval{\I/20}}\relax
947 {\thicklines\Xcircle{\Aux}}\advance\I by16\edef\Aux{\fpeval{\I/20}}\relax
948 \Xcircle{\Aux}\advance\I by16\ignorespaces}% up to 15
949 % Images of the horizontal cartesian semi-lines
950 \Ycircle{1}%
951 {\thicklines\segment(-\Rzero,0)(\Rzero,0)}% diameter
952 \Rbox[180](-\Rzero,0){0}\Rbox[0](\Rzero,0){\infty}
953 \Ycircle{0.05}\Ycircle{-0.05}\I=2% \I=2 is to avoid a division by 0
954 \fpdowhile{\I=<18}{\edef\Aux{\fpeval{\I/20}}\relax
955 {\thicklines\Ycircle{\Aux}*\Ycircle{-\Aux}*}%
956 \advance\I by1\edef\Aux{\fpeval{\I/20}}\relax
957 \Ycircle{\Aux}\Ycircle{-\Aux}\advance\I by 1\ignorespaces}% restarts from 1
958 \fpdowhile{\I<40}{\edef\Aux{\fpeval{\I/20}}\relax
959 {\thicklines\Ycircle{\Aux}*\Ycircle{-\Aux}*}%
960 \advance\I by 2\edef\Aux{\fpeval{\I/20}}\relax
961 \Ycircle{\Aux}\Ycircle{-\Aux}\advance\I by 2\ignorespaces}% restarts from 2
962 \fpdowhile{\I<80}{\edef\Aux{\fpeval{\I/20}}\relax
963 {\thicklines\Ycircle{\Aux}*\Ycircle{-\Aux}*}%
964 \advance\I by 4\edef\Aux{\fpeval{\I/20}}\relax
965 \Ycircle{\Aux}\Ycircle{-\Aux}\advance\I by 4\ignorespaces}% restarts from 4
966 \fpdowhile{\I=<140}{\edef\Aux{\fpeval{\I/20}}\relax
967 {\thicklines\Ycircle{\Aux}*\Ycircle{-\Aux}*}%
968 \advance\I by 10\edef\Aux{\fpeval{\I/20}}\relax
969 \Ycircle{\Aux}\Ycircle{-\Aux}\advance\I by 10\ignorespaces}% stops at 7.5
970 {\thicklines\Ycircle{8}*\Ycircle{-8}*}%
971 % non linear graduation for the abscissas
972 \GradResist{62}%
973 % Polar graduation in normalised wave length percentages
974 \edef\Rout{\fpeval{1.09*\Rzero}}%
975 \edef\RoutCifre{\fpeval{\Rout+2}}%
976 \edef\RoutTak{\fpeval{\Rout+1}}%
977 {\color{black}%
978 \Circlewithcenter 0,0radius\Rout
979 \I=0\fpdowhile{\I<10}%
980 {\edef\LAng{\fpeval{180-\I*36}}\edef\Cifre{\fpeval{\I*5}}%
981 \put(\LAng:\RoutCifre){%
982 \rotatebox{\fpeval{\LAng-90}}{\makebox(0,0)[b]{\scriptsize\Cifre}}}%
983 \advance\I by 1\ignorespaces}
984 \I=0\fpdowhile{\I<50}{%
985 \edef\LAng{\fpeval{180-\I*7.2}}\segment(\LAng:\Rout)(\LAng:\RoutTak)%
986 \advance\I by1\ignorespaces}
987 %
988 % Outside circle encloses everything except the abscissa graduation.
989 % Everything lays inside a square
990 \Circlewithcenter0,0radius{\fpeval{\Scala+9}}}%
991 % Now the user supplied code is executed
992 \GP@custom
993 \end{picture}
994 \ifGP@customcodereset\def\GP@custom{}\fi}%
995 % \end{macrocode}
996 %
997 %
998 %\subsection{User interface}
999 %
1000 % Here follows the user commands to draw the graph papers, as described in
1001 % section~\ref{sec:howto}:
1002 % \begin{macrocode}
1003 \NewDocumentCommand{\bilinear}{}{\carta{0}{0}}
1004 \NewDocumentCommand{\semilogx}{m}{\carta{#1}{0}}
1005 \NewDocumentCommand{\semilogy}{m}{\carta{0}{#1}}
1006 \NewDocumentCommand{\loglog}{O{0}mm}{\carta[#1]{#2}{#3}}
1007 \NewDocumentCommand{\polar}{}{\PolarChart{0}}
1008 \NewDocumentCommand{\logpolar}{m}{\PolarChart{#1}}
1009 \NewDocumentCommand{\smith}{}{\SmithChart}
1010 % \end{macrocode}
1011 %
1012 % The user commands to customise the appearance of the graph
1013 % papers is defined. Their syntax was previously described in
1014 % sectio~\ref{sec:howto}:
1015 % \begin{macrocode}
1016 \NewDocumentCommand{\setgridcolor}{m}{\colorlet{gridcolor}{#1}}
1017 \NewDocumentCommand{\setmajorlinethickness}{m}{\setlength{\lwa}{#1}}
1018 \NewDocumentCommand{\setmediumlinethickness}{m}{\setlength{\lwb}{#1}}
1019 \NewDocumentCommand{\setminorlinethickness}{m}{\setlength{\lwc}{#1}}
1020 \NewDocumentCommand{\setminimumdistance}{m}{\setlength{\mindistanceunit}{#1}}
1021 \NewDocumentCommand{\setxside}{m}{%
1022 \ifnum\fpeval{#1 > \paperwidth}=1 \ClassError{graphpaper}{X side too wide!} \fi
1023 \setlength{\xsideunit}{#1}}
1024 \NewDocumentCommand{\setyside}{m}{%
1025 \ifnum\fpeval{#1 > \paperheight}=1 \ClassError{graphpaper}{Y side too wide!} \fi
1026 \setlength{\ysideunit}{#1}}
1027 \def\GP@custom{}
1028 \newif\ifGP@customcodereset \GP@customcoderesettrue
1029 \NewDocumentCommand{\customcode}{O{1} m}{%
1030 \ifnum#1=\z@ \GP@customcoderesetfalse \fi%
1031 \def\GP@custom{#2}}
1032 % \end{macrocode}
1033 %
1034 %
1035 %\subsection{Class code end}
1036 %
1037 % \begin{macrocode}
1038 %
1039 \endinput
1040 % \end{macrocode}
1041 %
1042 %\iffalse
1043 %</class>
1044 %\fi
1045 %
1046 % \Finale
1047 %^^A