% \iffalse % This is the coordsys package, coordsys.dtx % Copyright 2000--01 by Mogens Lemvig Hansen. % % Run first coordsys.ins then this file, coordsys.dtx, % through LaTeX and read the documentation in coordsys.dvi % % This program may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.2 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.2 or later is part of all distributions of LaTeX % version 1999/12/01 or later. % % This program consists of the files coordsys.dtx and coordsys.ins % %<*docdriver> \documentclass{ltxdoc}[1996/01/11] \usepackage{url} \usepackage{coordsys,logsys} \CodelineIndex%\EnableCrossrefs \makeatletter \newcommand{\nextlinelabel}[2][1]{\@bsphack \@tempcnta\c@CodelineNo \advance\@tempcnta#1\relax \def\@currentlabel{\the\@tempcnta}\label{#2}% \@esphack} \makeatother \begin{document} \DocInput{coordsys.dtx} \end{document} % % \fi % \CheckSum{1616} % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z % Digits \0\1\2\3\4\5\6\7\8\9 % Exclamation \! Double quote \" Hash (number) \# % Dollar \$ Percent \% Ampersand \& % Acute accent \' Left paren \( Right paren \) % Asterisk \* Plus \+ Comma \, % Minus \- Point \. Solidus \/ % Colon \: Semicolon \; Less than \< % Equals \= Greater than \> Question mark \? % Commercial at \@ Left bracket \[ Backslash \\ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % % \def\fileversion{1.1} \def\filedate{2001/11/29} \def\docdate{\filedate} % \title{The \textsf{coordsys} and \textsf{logsys} Packages\thanks{This % file describes version \fileversion, \filedate.}} % \author{\copyright\ Mogens Lemvig Hansen\thanks{% % The \textsf{coordsys} and \textsf{logsys} packages are distributed under % the \LaTeX\ Project % Public License; please see Section~\ref{sec:license}.}\\ % mlhansen@uniserve.com} % \date{\docdate} % \maketitle % \begin{abstract} % The \textsf{coordsys} package provides commands for typesetting % number lines (coordinate axes), coordinate systems, and grids % in the \textsf{picture} environment. % The \textsf{logsys} package extends the \textsf{coordsys} package by % providing logarithmic, semi-logarithmic, and double-logarithmic % coordinate systems and grids. % \end{abstract} % % \tableofcontents % % \section{Regular Coordinate Systems} % Load the \textsf{coordsys} package with the \verb:\usepackage: command. % \begin{quote} % \verb:\usepackage:\oarg{options}\verb:{coordsys}: % \end{quote} % The \textsf{coordsys} package provides three \meta{options}, % \textsf{centred} (the default), \textsf{outside}, and \textsf{inside}, that % control the % appearance of tick marks; see Section~\ref{sec:tickstyle} on % page~\pageref{sec:tickstyle}. % % \subsection{One Dimension} % \DescribeMacro{\numbline} % The \verb:\numbline: command typesets a number line. For example, % \begin{quote} % \begin{verbatim} % \begin{picture}(200,20)(-75,-15) % \numbline{-75}{125} % \end{picture} % \end{verbatim} % \begin{picture}(200,20)(-75,-15) % \numbline{-75}{125} % \end{picture} % \end{quote} % You should always use the \verb:\numbline: command inside a % \textsf{picture} environment. % Do not forget to leave room for the labels on the number line. % In the following examples I omit the \verb:\begin{picture}: % and \verb:\end{picture}: commands to reduce clutter. % % The tick marks are by default separated by 10 units; % give \verb:\numbline: an optional first argument to change that. % For example % \begin{quote} % \begin{verbatim} % \numbline[7]{-75}{125} % \end{verbatim} % \begin{picture}(200,20)(-75,-15) % \numbline[7]{-75}{125} % \end{picture} % \end{quote} % % \DescribeMacro{\numbline*} % The starred version of \verb:\numbline: omits the labels. % \begin{quote} % \begin{verbatim} % \numbline*[7]{-75}{125} % \end{verbatim} % \begin{picture}(200,6)(-75,-3) % \numbline*[7]{-75}{125} % \end{picture} % \end{quote} % % Thus, % \begin{quote} % \verb:\numbline:\oarg{spacing}\marg{from}\marg{to}\\ % \verb:\numbline*:\oarg{spacing}\marg{from}\marg{to} % \end{quote} % typeset (horizontal) number lines from \meta{from} to \meta{to} with % \meta{spacing} % units between the tick marks (the default is 10); % use the starred command to suppresses the labels. % All the arguments must be integers. % % \DescribeMacro{\vnumbline}\DescribeMacro{\vnumbline*} % The \verb:\vnumbline: and \verb:\vnumbline*: commands similarly % typeset vertical number lines. % \begin{quote} % \begin{minipage}{.2\linewidth} % \begin{picture}(20,100)(-17,20) % \vnumbline{20}{120} % \end{picture} % \end{minipage} % \qquad % \begin{minipage}{.6\linewidth} % \begin{verbatim} % \vnumbline{20}{120} % \end{verbatim} % \end{minipage} % \end{quote} % Thus, % \begin{quote} % \verb:\vnumbline:\oarg{spacing}\marg{from}\marg{to}\\ % \verb:\vnumbline*:\oarg{spacing}\marg{from}\marg{to} % \end{quote} % typeset vertical number lines from \meta{from} to \meta{to} with \meta{spacing} % units between the tick marks (the default is 10); % use the starred command to suppresses the labels. % All the arguments must be integers. % % \subsection{Two Dimensions} % \DescribeMacro{\coordsys} % Use the \verb:\coordsys: command to typeset coordinate systems. % \begin{quote} % \begin{picture}(200,110)(-50,-50) % \coordsys(-50,-50)(150,60) % \put(75,25){\texttt{\textbackslash coordsys(-50,-50)(150,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\coordsys*} % Thus, % \begin{quote} % \verb:\coordsys:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\coordsys*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset coordinate systems where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % tick marks on the horizontal axis; the default is 10 units. % The optional argument \meta{v-spacing} gives the spacing between the % tick marks on the vertical axis; the default is to use the same % spacing as on the horizontal axis. % The starred version omits the labels. % All the arguments must be integers. % % Regular coordinate systems with intersecting axes are not always % appropriate, so the \textsf{coordsys} package provides some alternative % styles. All the coordinate-system-drawing commands have similar syntax. % \DescribeMacro{\fcoordsys} % The \verb:\fcoordsys: command typesets framed coordinate systems; that is, the % axes are at the left and bottom edges of the system. % \begin{quote} % \begin{picture}(220,125)(-70,-65) % \fcoordsys[5](-50,-50)(150,60) % \put(55,25){\texttt{\textbackslash fcoordsys[5](-50,-50)(150,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\fcoordsys*} % Thus, % \begin{quote} % \verb:\fcoordsys:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\fcoordsys*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset framed coordinate systems where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % tick marks on the horizontal axis; the default is 10 units. % The optional argument \meta{v-spacing} gives the spacing between the % tick marks on the vertical axis; the default is to use the same % spacing as on the horizontal axis. % The starred version omits the labels. % All the arguments must be integers. % % \DescribeMacro{\bcoordsys} % The \verb:\bcoordsys: command typesets boxed coordinate systems. % \begin{quote} % \begin{picture}(265,125)(-70,-65) % \bcoordsys[15][5](-50,-50)(195,60) % \put(-30,25){\texttt{\textbackslash bcoordsys[15][5](-50,-50)(195,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\bcoordsys*} % Thus, % \begin{quote} % \verb:\bcoordsys:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\bcoordsys*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset boxed coordinate systems where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % tick marks on the horizontal axis; the default is 10 units. % The optional argument \meta{v-spacing} gives the spacing between the % tick marks on the vertical axis; the default is to use the same % spacing as on the horizontal axis. % The starred version omits the labels. % All the arguments must be integers. % % \DescribeMacro{\window} % The \verb:\window: command typesets a plotting window as on a graphing % calculator. % \begin{quote} % \begin{picture}(302,127)(-107,-67) % \window(-50,-50)(195,60) % \put(15,25){\texttt{\textbackslash window(-50,-50)(195,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\window*} % Thus, % \begin{quote} % \verb:\window:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\window*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset plotting windows where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The (regular, unlabelled) coordinate axes will be drawn % if they are inside the window. % The optional argument \meta{h-spacing} gives the spacing between the % tick marks on the horizontal axis; the default is 10 units. % The optional argument \meta{v-spacing} gives the spacing between the % tick marks on the vertical axis; the default is to use the same % spacing as on the horizontal axis. % The labels will look nicer if you use the \textsf{amstext} package (which is % part of the \textsf{amsmath} package). % The starred version omits values of the labels. % All the arguments must be integers. % % \DescribeMacro{\coordgrid} % The \verb:\coordgrid: command typesets a coordinate grid. % \begin{quote} % \begin{picture}(300, 125) % \coordgrid(0,0)(300,125) % \put(15,25){\texttt{\textbackslash coordgrid(0,0)(300,125)}} % \end{picture} % \end{quote} % The \verb:\coordgrid: command does not print any labels % but you can superimpose a coordinate system. % \begin{quote} % \begin{verbatim} % \coordgrid[15][5](-50,-50)(195,60) % \coordsys[15][5](-50,-50)(195,60) % \end{verbatim} % \begin{picture}(245,110)(-50,-50) % \coordgrid[15][5](-50,-50)(195,60) % \coordsys[15][5](-50,-50)(195,60) % \end{picture} % \end{quote} % Typesetting pretty grids with dotted lines is not easy. % If a grid does come out ugly, try to increase \verb:\unitlength: % to allow for more dots between the lines. % You may also reduce the size of the dots: see \verb:\gridstyle: below. % \DescribeMacro{\coordgrid*} % Alternatively you can use the \verb:\coordgrid*: command which % typesets a coordinate grid with solid lines. You could then use the % \textsf{color} package to colour the grid, say, gray; see % Section~\ref{sec:colour}. % % Thus, % \begin{quote} % \verb:\coordgrid:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\coordgrid*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset coordinate grids where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % vertical grid lines; the default is 10 units. % The optional argument \meta{v-spacing} gives the spacing between the % horizontal grid lines; the default is to use the same % spacing as between the vertical grid lines. % The starred version uses solid lines; % the un-starred version uses dotted lines. % All the arguments must be integers. % % \DescribeMacro{\gridstyle} % The default size of the dots is the with of \verb:\thinlines: % and \verb:\thicklines:. If you intend to print your grids at a % sufficiently high resolution, you should reduce the size of the % dots by issuing a \verb:\gridstyle: command. On my 300\,dpi printer, % these sizes look nice: % \begin{quote} % \begin{verbatim} % \gridstyle{\linethickness{0.24pt}}{\linethickness{0.48pt}} % \end{verbatim} % \gridstyle{\linethickness{0.24pt}}{\linethickness{0.48pt}} % \begin{picture}(245,110)(-50,-50) % \coordgrid[15][5](-50,-50)(195,60) % \coordsys[15][5](-50,-50)(195,60) % \end{picture} % \end{quote} % If you make grids for the screen, I recommend using colour. % See Section~\ref{sec:colour}. % % In general, % \begin{quote} % \verb:\gridstyle:\marg{thin declaration}\marg{thick declaration} % \end{quote} % Note that these are \emph{declarations}: the \meta{thin declarations} % apply also to the thick grid lines unless explicitly overruled by the % \meta{thick declaration}. % The current \verb:\gridstyle: applies to all types of grids: % dotted, solid, regular, or logarithmic. % The default style is \verb:\gridstyle{\thinlines}{\thicklines}:. % % % \subsection{Bells and Whistles} % \subsubsection{Manual Labels} % \DescribeMacro{\sethlabel}\DescribeMacro{\setvlabel} % All the number-line and coordinate-system commands format the labels using % the commands \verb:\sethlabel: (for labels on horizontal axes) and % \verb:\setvlabel: (for labels on vertical axes). If you set labels manually, % you should use the same commands for a uniform appearance. % \begin{quote} % \begin{verbatim} % \numbline{-75}{125} % \put(125,0){\sethlabel{x}} % \end{verbatim} % \begin{picture}(200,20)(-75,-15) % \numbline{-75}{125} % \put(125,0){\sethlabel{x}} % \end{picture} % \end{quote} % The syntax is % \begin{quote} % \verb:\sethlabel:\oarg{alignment}\marg{label}\\ % \verb:\setvlabel:\oarg{alignment}\marg{label} % \end{quote} % The \meta{label} is set in math mode. % The default \meta{alignment} is \verb:[t]: for \verb:\sethlabel: and % \verb:[r]: for \verb:\setvlabel:. You may want to add to these defaults % (as in \verb:\sethlabel[tl]:); you probably do not want to replace the % defaults. % % If you want your labels set in some other style, you must re-define % \verb:\sethlabel: and \verb:\setvlabel:. See the comments around code % line~\ref{cl:setlabels} on page~\pageref{cl:setlabels} and the example in % Section~\ref{sec:colour}. % % \subsubsection{Different Scales on the Two Axes} % Manual labels come in handy when you need the two axes of a coordinate % system to use different scales. \LaTeX\ (the \textsf{picture} environment) % does not support different scales; \verb:\unitlength: is used for both the % horizontal and the vertical direction. However, you can use manual labels % to fake it. % Here is a coordinate system that has been rigged to contain the graph of % $y=x^2$ for $x$ between $-10$ and $10$. % \begin{quote}\setlength{\unitlength}{5pt} % \begin{picture}(22,15)(-10,-3) % \numbline[1]{-10}{12} % \vnumbline*[1]{0}{12} % \put(0, 5){\setvlabel{50}} % \put(0,10){\setvlabel{100}} % \end{picture} % \begin{minipage}[b]{.5\linewidth} % \begin{verbatim} % \numbline[1]{-10}{12} % \vnumbline*[1]{0}{12} % \put(0, 5){\setvlabel{50}} % \put(0,10){\setvlabel{100}} % \end{verbatim} % \end{minipage} % \end{quote} % % \subsubsection{Thick Tick Density} % \DescribeMacro{\hthickratio} % \DescribeMacro{\vthickratio} % By default every fifth tick mark is thick. You can change that by % redefining % the commands \verb:\hthickratio: and \verb:\vthickratio:. % \begin{quote} % \begin{verbatim} % \renewcommand{\hthickratio}{4} % \numbline[25]{0}{350} % \end{verbatim} % \setlength{\unitlength}{.3pt} % \begin{picture}(350,80)(0,-50) % \renewcommand{\hthickratio}{4} % \numbline[25]{0}{350} % \end{picture} % \end{quote} % % The following coordinate system has been rigged for graphing $\sin$ or % $\cos$. % \begin{quote} % \begin{verbatim} % \renewcommand{\hthickratio}{6} % \coordsys*[15][10](0,-100)(400,110) % \put(0,-100){\setvlabel{-1}} % \put(0, -50){\setvlabel{-\frac12}} % \put(0, 50){\setvlabel{\frac12}} % \put(0, 100){\setvlabel{1}} % \put( 90,0){\sethlabel{\frac\pi2}} % \put(180,0){\sethlabel{\pi}} % \put(270,0){\sethlabel{\frac{3\pi}2}} % \put(360,0){\sethlabel{2\pi}} % \end{verbatim} % \setlength{\unitlength}{.5pt} % \begin{picture}(435,210)(-35,-100) % \renewcommand{\hthickratio}{6} % \coordsys*[15][10](0,-100)(400,110) % \put(0,-100){\setvlabel{-1}} % \put(0, -50){\setvlabel{-\frac12}} % \put(0, 50){\setvlabel{\frac12}} % \put(0, 100){\setvlabel{1}} % \put( 90,0){\sethlabel{\frac\pi2}} % \put(180,0){\sethlabel{\pi}} % \put(270,0){\sethlabel{\frac{3\pi}2}} % \put(360,0){\sethlabel{2\pi}} % \end{picture} % \end{quote} % % \subsubsection{Different Styles of Tick Marks} % \label{sec:tickstyle} % \DescribeMacro{\tickstyle} % As you can affect the width of the dots or lines of a % \verb:\coordgrid: with a \verb:\gridstyle: command, % so you can affect the width of the tick marks with a % \verb:\tickstyle: command: % \begin{quote} % \verb:\tickstyle:\marg{thin declaration}\marg{thick declaration} % \end{quote} % Note that these are \emph{declarations}: the \meta{thin declarations} % apply also to the thick tick marks unless explicitly overruled by the % \meta{thick declaration}.\footnote{And the declarations that apply % to the thick tick marks spill over to the labels which maybe they % shouldn't, so let's not talk about that.} % The default style is % \verb:\tickstyle{\thinlines}{\thicklines}:.\footnote{When % I wrote above that the default grid style is % \texttt{\textbackslash gridstyle\{\textbackslash thinlines\}\{\textbackslash % thicklines\}} I lied. The default grid style is the follow the current % \texttt{\textbackslash tickstyle}.} % % \DescribeMacro{\ticklength} % The \verb:\ticklength: command controls the length of the tick marks. % \begin{quote} % \begin{verbatim} % \tickstyle{\thinlines\renewcommand{\ticklength}{4pt}} % {\thinlines\renewcommand{\ticklength}{8pt}} % \end{verbatim} % \tickstyle{\thinlines\renewcommand{\ticklength}{4pt}} % {\thinlines\renewcommand{\ticklength}{8pt}} % \begin{picture}(200,20)(-75,-15) % \numbline{-75}{125} % \end{picture} % \end{quote} % Note that the \emph{command} \verb:\ticklength: must be changed with % \verb:\renewcommand:. % % If you prefer tick marks just on the outside of the coordinate axes, load % \textsf{coordsys} with the \textsf{outside} option. % \begin{quote} % \begin{verbatim} % \usepackage[outside]{coordsys} % \end{verbatim} % \makeatletter % \renewcommand{\vtickmark}{\makebox(0,0)[t]{\rule{\@wholewidth}{3pt}}} % \renewcommand{\htickmark}{\makebox(0,0)[r]{\rule{3pt}{\@wholewidth}}} % \makeatother % \begin{picture}(200,110)(-50,-50) % \coordsys(-50,-50)(150,60) % \end{picture} % \end{quote} % % Similarly, the \textsf{inside} option puts the tick marks on the inside of % the axes. The default option is \textsf{centred}. % % % % \section{Logarithmic Coordinate Systems} % Load the \textsf{logsys} package with the \verb:\usepackage: command. % \begin{quote} % \verb:\usepackage:\oarg{options}\verb:{coordsys,logsys}: % \end{quote} % The \textsf{logsys} package supports the same options, \textsf{centred}, % \textsf{outside}, and \textsf{inside}, as the \textsf{coordsys} package. % % \subsection{One Dimension} % \DescribeMacro{\logline} % The \verb:\logline: command typesets a horizontal, logarithmic number line. % \begin{quote} % \begin{verbatim} % \logline{-60}{210} % \end{verbatim} % \begin{picture}(270,20)(-60,-15) % \logline{-60}{210} % \end{picture} % \end{quote} % The \verb:\logline: command typesets only whole blocks of tick marks % (whole powers of $10$). % Making the axis long enough that the tick marks do not % collide with the arrow and yet not so long that it looks ridiculous is the % users responsibility. % The default distance between the thick tick marks (the powers of $10$) is % 50~units. % Therefore I made the axis above extend from $-60$ (a bit below $-50$ which % appears as $10^{-1} = \frac1{10}$) to $210$ (a bit above $200$ which appears % as $10^4$). % % \DescribeMacro{\logline*} % Thus, % \begin{quote} % \verb:\logline:\oarg{spacing}\marg{from}\marg{to}\\ % \verb:\logline*:\oarg{spacing}\marg{from}\marg{to} % \end{quote} % typeset horizontal, logarithmic number lines from \meta{from} to % \meta{to} with \meta{spacing} units between the powers of $10$; the default % is 50. % The starred version omits the labels. % All the arguments must be integers. % % The \verb:\logline: command only typesets an axis; it does not change the % way \LaTeX\ and the \textsf{picture} environment interprets coordinates. % The equation below gives the relationship between the coordinate to % \verb:\put:, $x_p$, and the apparent coordinate, $x_a$. % \[ % x_p = \meta{spacing} \log_{10} x_a. % \] % For example: % \begin{quote} % \begin{verbatim} % \logline[40]{-50}{210} % \put(87.04,10){\makebox(0,0)[b]{150}} % 40*log(150) = 87.04 % \put(87.04,10){\vector(0,-1){10}} % \end{verbatim} % \begin{picture}(260, 40)(-50,-15) % \logline[40]{-50}{210} % \put(87.04,10){\makebox(0,0)[b]{150}} ^^A% 40*log(150) = 87.04 % \put(87.04,10){\vector(0,-1){10}} % \end{picture} % \end{quote} % % \DescribeMacro{\vlogline} % \DescribeMacro{\vlogline*} % The vertical equivalent is \verb:\vlogline:: % \begin{quote} % \verb:\vlogline:\oarg{spacing}\marg{from}\marg{to}\\ % \verb:\vlogline*:\oarg{spacing}\marg{from}\marg{to} % \end{quote} % typeset vertical, logarithmic number lines from \meta{from} to % \meta{to} with \meta{spacing} units between the powers of $10$; the default % is 50. % The starred version omits the labels. % All the arguments must be integers. % % % \subsection{Two Dimensions} % \DescribeMacro{\logsys} % Use the \verb:\logsys: command to typeset logarithmic coordinate systems. % \begin{quote} % \begin{picture}(220,125)(-70,-65) % \logsys[5](-50,-50)(150,60) % \put(55,25){\texttt{\textbackslash logsys[5](-50,-50)(150,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\logsys*} % Thus, % \begin{quote} % \verb:\logsys:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\logsys*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset coordinate systems with logarithmic vertical axis, % where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % tick marks on the horizontal axis; the default is 10 units. % The optional argument \meta{v-spacing} gives the spacing between the % thick tick marks (powers of $10$) on the vertical axis; % the default is 50 units. % The starred version omits the labels. % All the arguments must be integers. % % \DescribeMacro{\semilogsys} % Use the \verb:\semilogsys: command to typeset semi-logarithmic % coordinate systems. % \begin{quote} % \begin{picture}(230,125)(-70,-65) % \semilogsys[25](-50,-50)(160,60) % \put(55,25){\texttt{\textbackslash semilogsys[25](-50,-50)(160,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\semilogsys*} % Thus, % \begin{quote} % \verb:\semilogsys:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\semilogsys*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset coordinate systems with logarithmic horizontal axis, % where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % thick tick marks (powers of $10$) on the horizontal axis; % the default is 50 units. % The optional argument \meta{v-spacing} gives the spacing between the % tick marks on the vertical axis; % the default is 10 units. % The starred version omits the labels. % All the arguments must be integers. % % \DescribeMacro{\loglogsys} % Use the \verb:\loglogsys: command to typeset double-logarithmic % coordinate systems. % \begin{quote} % \begin{picture}(230,125)(-70,-65) % \loglogsys(-50,-50)(160,60) % \put(55,25){\texttt{\textbackslash loglogsys(-50,-50)(150,60)}} % \end{picture} % \end{quote} % \DescribeMacro{\loglogsys*} % Thus, % \begin{quote} % \verb:\loglogsys:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\loglogsys*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset coordinate systems with two logarithmic axes, % where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % thick tick marks (powers of $10$) on the horizontal axis; % the default is 50 units. % The optional argument \meta{v-spacing} gives the spacing between the % thick tick marks (powers of $10$) on the vertical axis; % the default is 50 units. % The starred version omits the labels. % All the arguments must be integers. % % \DescribeMacro{\loggrid} % \DescribeMacro{\loggrid*} % \DescribeMacro{\semiloggrid} % \DescribeMacro{\semiloggrid*} % \DescribeMacro{\logloggrid} % \DescribeMacro{\logloggrid*} % The \verb:\loggrid:, \verb:\loggrid*:, \verb:\semiloggrid:, % \verb:\semiloggrid*:, \verb:\logloggrid:, and \verb:\logloggrid*: commands % typeset logarithmic grids. % \begin{quote} % \begin{verbatim} % \logloggrid*(0,0)(300,100) % \end{verbatim} % \begin{picture}(300, 100) % \logloggrid*(0,0)(300,100) % \end{picture} % \end{quote} % Thus, % \begin{quote} % \verb:\loggrid:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\loggrid*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\semiloggrid:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\semiloggrid*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\logloggrid:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\ % \verb:\logloggrid*:\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur} % \end{quote} % typeset logarithmic, semi-logarithmic, and double-logarithmic % coordinate grids where \parg{ll} is the lower-left corner % and \parg{ur} is the upper-right corner. % The optional argument \meta{h-spacing} gives the spacing between the % vertical grid lines and % the optional argument \meta{v-spacing} gives the spacing between the % horizontal grid lines; % The default spacing is 10 units on linear axes and 50 units between the % thick tick marks (the powers of $10$) on logarithmic axes. % The starred versions use solid lines; % the un-starred versions use dotted lines. % All the arguments must be integers. % % % \section{Filling the Coordinate Systems} % The \textsf{coordsys} and \textsf{logsys} packages typeset coordinate systems; % filling them is your task. However, an example or two could come in handy. % % \subsection{One Dimension} % \LaTeX's \textsf{picture} environment does a nice job for one dimensional % number lines. For example, % \begin{quote} % \begin{verbatim} % \numbline{-59}{100} % \put(90,0){\sethlabel{x}} % \put(-5,0){\circle{5}} % \put(60,0){\circle*{5}} % {\linethickness{2pt} % \put(-5,0){\line(1,0){65}} % } % \put(27.5,15){\vector(0,-1){15}} % \put(27.5,15){\makebox(0,0)[b]{Midpoint}} % \end{verbatim} % \begin{picture}(160,50)(-60,-25) % \numbline{-59}{100} % \put(90,0){\sethlabel{x}} % \put(-5,0){\circle{5}} % \put(60,0){\circle*{5}} % {\linethickness{2pt} % \put(-5,0){\line(1,0){65}} % } % \put(27.5,15){\vector(0,-1){15}} % \put(27.5,15){\makebox(0,0)[b]{Midpoint}} % \end{picture} % \end{quote} % % \subsection{Two Dimensions} % Filling two-dimensional coordinate systems you run into some of \LaTeX's % limitations. For plotting curves I recommend the \textsf{epic} and % \textsf{eepic} packages.\footnote{Both are old \LaTeX209 packages that work % fine in \LaTeXe. The \textsf{eepic} package re-implements the \textsf{epic} % package making use of \textsc{PostScript}. I shall explain the workings of % parts of \textsf{(e)epic} in more detail than I would have had they been % modern \LaTeXe\ packages.} % I especially like \textsf{(e)epic}'s \verb:\putfile: command which allows % you to calculate your plot with some external program, export the points to % plot to a text file, and import that file to have \LaTeX\ (or, better, % \textsc{PostScript}) draw the plot. % For external program I use Maple. % The \textsf{coordsys} package includes a piece of % Maple code that exports a Maple plot in the form \verb:\putfile: expects. % You can therefore take advantage of Maple adaptive plotting % algorithm\footnote{Maple cleverly calculates more points where the curve % wiggles.} in your \LaTeX\ plots. % % \iffalse %<*eepic> \documentclass{article} \usepackage{coordsys,logsys,epic,eepic} \title{Examples of combining the \textsf{coordsys} and \textsf{logsys} packages with the \textsf{epic} and \textsf{eepic} packages} \author{Mogens Lemvig Hansen\thanks{This file is part of the \textsf{coordsys} package.}} \date{2001/11/29} \begin{filecontents*}{parabola.put} %% plot( x^2/10, x=-10..10); -10 10 -9.5640569167 9.1471184705 -9.1847451708 8.4359543853 -8.7581694417 7.6705531969 -8.3287660917 6.936834461 -7.9014036208 6.2432179179 -7.5051839042 5.6327785435 -7.0949213375 5.0337908785 -6.6706272042 4.4497267297 -6.2476937875 3.9033677662 -5.8126547833 3.378695563 -5.4294721917 2.947916828 -4.99809935 2.4980997112 -4.56495525 2.0838816435 -4.14754065 1.7202093443 -3.7684882042 1.4201503345 -3.3177581833 1.1007519363 -2.9359307333 .8619689271 -2.4917746375 .6208940844 -2.0986212333 .4404211081 -1.6672696375 .2779788044 -1.2565209125 .1578844804 -.8279477083 .0685497408 -.4343837208 .0188689217 0 0 .4310767958 .0185827204 .8149238375 .0664100861 1.2294891583 .151164359 1.6577757 .2748220272 2.076770525 .4312975814 2.4821695625 .6161165737 2.932296075 .8598360271 3.3367547667 1.1133932373 3.76860075 1.4202351613 4.1599173958 1.730491274 4.58772985 2.1047265177 4.9902680292 2.4902775003 5.4110364125 2.9279315057 5.8224144167 3.3900509639 6.2530890625 3.9101122824 6.6678799333 4.4460622805 7.0920635083 5.0297364806 7.5127346292 5.6441181608 7.8992877 6.2398746167 8.3423211417 6.9594322031 8.7385755333 7.6362702352 9.1610653625 8.3925118576 9.5654420375 9.1497681373 10 10 \end{filecontents*} \begin{filecontents*}{cardioid.put} %% polarplot( 1+sin(theta), theta=0..2*Pi); %% scale=[100,100] 100 0 112.5885641573 15.5167663413 121.2445570425 31.7504425488 124.9346771084 41.8359445153 127.6592595167 52.4947513916 129.3454818525 63.6951715609 129.9035430519 75.2485730688 129.2857844612 86.9697309187 127.4606933136 98.778656501 124.6721568792 109.6842233725 120.8254764621 120.4325701546 115.7383687774 131.2750353131 109.5537903246 141.7021595985 102.04682232 151.9193228577 93.4710635868 161.4324297982 83.9356546875 170.0932289956 73.5054672343 177.8221882058 61.9526995832 184.6948697614 49.6891673596 190.3811055007 38.4075821367 194.3437411329 26.7804868717 197.2817805659 13.4073287469 199.3241367541 -.1194213848 199.9999465195 -13.7001223321 199.2942126268 -27.1225920093 197.211114697 -39.7635841421 193.9272282403 -51.9803652016 189.433045519 -62.5994526909 184.3513592329 -72.6733475464 178.3723143526 -83.8276198091 170.1818641203 -93.9669994784 160.9319074122 -101.6806050772 152.3668332452 -108.5310152046 143.226867249 -115.3534291624 131.9963774127 -120.8924957252 120.2693143392 -124.697389318 109.6016438805 -127.4604098723 98.78002972 -129.2969481099 86.8610741542 -129.9038059061 75.0328108808 -129.3734142009 63.9799851226 -127.8092628576 53.2473447208 -121.4895655594 32.3328189346 -112.5480715584 15.4550062449 -100.309648545 .3110927557 -85.706682373 -11.6784625329 -72.2431828754 -18.9103729475 -57.7358426983 -23.4802621906 -43.5809250175 -24.9994139188 -31.2181592951 -23.8524357161 -21.1087971266 -20.8736260664 -12.3189830664 -16.2186836807 -6.6594577853 -11.5632050042 -2.7880857408 -6.8438795102 -.9032538593 -3.3426230747 -.1081790589 -.8305646656 0 -.0004673786 .1072134621 -.8256496288 .8480702702 -3.2090325729 2.9340896713 -7.0641211764 6.712690173 -11.6164927603 12.7269542038 -16.4922352222 20.9946044182 -20.8272865832 30.5670656754 -23.7212041699 43.5839748809 -24.9994010709 56.6417957327 -23.7003283539 71.394649273 -19.2648555582 85.5865127718 -11.7574410531 100.000000082 0 \end{filecontents*} \begin{filecontents*}{logxxp1.put} %% logplot( x^2+1, x=-5..5); %% scale=[1,5] -5 7.074866740 -4.7820284583 6.889061600 -4.5923725854 6.720967370 -4.3790847208 6.524216565 -4.1643830458 6.317243645 -3.9507018104 6.101592535 -3.7525919521 5.892286960 -3.5474606688 5.665214645 -3.3353136021 5.418286380 -3.1238468938 5.158742355 -2.9063273917 4.876409562 -2.7147360958 4.613573345 -2.499049675 4.300266661 -2.282477625 3.965354533 -2.073770325 3.621593765 -1.8842441021 3.290236343 -1.6588790917 2.871244605 -1.4679653667 2.494943352 -1.2458873188 2.034603480 -1.0493106167 1.612184802 -.8336348187 1.145780627 -.6282604562 .722421444 -.4139738542 .3434785533 -.2171918604 .1000907366 -.0049358958 0 .2155383979 .0986065242 .4074619188 .3335397102 .6147445792 .696105675 .82888785 1.135646294 1.0383852625 1.588482628 1.2410847813 2.024417719 1.4661480375 2.491270161 1.6683773833 2.889458989 1.884300375 3.290337540 2.0799586979 3.632098842 2.293864925 3.983501612 2.4951340146 4.294397753 2.7055182063 4.600571939 2.9112072083 4.882925293 3.1265445313 5.162142965 3.3339399667 5.416645000 3.5460317542 5.663593805 3.7563673146 5.896364775 3.94964385 6.100499435 4.1711605708 6.323921585 4.3692877667 6.514972705 4.5805326813 6.710264855 4.7827210188 6.889664180 5 7.074866740 \end{filecontents*} \begin{document} \maketitle Your .dvi pre-viewer may not display the \textsc{PostScript} curves generated by the \textsf{eepic} package. % \fi % Here is how it works: % In Maple, read in the file \url{putfile} which is part of the % \textsf{coordsys} package. % \begin{verbatim} % > read "/where/you/placed/putfile"; % \end{verbatim} % Make your plot, here $y=\frac{x^2}{10}$. % \begin{verbatim} % > plot( x^2/10, x=-10..10); % \end{verbatim} % When you are happy with your plot, assign it to a variable. % \begin{verbatim} % > P := %: % \end{verbatim} % Then use the \verb:putfile: command to export the curve to the file % \url{parabola.put}. % \begin{verbatim} % > putfile( "parabola.put", P ); % \end{verbatim} % You should inspect the \url{.put} file and add a comment (preceded with % \verb:%:s) about which curve it represents.\footnote{Well, actually you % should edit the \url{.put} file a bit as it may contain numbers of the form % \mbox{\texttt{1.234e-7}} which \LaTeX\ cannot read. Such small numbers % should probably be rounded to zero. See also the comments preceding code % line~\ref{cl:writedata}.} % % In \LaTeX, use the \verb:\putfile: command to put \verb:\picsquare:s at each % point listed in \url{parabola.put}. % \iffalse Points on the parabola $y=\frac{x^2}{10}$. \begin{center} \setlength{\unitlength}{10pt} \begin{picture}(21,12)(-10,-1) % \fi % \begin{quote}\begin{verbatim} \coordsys[1](-10,0)(11,11) \putfile{parabola.put}{\picsquare} % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % If you have the \textsf{epic} and \textsf{eepic} packages, you can see the % result of the above commands (and all the other examples to follow in this % section) by running the file \url{ex-eepic.tex} through \LaTeX. % % To join the points, use the \textsf{drawjoin} environment of the % \textsf{(e)epic} package: \textsf{(e)epic} provides an alternative % \verb:\put: command, \verb:\jput:. % The \textsf{(e)epic} package joins objects put with the \verb:\jput: command % inside a \textsf{drawjoin} environment. % Thus, to draw a curve with the \verb:\putfile: command you enter a % \textsf{drawjoin} environment, let \verb:\put: be a synonym for % \verb:\jput:, and call \verb:\putfile:. % \iffalse The parabola $y=\frac{x^2}{10}$. \begin{center} \setlength{\unitlength}{10pt} \begin{picture}(21,12)(-10,-1) % \fi % \begin{quote}\begin{verbatim} \coordsys[1](-10,0)(11,11) \begin{drawjoin} \let\put=\jput \putfile{parabola.put}{\picsquare} \end{drawjoin} % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % The main remaining problem with drawing curves in \LaTeX\ is that \LaTeX\ % uses the same scale for both axes; in Maple terminology, \LaTeX\ uses % \texttt{scaling = constrained}.\footnote{If you intend to export a Maple % plot with \texttt{putfile}, you should use the \texttt{scaling = % constrained} option in Maple. Using or not using the option does not change % the contents of the \url{.put} file but Maple will display a closer % approximation of the graph \LaTeX\ will draw.} % Consider plotting $y=x^2$ for $x$ running from $-10$ to $10$. The graph is % $100$ units tall but only $20$ units wide. The solution is to fake % it:\footnote{Or you could say that the solution is to do the necessary % scaling by hand.} % Use the same curve as above but change the coordinate system so that the % curve appears to be that of $y=x^2$. % \iffalse The same curve again but dressed up to look like $y=x^2$. \begin{center} \setlength{\unitlength}{10pt} \begin{picture}(21,12)(-10,-1) % \fi % \begin{quote}\begin{verbatim} \coordsys*[1](-10,0)(11,11) \put(-10,0){\sethlabel{-10}} \put( -5,0){\sethlabel{-5}} \put( 5,0){\sethlabel{5}} \put( 10,0){\sethlabel{10}} \put(0, 5){\setvlabel{50}} \put(0,10){\setvlabel{100}} \begin{drawjoin} \let\put=\jput \putfile{parabola.put}{\picsquare} \end{drawjoin} % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % Scaling by hand can be appropriate even when the two axes do use the same % scale. Consider the graph of $r=1+\sin\theta$ in polar coordinates. The % graph is $2.6$ units wide and $2.25$ units tall. All the arguments to the % \verb:\coordsys: command must be integers, so the smallest distance between % tick marks is $1$ unit; the coordinate system will have very few tick marks. % Instead scale up by, say, a factor $100$. % You could plot $r=100(1+\sin\theta)$; instead I'll plot $r=1+\sin\theta$ % and take advantage of % \verb:putfile:s \verb:scale: option. % In Maple: % \begin{verbatim} % > read "/where/you/placed/putfile"; % > with(plots): % > polarplot( 1+sin(theta), theta=0..2*Pi); % > P := %: % > putfile("cardioid.put", P, scale=[100,100]); % \end{verbatim} % In \LaTeX: % \iffalse The graph of $r=1+\sin\theta$ in polar coordinates. The .put file has been scaled by a factor $100$, so the coordinate system is scaled the other way. \begin{center} \setlength{\unitlength}{0.6pt} \begin{picture}(295,260)(-145,-50) % \fi % \begin{quote}\begin{verbatim} \coordsys*(-145,-50)(150,210) \put(-100,0){\sethlabel{1}} \put( 100,0){\sethlabel{1}} \put(0,-50){\setvlabel{-\frac12}} \put(0,100){\setvlabel{1}} \put(0,200){\setvlabel{2}} \begin{drawjoin} \let\put=\jput \putfile{cardioid.put}{\picsquare} \end{drawjoin} % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % For logarithmic plots scaling is almost always necessary. Consider the % graph of $y=x^2+1$ (for $x$ running from $-5$ to $5$) % in a logarithmic coordinate system\footnote{Logarithmic % vertical scale, linear horizontal scale.}. % The vertical axis must extend from $1$ to at least $26$, so it must contain % two blocks of logarithmic tick marks. % The width of the graph is $10$ units, so make each % logarithmic block $5$ units tall (instead of the default $50$). % In Maple: % \begin{verbatim} % > read "/where/you/placed/putfile"; % > with(plots): % > logplot( x^2+1, x = -5..5); % > P := %: % > putfile("logxxp1.put", P, scale=[1,5]); % \end{verbatim} % In \LaTeX: % \iffalse The graph of $y=x^2+1$ in a logarithmic coordinate system. The size of each logarithmic block on the $y$-axis is $5$ units. \begin{center} \setlength{\unitlength}{10pt} \begin{picture}(12,12)(-6,-1) % \fi % \begin{quote}\begin{verbatim} \logsys[1][5](-6,0)(6,11) \begin{drawjoin} \let\put=\jput \putfile{logxxp1.put}{\picsquare} \end{drawjoin} % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % Use the \verb:putfile: command as follows: % \begin{quote} % \verb:putfile(: \meta{filename}\verb:,: \meta{PLOT structure} [\verb:,: % \meta{options} ] \verb:);: % \end{quote} % Here \meta{filename} is a string or a list or set of strings; the number of % strings must match the number of curves in the \meta{PLOT structure}. % The only possible option is % \begin{quote} % \verb:scale: \verb:=: \verb:[: \meta{number}\verb:,: \meta{number} \verb:]: % \end{quote} % The \verb:putfile: command will multiply all $x$-coordinates by the first % number and all $y$-coordinates by the second number. % Both numbers must be \verb:evalf:able. % % % \iffalse \end{document} % % \fi % % % \section{Colour}\label{sec:colour} % Using the \textsf{color} package you can create very nice coordinate grids. % This section gives a number of examples. % Please run the file \url{ex-color.tex} through \LaTeX\ to see the output of % the commands in this section. % % \iffalse %<*color> \documentclass{article} \usepackage{coordsys,logsys,color} \title{Examples of combining the \textsf{coordsys} and \textsf{logsys} packages with the \textsf{color} package} \author{Mogens Lemvig Hansen\thanks{This file is part of the \textsf{coordsys} package.}} \date{2001/11/29} \begin{document} \maketitle % \fi % In most cases grids should be gray so as to not attract too much attention. % \LaTeX\ does not pre-define a gray colour, so you must do it yourself. % \begin{quote}\begin{verbatim} \definecolor{gray}{gray}{0.5} \definecolor{lightgray}{gray}{0.75} % \end{verbatim}\end{quote} % You can of course put a grid in a \verb:\textcolor: command: % \iffalse \verb:\textcolor{gray}{\coordgrid*(-109,-65)(200,100)}:. \begin{center} \begin{picture}(309,165)(-109,-65) % \fi % \begin{quote}\begin{verbatim} \textcolor{gray}{\coordgrid*(-109,-65)(200,100)} \coordsys(-109,-65)(200,100) % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % If you have several grids, a better solution is to change % \verb:\gridstyle:. % \begin{quote}\begin{verbatim} \gridstyle{\thinlines\color{lightgray}}{\thinlines\color{gray}} % \end{verbatim}\end{quote} % The two \verb:\thinlines: commands are not necessary but better be % explicit. % \iffalse You have more control using grid styles. For example\\ \verb:\gridstyle{\thinlines\color{lightgray}}{\thinlines\color{gray}}:. \begin{center} \begin{picture}(309,165)(-109,-65) % \fi % \begin{quote}\begin{verbatim} \coordgrid*(-109,-65)(200,100) \coordsys(-109,-65)(200,100) % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % The labels can be hard to read on top of the grid lines. % You can re-define the commands that typeset the labels to set them % in a white \verb:\colorbox:. % \begin{quote}\begin{verbatim} \makeatletter \renewcommand{\setvlabel}[2][r]{% \makebox(0,0)[#1]{\colorbox{white}{$#2$}\hspace{5pt}}} \renewcommand{\sethlabel}[2][t]{% \makebox(0,0)[#1]{% \setlength{\@tempdimc}{3pt}% \addtolength{\@tempdimc}{\baselineskip}% \rule{0pt}{\@tempdimc}\colorbox{white}{$#2$}}} \makeatother % \end{verbatim}\end{quote} % Now the labels are on a white background. % \iffalse The same grid again but with labels on a white background. To achieve the white background you must re-define \verb:\setvlabel: and \verb:\sethlabel:; see the .tex file. \begin{center} \begin{picture}(309,165)(-109,-65) % \fi % \begin{quote}\begin{verbatim} \coordgrid*(-109,-65)(200,100) \coordsys(-109,-65)(200,100) % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} % \fi % % You can of course combine colour and the extra thin grid lines. % \begin{quote}\begin{verbatim} \gridstyle{\linethickness{0.24pt}\color{lightgray}} {\linethickness{0.24pt}\color{gray}} % \end{verbatim}\end{quote} % \iffalse A grid using two shades of very small gray dots by means of \begin{verbatim} \gridstyle{\linethickness{0.24pt}\color{lightgray}} {\linethickness{0.24pt}\color{gray}} \end{verbatim} \begin{center} \begin{picture}(309,165)(-109,-65) % \fi % Here is then a semi-logarithmic grid using two shades of small dots. The % labels are still on a white background---but you cannot see it as the labels % are on the outside. % \begin{quote}\begin{verbatim} \semiloggrid(-100,-65)(209,100) \semilogsys(-100,-65)(209,100) % \end{verbatim}\end{quote} % \iffalse \end{picture} \end{center} \end{document} % % \fi % % % \section{Installation} % As you must have figured, you must first extract the \url{.sty} files from % the \url{.dtx} file by running \url:coordsys.ins: through \LaTeX. % Then generate the documentation for the \textsf{coordsys} and % \textsf{logsys} packages % by running the file \url:coordsys.dtx: through % \LaTeX---thrice to resolve cross references.\footnote{If you want an index, % you must run MakeIndex % (\texttt{makeindex -s gind.ist coordsys}) between the second and third % \LaTeX{} run.} % % You now have to decide what to do with several files. % \begin{itemize} % \item Move the files \url:coordsys.sty: and \url:logsys.sty: to some % directory where \LaTeX\ can find it; % \url:(local)texmf/tex/latex/misc: would be % the natural choice. % \item Move the documentation, \url:coordsys.dvi:, to % \url:(local)texmf/doc/latex/misc:. % \item The files \url{ex-eepic.tex} and \url{ex-color.tex} provide examples % of how you may use the \textsf{coordsys} and \textsf{logsys} packages with % other packages. You must decide whether to keep or toss those files. % \item \LaTeX\ creates a number of \url{.put} files when processing the file % \url{ex-eepic.tex}. % You should keep those only if you keep % \url{ex-eepic.tex}. % \item You may discard the source files, \url:coordsys.dtx: and % \url:coordsys.ins:, or store them in % \url:(local)texmf/source/latex/misc:. % \end{itemize} % % % % \section{License}\label{sec:license} % This program may be distributed and/or modified under the % conditions of the \LaTeX\ Project Public License, either version 1.2 % of this license or (at your option) any later version. % The latest version of this license is in % \url;http://www.latex-project.org/lppl.txt; % and version 1.2 or later is part of all distributions of \LaTeX \ % version 1999/12/01 or later. % % This program consists of the files \url:coordsys.dtx: and % \url:coordsys.ins:. % % % \section{Acknowledgements} % Thank you to Scott Pakin % (\url{pakin@uiuc.edu}) for his input on the implementation of Euclid's % algorithm. % % Thank you to Svend Daugaard Pedersen % (\url{Svend@DaugaardPedersen.dk}) % for catching an error in the logarithmic systems % and for suggestions that led to % \verb:\gridstyle:. % % % \StopEventually{ % \PrintIndex % } % % \section{Implementation} % % \subsection{The \textsf{coordsys} Package} % \subsubsection{Identification} % First we must declare ourselves. % \begin{macrocode} %<*coordsys> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{coordsys}[2001/11/29 version 1.1] % \end{macrocode} % % \subsubsection{Declaration of Options} % \begin{macro}{\ticklength} % \begin{macro}{\vtickmark} % \begin{macro}{\htickmark} % The options define \verb:\ticklength:, \verb:vtickmark:, and % \verb:\htickmark:. First check that these three commands are not defined % elsewhere. % \begin{macrocode} \newcommand{\ticklength}{\relax} \newcommand{\vtickmark}{\relax} \newcommand{\htickmark}{\relax} % \end{macrocode} % The \verb:\vtickmark: and \verb:\htickmark: commands set the individual % ticks; \verb:\vtickmark: sets vertical ticks on a horizontal axis, % and \verb:\htickmark: sets horizontal ticks on a vertical axis. % \verb:\@wholewidth: is the current line width, % that is, the width of \verb:\thinlines: or \verb:\thicklines:. % \begin{macrocode} \DeclareOption{centred}{% \def\vtickmark{\makebox(0,0){\rule{\@wholewidth}{\ticklength}}}% \def\htickmark{\makebox(0,0){\rule{\ticklength}{\@wholewidth}}}% \def\ticklength{6\p@}% } \DeclareOption{outside}{% \def\vtickmark{\makebox(0,0)[t]{\rule{\@wholewidth}{\ticklength}}}% \def\htickmark{\makebox(0,0)[r]{\rule{\ticklength}{\@wholewidth}}}% \def\ticklength{3\p@}% } \DeclareOption{inside}{% \def\vtickmark{\makebox(0,0)[b]{\rule{\@wholewidth}{\ticklength}}}% \def\htickmark{\makebox(0,0)[l]{\rule{\ticklength}{\@wholewidth}}}% \def\ticklength{3\p@}% } % \end{macrocode} % \end{macro}\end{macro}\end{macro} % % \subsubsection{Execution of Options} % The default option is \textsf{centred}. % \begin{macrocode} \ExecuteOptions{centred} \ProcessOptions % \end{macrocode} % % \subsubsection{Main Code} % \begin{macro}{\vgridfromto} % \begin{macro}{\hgridfromto} % The \verb:\vgridfromto: and \verb:\hgridfromto: commands typeset vertical % and horizontal dotted lines for the dotted coordinate grids. % \begin{quote} % \verb:\vgridfromto:\marg{from}\marg{to}\\ % \verb:\hgridfromto:\marg{from}\marg{to} % \end{quote} % The dotted line is to run from ($y$- or $x$-coordinate) \meta{from} to ($y$- % or $x$-coordinate) \meta{to}. The two commands set the lines by means of % leaders in a box. The box is set at $y$- or $x$-coordinate zero and the % leaders extend to the right length by skipping back and forth. This way the % dots line up nicely in a predictable manner. When \verb:\vgridfromto: or % \verb:\hgridfromto: is called, \verb:\coordsys@w: should contain the size % (height or width) of the box containing each dot. % \begin{macrocode} \newcommand{\vgridfromto}[2]{% \vbox to \z@{\vskip -#2\unitlength \leaders\vbox to \coordsys@w{\vss\hbox{\picsquare}\vss} \vfill \vskip #1\unitlength}} \newcommand{\hgridfromto}[2]{% \hbox to \z@{\hskip #1\unitlength \leaders\hbox to \coordsys@w{\hss\picsquare\hss}\hfill \hskip-#2\unitlength}} % \end{macrocode} % \end{macro}\end{macro} % \begin{macro}{\vgridlength} % \begin{macro}{\hgridlength} % The \verb:\vgriglength: and \verb:\hgridlength: command typesets % solid vertical and horizontal lines. % \begin{quote} % \verb:\vgridlength:\marg{length}\\ % \verb:\hgridlength:\marg{length} % \end{quote} % The line is to have length \meta{length} and is set at the left-hand or % bottom edge of the coordinate system. % \begin{macrocode} \newcommand{\vgridlength}[1]{\line(0,1){#1}} \newcommand{\hgridlength}[1]{\line(1,0){#1}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\setvlabel} % \begin{macro}{\sethlabel} % The \verb:\setvlabel: and \verb:\sethlabel: commands typeset the labels on % the vertical and horizontal axes, respectively. % The \verb:\setvlabel: command sets 5\,pt of space between the label and the % axis, which is about right, considering that the tick marks extend 3\,pt on % either side of the axis. % The \verb:\sethlabel: command places the labels on a baseline 3\,pt plus % the current \verb:\baselineskip: below the axis by means of a strut (a % zero-width rule).\nextlinelabel{cl:setlabels} % \begin{macrocode} \newcommand{\setvlabel}[2][r]{% \makebox(0,0)[#1]{$#2$\hspace{5\p@}}} \newcommand{\sethlabel}[2][t]{% \makebox(0,0)[#1]{% \setlength{\@tempdimc}{3\p@}% \addtolength{\@tempdimc}{\baselineskip}% \rule{\z@}{\@tempdimc}$#2$}} % \end{macrocode} % You may want to redefine \verb:\setvlabel: and \verb:\sethlabel: to present % the labels in a different way---use a smaller font, increase the distance to % the axes,\dots). Your redefined commands must take one optional and one % mandatory argument---the \verb:\window: command uses the optional argument. % Do not assume that the mandatory argument is always a number---the % \verb:\window: command uses \verb:\setvlabel: and \verb:\sethlabel: to % typeset the min\slash max labels. % \end{macro}\end{macro} % % \begin{macro}{\hthickratio} % \begin{macro}{\vthickratio} % By default every fifth tick mark is thick. % \begin{macrocode} \newcommand{\hthickratio}{5} \newcommand{\vthickratio}{5} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\text} % Hopefully the \textsf{amstext} package will override this very simple % \verb:\text: command intended for subscripts only. % \begin{macrocode} \providecommand{\text}[1]{\mbox{\scriptsize #1}} % \end{macrocode} % \end{macro} % \begin{macro}{\picsquare} % The \verb:\picsquare: command typesets a square of size the current line % width---as in the \textsf{epic} package. % \begin{macrocode} \providecommand{\picsquare}{% \makebox(0,0){\rule{\@wholewidth}{\@wholewidth}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\count@} % \begin{macro}{\c@@coord} % \begin{macro}{\@tenpcnta} % \begin{macro}{\@tenpcntb} % \begin{macro}{\if@numbline} % We need three counters. \LaTeX\ inherits one, \verb:\count@:, from plain % \TeX\ and defines two more, \verb:\@tempcnta: and \verb:\@tempcntb:. % We create a \LaTeX\ counter, \verb:@coord:,\nextlinelabel{cl:@coord} without % allocating a new counter % by making \verb:\c@@coord: a synonym for \verb:\count@:\footnote{I don't % quite understand why I bother do that; I copied the idea from Lamport's % \textsf{graphpap} package, which is where the \textsf{coordsys} package % began.} % The \verb:\if: control whether to set labels. % \begin{macrocode} \let\c@@coord\count@ \newif\if@numbline % \end{macrocode} % \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} % % \begin{macro}{\tickstyle} % \begin{macro}{\thin@ticks} % \begin{macro}{\thick@ticks} % The commands \verb:\thin@ticks: and \verb:\thick@ticks: store the style of % the tick marks. The \verb:\tickstyle: command defines those two. The % default is \verb:\thinlines: for the thin tick marks and \verb:\thicklines: % for the thick tick marks. % \begin{macrocode} \newcommand{\tickstyle}[2]{% \def\thin@ticks{#1}% \def\thick@ticks{#2}} \tickstyle{\thinlines}{\thicklines} % \end{macrocode} % \end{macro}\end{macro}\end{macro} % % \begin{macro}{\@set@ticks} % The \verb:\@set@ticks: command calculates the positions of the % tick marks. % \begin{quote} % \verb:\@set@ticks:\marg{thickratio}\marg{spacing}% % \marg{from}\marg{to}\marg{cmd} % \end{quote} % \begin{macro}{\coordsys@a} % \begin{macro}{\coordsys@b} % \begin{macro}{\coordsys@c} % The \verb:\@set@ticks: command calculates three parameters: % \verb:\coordsys@a: is the position of the first tick; % \verb:\coordsys@b: is the number of ticks to set; and % \verb:\coordsys@c: is the spacing between the ticks (that is, % \meta{spacing} for the thin ticks and $\meta{thickratio}\meta{spacing}$ % for the thick ticks). % \end{macro}\end{macro}\end{macro} % Then \verb:\@set@ticks: calls \meta{cmd} to actually set the ticks using % these parameters.\nextlinelabel{cl:BeginTickCalc} % \begin{macrocode} \newcommand{\@set@ticks}[5]{% \thin@ticks \edef\coordsys@c{#2}% % \end{macrocode} % First we must round \meta{from} up to a multiple of \meta{spacing}. % Knuth's implementation of integer division % always rounds toward zero, % so for negative \meta{from} we can simply divide and multiply % by \meta{spacing}. If \meta{from} is positive, we must play around a % little to round up instead of down. % \begin{macrocode} \@tempcnta=#3\relax \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi \divide\@tempcnta \coordsys@c\relax \ifnum #3>0\advance\@tempcnta 1\relax\fi \multiply\@tempcnta \coordsys@c\relax \edef\coordsys@a{\the\@tempcnta}% % \end{macrocode} % Then we must calculate how many ticks to set. % If \meta{to} is larger than (or equal to) \verb:\@tempcnta:, % the position of the first tick, then we are done. % \begin{macrocode} \@tempcntb=#4\relax \ifnum\@tempcnta<\@tempcntb\relax % \end{macrocode} % Otherwise we could set % $\left\lfloor \frac{\meta{to}-\meta{from}}{\meta{spacing}} \right\rfloor + 1$ % ticks. However, the last tick could collide with the % arrow,\nextlinelabel{cl:collide} % so we'll set only % $\left\lfloor \frac{\meta{to}-\meta{from}}{\meta{spacing}} \right\rfloor$ % ticks. % \begin{macrocode} \advance\@tempcntb -\@tempcnta\relax \divide\@tempcntb \coordsys@c\relax \edef\coordsys@b{\the\@tempcntb}% % \end{macrocode} % Then put the ticks.\nextlinelabel{cl:EndTickCalc} % \begin{macrocode} #5% % \end{macrocode} % Then the thick ticks. % This time the spacing is $\meta{thickratio}\meta{spacing}$, so calculate % that number % and store it in \verb:\coordsys@c:. % \begin{macrocode} \thick@ticks \@tempcntb=#1\relax \multiply\@tempcntb \coordsys@c\relax \edef\coordsys@c{\the\@tempcntb}% % \end{macrocode} % Calculate the position of the first (thick) tick as above. % \begin{macrocode} \@tempcnta=#3\relax \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi \divide\@tempcnta \coordsys@c\relax \ifnum #3>0\advance\@tempcnta 1\relax\fi \multiply\@tempcnta \coordsys@c\relax \edef\coordsys@a{\the\@tempcnta}% % \end{macrocode} % Again, if the first tick is to the right of \meta{to}, we are done. % \begin{macrocode} \@tempcntb=#4\relax \ifnum\@tempcnta<\@tempcntb\relax % \end{macrocode} % Otherwise calculate the number of \emph{thin} ticks between % the first thick tick and \meta{to}. % \begin{macrocode} \advance\@tempcntb -\@tempcnta\relax \divide\@tempcntb #2\relax % \end{macrocode} % The number of thick ticks is then % $\left\lceil \frac{\meta{number of thin ticks}} % {\meta{thichratio}} \right\rceil$. % \begin{macrocode} \advance\@tempcntb -1\relax \divide\@tempcntb #1\relax \advance\@tempcntb 1\relax % \end{macrocode} % Store the result and set the ticks. % \begin{macrocode} \edef\coordsys@b{\the\@tempcntb}% #5% \fi \fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\numbline} % The \verb:\numbline: command checks for a star, % \begin{macrocode} \newcommand{\numbline}{% \@ifstar{\@numblinefalse\hnumbline@i} {\@numblinetrue \hnumbline@i}} % \end{macrocode} % \begin{macro}{\hnumbline@i} % then \verb:\hnumbline@i: picks up the optional argument, % \begin{macrocode} \newcommand{\hnumbline@i}[1][10]{\leavevmode\hnumbline@ii{#1}} % \end{macrocode} % \end{macro} % \begin{macro}{\hnumbline@ii} % and \verb:\hnumbline@ii: does the work: % Calculate the length of the arrow and set it, then call \verb:\@set@ticks: % to set the tick marks. The extra set of braces localizes the % \verb:\tickstyle: declarations. % \begin{macrocode} \newcommand{\hnumbline@ii}[3]{{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#2\relax \edef\coordsys@w{\the\@tempcnta}% \put(#2,0){\vector(1,0){\coordsys@w}}% \@set@ticks{\hthickratio}{#1}{#2}{#3}{ \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b\vtickmark}% % \end{macrocode} % Set the labels if we have to. % The parameters \verb:\coordsys@a:, \verb:\coordsys@b:, and % \verb:\coordsys@c: that \verb:\@set@ticks: calculated for the thick tick % marks are still available. In particular, \verb:\coordsys@a: is the % position and, hence, the value of the first label. % \begin{macrocode} \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b{% \sethlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}} \fi \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\vnumbline} % \begin{macro}{\vnumbline@i} % \begin{macro}{\vnumbline@ii} % The \verb:\vnumbline: command and friends work in much the same way. % \begin{macrocode} \newcommand{\vnumbline}{% \@ifstar{\@numblinefalse\vnumbline@i} {\@numblinetrue \vnumbline@i}} \newcommand{\vnumbline@i}[1][10]{\leavevmode\vnumbline@ii{#1}} \newcommand{\vnumbline@ii}[3]{{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(0,#2){\vector(0,1){\coordsys@h}}% \@set@ticks{\vthickratio}{#1}{#2}{#3}{% \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b{% \setvlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}} \fi \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro}\end{macro} % % \begin{macro}{\coordsys} % All the coordinate-system drawing command use similar syntax, so we use a % unified approach for picking up the arguments. % The \verb:\coordsys: command defines the temporary variable % \verb:\coordsys@c: to be the name of the command that does the real work. % Then \verb:\coordsys: checks for the presence of a star. % \begin{macrocode} \newcommand{\coordsys}{% \def\coordsys@c{\coordsys@i}% \@ifstar{\@numblinefalse\coordsys@args@i} {\@numblinetrue \coordsys@args@i}} % \end{macrocode} % \begin{macro}{\coordsys@args@i} % \begin{macro}{\@hticksep} % The \verb:\coordsys@args@i: command picks up the first optional argument % storing it % in \verb:\@hticksep: so that we can use that variable as the default for the % second optional argument. % \begin{macrocode} \newcommand{\coordsys@args@i}[1][10]{\leavevmode \def\@hticksep{#1}% \coordsys@args@ii} % \end{macrocode} % \end{macro}\end{macro} % \begin{macro}{\coordsys@args@ii} % \begin{macro}{\@vticksep} % Then \verb:\coordsys@args@ii: picks up the second optional argument, % \begin{macrocode} \newcommand{\coordsys@args@ii}[1][\@hticksep]{% \def\@vticksep{#1}% \coordsys@args@iii} % \end{macrocode} % \end{macro}\end{macro} % \begin{macro}{\coordsys@args@iii} % and the \verb:\coordsys@args@iii: command picks up the first point and % brutally % replaces whatever the following may be with a \verb:(:. Since \TeX\ ignores % spaces when looking for an argument, this allows the user to leave a space % between the first and the second point. % \begin{macrocode} \def\coordsys@args@iii(#1,#2)#3{\coordsys@c{#1}{#2}(} % \end{macrocode} % \end{macro} % \begin{macro}{\coordsys@i} % Finally the real command, \verb:\coordsys@c:, that is \verb:\coordsys@i:, % picks up the second point (as well as the first), and gets to work: % First calculate the length of each axis and set it. % \begin{macrocode} \def\coordsys@i#1#2(#3,#4){{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \put(#1,0){\vector(1,0){\coordsys@w}}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(0,#2){\vector(0,1){\coordsys@h}}% % \end{macrocode} % Then set the tick marks on the horizontal axis. % \begin{macrocode} \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b\vtickmark}% % \end{macrocode} % This style of coordinate system has intersecting axes, so we must suppress % the label ``0''. % \begin{macrocode} \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b{% \ifnum\value{@coord}=0\relax\else \sethlabel{\arabic{@coord}}% \fi \addtocounter{@coord}{\coordsys@c}}% \fi % \end{macrocode} % Then do the tick marks and labels on the vertical axis. % \begin{macrocode} \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b{% \ifnum\value{@coord}=0\relax\else \setvlabel{\arabic{@coord}}% \fi \addtocounter{@coord}{\coordsys@c}}% \fi \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\fcoordsys} % \begin{macro}{\fcoordsys@i} % The \verb:\fcoordsys: and \verb:\fcoordsys@i: commands work much like % \verb:\coordsys: and \verb:\coordsys@i: above. % \begin{macrocode} \newcommand{\fcoordsys}{% \def\coordsys@c{\fcoordsys@i}% \@ifstar{\@numblinefalse\coordsys@args@i} {\@numblinetrue \coordsys@args@i}} \def\fcoordsys@i#1#2(#3,#4){{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \put(#1,#2){\vector(1,0){\coordsys@w}}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(#1,#2){\vector(0,1){\coordsys@h}}% \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b\vtickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b{% \sethlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}}% \fi \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b{% \setvlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}}% \fi \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\bcoordsys} % \begin{macro}{\bcoordsys@i} % The \verb:\bcoordsys: and \verb:\bcoordsys@i: commands work much like % \verb:\coordsys: and \verb:\coordsys@i: above. % \begin{macrocode} \newcommand{\bcoordsys}{% \def\coordsys@c{\bcoordsys@i}% \@ifstar{\@numblinefalse\coordsys@args@i} {\@numblinetrue \coordsys@args@i}} \def\bcoordsys@i#1#2(#3,#4){{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \put(#1,#2){\line(1,0){\coordsys@w}}% \put(#1,#4){\line(1,0){\coordsys@w}}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(#1,#2){\line(0,1){\coordsys@h}}% \put(#3,#2){\line(0,1){\coordsys@h}}% \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b\vtickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b{% \sethlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}}% \fi \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b{% \setvlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}}% \fi \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\window} % \begin{macro}{\window@i} % And yet another modification of the same old thing. % \begin{macrocode} \newcommand{\window}{% \def\coordsys@c{\window@i}% \@ifstar{\let\coordsys@a\phantom\coordsys@args@i} {\let\coordsys@a\relax \coordsys@args@i}} \def\window@i#1#2(#3,#4){{% \thinlines \@tempcnta=#3\relax \advance\@tempcnta-#1\relax \edef\coordsys@w{\the\@tempcnta}% \@tempcnta=#4\relax \advance\@tempcnta-#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(#1,#2){\line(1,0){\coordsys@w}}% \put(#1,#2){\line(0,1){\coordsys@h}}% \put(#3,#4){\line(-1,0){\coordsys@w}}% \put(#3,#4){\line(0,-1){\coordsys@h}}% % \end{macrocode} % Set the labels; \verb:\ensuremath: for the sake of the % subscripts. % \begin{macrocode} \put(#1,#2){\sethlabel[tl]% {\ensuremath{x_{\text{min}}=\coordsys@a{#1}}}}% \put(#3,#2){\sethlabel[tr]% {\ensuremath{x_{\text{max}}=\coordsys@a{#3}}}}% \put(#1,#2){\setvlabel[rb]% {\ensuremath{y_{\text{min}}=\coordsys@a{#2}}}}% \put(#1,#4){\setvlabel[rt]% {\ensuremath{y_{\text{max}}=\coordsys@a{#4}}}}% % \end{macrocode} % If the axes are in the window, typeset them (without labels). % \begin{macrocode} \ifnum #1<0\relax\ifnum #3>0\relax \vnumbline*[\@vticksep]{#2}{#4}% \fi\fi \ifnum #2<0\relax\ifnum #4>0\relax \numbline*[\@hticksep]{#1}{#3}% \fi\fi }} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\gridstyle} % \begin{macro}{\grid@style} % The \verb:\gridstyle: command defines \verb:\grid@style: to issue a suitable % \verb:\tickstyle: command at the proper time. The default % \verb:\grid@style: is to do nothing---that is, use the current % \verb:\tickstyle: unchanged. % \begin{macrocode} \newcommand{\gridstyle}[2]{\def\grid@style{\tickstyle{#1}{#2}}} \newcommand{\grid@style}{\relax} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\coordgrid} % The \verb:\coordgrid: command chooses between the starred version, % \verb:\coordgrid@ii:, with solid lines and the un-starred version, % \verb:\coordgrid@i:, with dotted lines. % \begin{macrocode} \newcommand{\coordgrid}{% \@ifstar{\def\coordsys@c{\coordgrid@ii}\coordsys@args@i} {\def\coordsys@c{\coordgrid@i}\coordsys@args@i}} % \end{macrocode} % \begin{macro}{\coordgrid@i} % The \verb:\coordgrid@i: command calls \verb:\coordgrid@calc: to calculate % the size, \verb:\coordsys@w:, of the box containing each dot of the dotted % lines based on the values of \verb:\@hticksep: and \verb:\@vticksep:. Then % set the dotted lines with \verb:\@set@ticks:. % \begin{macrocode} \def\coordgrid@i#1#2(#3,#4){{\color@begingroup \coordgrid@calc \grid@style \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b {\vgridfromto{#2}{#4}}}% \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b {\hgridfromto{#1}{#3}}}% \color@endgroup}} % \end{macrocode} % \end{macro} % \begin{macro}{\coordgrid@ii} % The \verb:\coordgrid@ii: command is similar to \verb:\fcoordsys@i: above. % \begin{macrocode} \def\coordgrid@ii#1#2(#3,#4){{\color@begingroup \grid@style \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b {\vgridlength{\coordsys@h}}}% \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b {\hgridlength{\coordsys@w}}}% \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\coordgrid@calc} % To typeset pretty grids of dots the number of dots between lines must be an % integer. Thus, the number of dots must be a factor of the greatest common % divisor of \verb:\@vticksep: and \verb:\@hticksep:. The \verb:\@EuclidGCD: % command returns the $\gcd$ in the counter \verb:\@tempcnta: % \begin{macrocode} \newcommand{\coordgrid@calc}{% \@EuclidGCD{\@vticksep}{\@hticksep}% \@tempdima=\unitlength \multiply\@tempdima\@tempcnta % \end{macrocode} % Now \verb:\@tempdima: is the longest length that fits an integer number of % times between lines. The dots should not be closer than 2\,pt. % \begin{macrocode} \@tempdimb=2\p@\relax \ifdim\@tempdima<\@tempdimb \PackageWarning{coordsys}{The tick marks are too close\MessageBreak for a pretty grid}% \else % \end{macrocode} % However, \verb:\@tempdima: may be able to contain multiple dots. % \begin{macrocode} \divide\@tempdima \@tempdimb\relax \@tempdimb=\unitlength \multiply\@tempdimb\@tempcnta \divide\@tempdimb\@tempdima \fi % \end{macrocode} % In either case store the box size in \verb:\coordsys@w:. % \begin{macrocode} \edef\coordsys@w{\the\@tempdimb}% } % % \end{macrocode} % \end{macro} % % \iffalse Don't document this fragment of code. % \begin{macrocode} %<*euclid> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{euclidgcd}[2001/11/29 version 1.1] \newcommand{\EuclidGCD}[2]{% \@EuclidGCD{#1}{#2}% \the\@tempcnta} % % \end{macrocode} % \fi % % \begin{macro}{\@EuclidGCD} % The \verb:\@EuclidGCD: command calculates the greatest common divisor % of two positive integers using Euclid's algorithm.\footnote{Euclid's % algorithm uses the fact that $\gcd(n, d) = \gcd(d, r)$, where $r$ is % the remainder after dividing $n$ by $d$. Since $r \newcommand{\@EuclidGCD}[2]{% \@tempcnta=#1\relax \@tempcntb=#2\relax \loop \count@=\@tempcntb \divide\count@\@tempcnta \multiply\count@\@tempcnta \advance\count@ -\@tempcntb % \end{macrocode} % Now \verb:\count@: is $-r$, where $r$ is the remainder after dividing % \verb:\@tempcntb: by \verb:\@tempcnta:. % \begin{macrocode} \ifnum\count@<0\relax \@tempcntb=\@tempcnta \@tempcnta=-\count@ \repeat } % % \end{macrocode} % \end{macro} % % % \subsection{The \textsf{logsys} Package} % \subsubsection{Identification} % First we must declare ourselves. % \begin{macrocode} %<*logsys> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{logsys}[2001/11/29 version 1.1] % \end{macrocode} % % \subsubsection{Options} % Pass all options to \textsf{coordsys}. % \begin{macrocode} \DeclareOption{centred}{\PassOptionsToPackage{centred}{coordsys}} \DeclareOption{outside}{\PassOptionsToPackage{outside}{coordsys}} \DeclareOption{inside}{\PassOptionsToPackage{inside}{coordsys}} \ProcessOptions % \end{macrocode} % % \subsubsection{Package Loading} % The \textsf{logsys} package extends the \textsf{coordsys} package. % \begin{macrocode} \RequirePackage{coordsys}[2001/11/29] % \end{macrocode} % % \subsubsection{Main Code} % \begin{macro}{\loglabel} % The \verb:\loglabel: command typesets logarithmic labels. % \begin{macrocode} \newcommand{\loglabel}[1]{% \ifnum #1=-2\relax \frac{1}{100}% \else\ifnum #1=-1\relax \frac{1}{10}% \else\ifnum #1= 0\relax 1% \else\ifnum #1= 1\relax 10% \else\ifnum #1= 2\relax 100% \else 10^{#1}% \fi\fi\fi\fi\fi} % \end{macrocode} % \end{macro} % % \begin{macro}{\v@logbox} % \begin{macro}{\h@logbox} % The \verb:\v@logbox: and \verb:\h@logbox: commands each typeset one block % of logarithmic tick marks. Each take two arguments: the size of a block and % the tick mark to typeset. % The glue in the boxes is (10000 times) $\log10-\log9$, $\log9-\log8$, % $\log8-\log7$, \dots, and $\log2-\log1$. % \begin{macrocode} \newcommand{\v@logbox}[2]{% \vbox to #1\unitlength{% \offinterlineskip \vskip \z@ plus 458fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 9 \vskip \z@ plus 512fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 8 \vskip \z@ plus 580fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 7 \vskip \z@ plus 669fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 6 \vskip \z@ plus 792fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 5 \vskip \z@ plus 969fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 4 \vskip \z@ plus 1249fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 3 \vskip \z@ plus 1761fil\relax \vbox to \z@{\vss\hbox{#2}\vss}% 2 \vskip \z@ plus 3010fil\relax }} \newcommand{\h@logbox}[2]{% \hbox to #1\unitlength{% \hskip \z@ plus 3010fill\relax \hbox to \z@{\hss #2\hss}% 2 \hskip \z@ plus 1761fill\relax \hbox to \z@{\hss #2\hss}% 3 \hskip \z@ plus 1249fill\relax \hbox to \z@{\hss #2\hss}% 4 \hskip \z@ plus 969fill\relax \hbox to \z@{\hss #2\hss}% 5 \hskip \z@ plus 792fill\relax \hbox to \z@{\hss #2\hss}% 6 \hskip \z@ plus 669fill\relax \hbox to \z@{\hss #2\hss}% 7 \hskip \z@ plus 580fill\relax \hbox to \z@{\hss #2\hss}% 8 \hskip \z@ plus 512fill\relax \hbox to \z@{\hss #2\hss}% 9 \hskip \z@ plus 458fill\relax }} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\@sethlogticks} % In the linear case we got away with using one command, \verb:\@set@ticks:, % to calculate the positions of the tick marks on both horizontal and vertical % axes. The logarithmic case is more complicated, so we create separate % command for the horizontal and vertical case. This split then allows the % logarithmic commands to do more than just calculate the positions of the % ticks: % \begin{quote} % \verb:\@sethlogticks:\marg{spacing}\marg{from}\marg{to}^^A % \marg{y0}\marg{tick} % \end{quote} % \emph{typesets} the logarithmic tick marks on a horizontal axis at % $y$-coordinate \meta{y0}. Moreover, it typesets the labels. % % The calculation is much like the calculation for thin tick marks in the % linear case; compare with code % lines~\ref{cl:BeginTickCalc}--\ref{cl:EndTickCalc}. % \begin{macrocode} \newcommand{\@sethlogticks}[5]{% \thin@ticks \@tempcnta=#2\relax \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi \divide\@tempcnta #1\relax \ifnum #2>0\advance\@tempcnta 1\relax\fi \multiply\@tempcnta #1\relax \edef\coordsys@a{\the\@tempcnta}% \@tempcntb=#3\relax \ifnum\@tempcnta<\@tempcntb\relax \advance\@tempcntb -\@tempcnta\relax \divide\@tempcntb #1\relax \edef\coordsys@b{\the\@tempcntb}% \multiput(\coordsys@a,#4)(#1,0)\coordsys@b {\h@logbox{#1}{#5}}% % \end{macrocode} % In the linear case we took some measure against colliding tick marks and % arrow heads (see the commentary preceding code line~\ref{cl:collide}); in % the logarithmic case we leave that worry to the user\footnote{Because % calculating the position of individual logarithmic tick mark is difficult; % this code works by setting blocks of tick marks.}. Therefore we can (and % should) set one more thick tick mark than we have blocks. % \begin{macrocode} \thick@ticks \@tempcntb=\coordsys@b\relax \advance\@tempcntb 1\relax \edef\coordsys@b{\the\@tempcntb}% \multiput(\coordsys@a,#4)(#1,0)\coordsys@b {#5}% % \end{macrocode} % Then set the labels: First set the counter \verb:@coord: to\footnote{The % calculation uses a horrible mixture of \LaTeX\ syntax and plain \TeX\ since % \LaTeX\ does not provide a division command. Maybe I should avoid the % \LaTeX\ style counter and just use plain \TeX. See the note to code % line~\ref{cl:@coord}.} % $\frac{\meta{from}}{\meta{spacing}}$, then step that counter by one. % \begin{macrocode} \if@numbline \setcounter{@coord}{\coordsys@a}% \divide\c@@coord #1\relax \multiput(\coordsys@a,#4)(#1,0)\coordsys@b{% \sethlabel{\loglabel{\arabic{@coord}}}% \stepcounter{@coord}}% \fi \fi } % \end{macrocode} % \end{macro} % \begin{macro}{\@setvlogticks} % The vertical version works in much the same way. % \begin{macrocode} \newcommand{\@setvlogticks}[5]{% \thin@ticks \@tempcnta=#2\relax \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi \divide\@tempcnta #1\relax \ifnum #2>0\advance\@tempcnta 1\relax\fi \multiply\@tempcnta #1\relax \edef\coordsys@a{\the\@tempcnta}% \@tempcntb=#3\relax \ifnum\@tempcnta<\@tempcntb\relax \advance\@tempcntb -\@tempcnta\relax \divide\@tempcntb #1\relax \edef\coordsys@b{\the\@tempcntb}% \multiput(#4,\coordsys@a)(0,#1)\coordsys@b {\v@logbox{#1}{#5}}% \thick@ticks \@tempcntb=\coordsys@b\relax \advance\@tempcntb 1\relax \edef\coordsys@b{\the\@tempcntb}% \multiput(#4,\coordsys@a)(0,#1)\coordsys@b {#5}% \if@numbline \setcounter{@coord}{\coordsys@a}% \divide\c@@coord #1\relax \multiput(#4,\coordsys@a)(0,#1)\coordsys@b{% \setvlabel{\loglabel{\arabic{@coord}}}% \stepcounter{@coord}}% \fi \fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\logline} % The \verb:\logline: command checks for a star, % \begin{macrocode} \newcommand{\logline}{% \@ifstar{\@numblinefalse\hlogline@i} {\@numblinetrue \hlogline@i}} % \end{macrocode} % \begin{macro}{\hlogline@i} % then \verb:\hlogline@i: picks up the optional argument, % \begin{macrocode} \newcommand{\hlogline@i}[1][50]{\leavevmode\hlogline@ii{#1}} % \end{macrocode} % \begin{macro}{\hlogline@ii} % and \verb:\hlogline@ii: does the work---which isn't much since % \verb:\@sethlogticks: does almost everything. % \begin{macrocode} \newcommand{\hlogline@ii}[3]{{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#2\relax \edef\coordsys@w{\the\@tempcnta}% \put(#2,0){\vector(1,0){\coordsys@w}}% \@sethlogticks{#1}{#2}{#3}{0}{\vtickmark} \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro}\end{macro} % % \begin{macro}{\vlogline} % \begin{macro}{\vlogline@i} % \begin{macro}{\vlogline@ii} % The \verb:\vlogline: command and friends work in much the same way. % \begin{macrocode} \newcommand{\vlogline}{% \@ifstar{\@numblinefalse\vlogline@i} {\@numblinetrue \vlogline@i}} \newcommand{\vlogline@i}[1][50]{\leavevmode\vlogline@ii{#1}} \newcommand{\vlogline@ii}[3]{{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(0,#2){\vector(0,1){\coordsys@h}}% \@setvlogticks{#1}{#2}{#3}{0}{\htickmark} \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro}\end{macro} % % \begin{macro}{\logsys} % The logarithmic coordinate system commands have different default values for % the optional arguments than their linear cousins. We therefore need a new % approach for picking up optional arguments. % % The \verb:\logsys: command defines \verb:\coordsys@c: to be the command that % eventually sets the coordinate system. Then \verb:\logsys: define % \verb:\@hticksep: and \verb:\@vticksep: to be the default values for the % optional arguments. (Each logarithmic coordinate system type has a different % set of default values.) Then \verb:\logsys: checks for a star and calls % \verb:\logsys@args@i:. % \begin{macrocode} \newcommand{\logsys}{% \def\coordsys@c{\logsys@i}% \def\@hticksep{10}% \def\@vticksep{50}% \@ifstar{\@numblinefalse\logsys@args@i} {\@numblinetrue \logsys@args@i}} % \end{macrocode} % \begin{macro}{\logsys@args@i} % The \verb:\logsys@args@i: command picks up the first optional argument % storing it in \verb:\@hticksep: for later processing. % \begin{macrocode} \newcommand{\logsys@args@i}[1][\@hticksep]{\leavevmode \edef\@hticksep{#1}% \logsys@args@ii} % \end{macrocode} % \end{macro} % \begin{macro}{\logsys@args@ii} % Then \verb:\logsys@args@ii: picks up the second optional argument and calls % the good old \verb:\coordsys@args@iii: command to pick up (some of) the % remaining arguments. % \begin{macrocode} \newcommand{\logsys@args@ii}[1][\@vticksep]{% \edef\@vticksep{#1}% \coordsys@args@iii} % \end{macrocode} % \end{macro} % \begin{macro}{\logsys@i} % Finally \verb:\logsys@i: sets the coordinate system: % First calculate the width and height of the system, then set the axes % and the tick marks and labels on the linear (horizontal) axis---all of it % much like \verb:\fcoordsys@i: above. % \begin{macrocode} \def\logsys@i#1#2(#3,#4){{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \put(#1,#2){\vector(1,0){\coordsys@w}}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(#1,#2){\vector(0,1){\coordsys@h}}% \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b\vtickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b{% \sethlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}}% \fi % \end{macrocode} % Finally call \verb:\@setvlogticks: to set the tick marks and labels on the % logarithmic (vertical) axis. % \begin{macrocode} \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\htickmark}% \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\semilogsys} % \begin{macro}{\semilogsys@i} % The \verb:\semilogsys: and \verb:\semilogsys@i: commands work in much the % same manner. % \begin{macrocode} \newcommand{\semilogsys}{% \def\coordsys@c{\semilogsys@i}% \def\@hticksep{50}% \def\@vticksep{10}% \@ifstar{\@numblinefalse\logsys@args@i} {\@numblinetrue \logsys@args@i}} \def\semilogsys@i#1#2(#3,#4){{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \put(#1,#2){\vector(1,0){\coordsys@w}}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(#1,#2){\vector(0,1){\coordsys@h}}% \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vtickmark}% \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}% \if@numbline \setcounter{@coord}{\coordsys@a}% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b{% \setvlabel{\arabic{@coord}}% \addtocounter{@coord}{\coordsys@c}}% \fi \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\loglogsys} % \begin{macro}{\loglogsys@i} % The \verb:\loglogsys: and \verb:\loglogsys@i: commands work in much the % same manner. % \begin{macrocode} \newcommand{\loglogsys}{% \def\coordsys@c{\loglogsys@i}% \def\@hticksep{50}% \def\@vticksep{50}% \@ifstar{\@numblinefalse\logsys@args@i} {\@numblinetrue \logsys@args@i}} \def\loglogsys@i#1#2(#3,#4){{\color@begingroup \thinlines \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \put(#1,#2){\vector(1,0){\coordsys@w}}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \put(#1,#2){\vector(0,1){\coordsys@h}}% \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vtickmark}% \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\htickmark}% \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\loggrid} % The \verb:\loggrid: command is the obvious cross between \verb:\logsys: and % \verb:\coordgrid:. % \begin{macrocode} \newcommand{\loggrid}{% \def\@hticksep{10}% \def\@vticksep{50}% \@numblinefalse \@ifstar{\def\coordsys@c{\loggrid@ii}\logsys@args@i} {\def\coordsys@c{\loggrid@i}\logsys@args@i}} % \end{macrocode} % \begin{macro}{\loggrid@i} % Similarly, \verb:\loggrid@i: is a cross between \verb:\logsys@i: and % \verb:\coordgrid@i:, % \begin{macrocode} \def\loggrid@i#1#2(#3,#4){{\color@begingroup \coordgrid@calc \grid@style \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b {\vgridfromto{#2}{#4}}}% \@setvlogticks{\@vticksep}{#2}{#4}{0}{\hgridfromto{#1}{#3}}% \color@endgroup}} % \end{macrocode} % \end{macro} % \begin{macro}{\loggrid@ii} % and \verb:\loggrid@ii: is a cross between \verb:\logsys@i: and % \verb:\coordgrid@ii:. % \begin{macrocode} \def\loggrid@ii#1#2(#3,#4){{\color@begingroup \grid@style \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{% \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b {\vgridlength{\coordsys@h}}}% \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\hgridlength{\coordsys@w}}% \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\semiloggrid} % \begin{macro}{\semiloggrid@i} % \begin{macro}{\semiloggrid@ii} % Semi-logarithmic grids provide no surprises, % \begin{macrocode} \newcommand{\semiloggrid}{% \def\@hticksep{50}% \def\@vticksep{10}% \@numblinefalse \@ifstar{\def\coordsys@c{\semiloggrid@ii}\logsys@args@i} {\def\coordsys@c{\semiloggrid@i}\logsys@args@i}} \def\semiloggrid@i#1#2(#3,#4){{\color@begingroup \coordgrid@calc \grid@style \@sethlogticks{\@hticksep}{#1}{#3}{0}{\vgridfromto{#2}{#4}}% \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b {\hgridfromto{#1}{#3}}}% \color@endgroup}} \def\semiloggrid@ii#1#2(#3,#4){{\color@begingroup \grid@style \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vgridlength{\coordsys@h}}% \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{% \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b {\hgridlength{\coordsys@w}}}% \color@endgroup}} % \end{macrocode} % \end{macro}\end{macro}\end{macro} % \begin{macro}{\logloggrid} % \begin{macro}{\logloggrid@i} % \begin{macro}{\logloggrid@ii} % and nor do double-logarithmic grids. % \begin{macrocode} \newcommand{\logloggrid}{% \def\@hticksep{50}% \def\@vticksep{50}% \@numblinefalse \@ifstar{\def\coordsys@c{\logloggrid@ii}\logsys@args@i} {\def\coordsys@c{\logloggrid@i}\logsys@args@i}} \def\logloggrid@i#1#2(#3,#4){{\color@begingroup \coordgrid@calc \grid@style \@sethlogticks{\@hticksep}{#1}{#3}{0}{\vgridfromto{#2}{#4}}% \@setvlogticks{\@vticksep}{#2}{#4}{0}{\hgridfromto{#1}{#3}}% \color@endgroup}} \def\logloggrid@ii#1#2(#3,#4){{\color@begingroup \grid@style \@tempcnta=#3\relax \advance\@tempcnta -#1\relax \edef\coordsys@w{\the\@tempcnta}% \@tempcnta=#4\relax \advance\@tempcnta -#2\relax \edef\coordsys@h{\the\@tempcnta}% \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vgridlength{\coordsys@h}}% \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\hgridlength{\coordsys@w}}% \color@endgroup}} % % \end{macrocode} % \end{macro}\end{macro}\end{macro} % % % \subsection{The \texttt{putfile} Maple Code} % As the version number below indicates, the implementation of \verb:putfile: % is stalled work in progress. % \begin{macrocode} %<*putfile> putfile := proc(fn::{string, list(string), set(string)}, P::PLOT(anything) ) option `Copyright 2000-01 by Mogens Lemvig Hansen`; description "version 0.2"; local L, fns, i, V, scl; % \end{macrocode} % Process options. The scale must be \verb:evalf:able. % \begin{macrocode} L := [args[3..-1]]; if hasoption(L, 'scale', scl, 'L') then scl := evalf(scl); if not type(scl, [numeric, numeric]) then ERROR("the scale option must be [numeric, numeric] but got", scl); fi; else scl := [1,1]; fi; if L <> [] then ERROR("unknown options", op(L)); fi; % \end{macrocode} % Ensure that we have a list (or set) of filenames. % \begin{macrocode} if type(fn, 'string') then fns := [fn]; else fns := fn; fi; % \end{macrocode} % We are interested in two of the possible types of objects in the \verb:PLOT: % structure, \verb:P:: curves and \verb:VIEW(:\dots\verb:): options. First % deal with the curves. % \begin{macrocode} L := map( `putfile/grabcurves`, [op(P)] ); if nops(fns) <> nops(L) then ERROR("the number of filenames must match the number of curves", sprintf("received %d names but %d curves", nops(fns), nops(L) ) ); fi; % \end{macrocode} % Then the \verb:VIEW(:\dots\verb:): option (if present). The value % \verb:DEFAULT: indicates (to Maple) that there is no restriction on the % coordinate in question. % \begin{macrocode} V := select(type, [op(P)], 'VIEW'(anything, anything)); if nops(V) <> 1 then V := ['DEFAULT', 'DEFAULT']; else V := [ op([1,1], V), op([1,2], V) ]; fi; % \end{macrocode} % For each curve in \verb:L:, remove the bad points and scale. % \begin{macrocode} for i from 1 to nops(L) do L[i] := remove(`putfile/isbad`, L[i], V); L[i] := map(u->[scl[1]*u[1], scl[2]*u[2]], L[i]); od; % \end{macrocode} % Use \verb:writedata:\nextlinelabel[2]{cl:writedata} to write things to % files.\footnote{The use of \texttt{writedata} is a source of trouble as it % uses the \texttt{\%g} format symbol to write floating point numbers; % \texttt{\%g} writes large or small numbers in scientific notation which % \LaTeX\ in turn chokes on. I was too lazy to write my own version of % \texttt{writedata}.} % \begin{macrocode} for i from 1 to nops(L) do writedata(fns[i], L[i]); od; end; % \end{macrocode} % % The sub-routines that follow use Maple's naming convention for such. % % We are interested in \verb:CURVES: objects in a \verb:PLOT: structure. % A \verb:CURVES: object contains options (which we ignore) and lists of % \meta{curve}s, where a \meta{curve} is a list of \meta{point}s and a % \meta{point} is a list of length two usually containing two numeric values. % If \verb:x: is not a \verb:CURVES:, return nothing. If \verb:x: is a % \verb:CURVES:, extract the list of \meta{curve}s and return the % corresponding sequence of \meta{curve}s. If the \verb:PLOT: structure % contains more than one \verb:CURVES: object, the sequences returned by % \verb:putfile/grabcurves: will flatten to one sequence of \meta{curve}s % \begin{macrocode} `putfile/grabcurves` := proc(x) option `Copyright 2000-01 by Mogens Lemvig Hansen`; description "version 0.2"; local L; if op(0, x) = 'CURVES' then L := [ op(x) ]; L := select(type, L, 'list'); RETURN(op(L)); else RETURN(NULL); fi; end; % \end{macrocode} % % A \meta{point} is a list of two usually numeric values; one or both of the % values could be \verb:FAIL:. A point is bad if it contains a \verb:FAIL: or % if it is outside the view window. % \begin{macrocode} `putfile/isbad` := proc(pt::list, view::list) option `Copyright 2000-01 by Mogens Lemvig Hansen`; description "version 0.2"; if not type(pt, [numeric, numeric]) then RETURN(true) fi; if type(view[1], numeric..numeric) and ( op([1,1], view) > pt[1] or pt[1] > op([1,2], view) ) then RETURN(true); fi; if type(view[2], numeric..numeric) and ( op([2,1], view) > pt[2] or pt[2] > op([2,2], view) ) then RETURN(true); fi; false; end; % % \end{macrocode} % % \Finale %