From 46df998faf6dbae625217831671052e3987591db Mon Sep 17 00:00:00 2001 From: Ralf Hemmecke Date: Tue, 18 Jun 2024 22:00:33 +0200 Subject: [PATCH] generate book.pdf with postscript files --- src/doc/Makefile.in | 76 +++++++++++-------- src/doc/fricas.sty | 2 - src/doc/ht/util.ht | 1 - src/doc/htex/SEGBIND.htex | 9 +-- src/doc/htex/ug00.htex | 2 +- src/doc/htex/ug01.htex | 6 +- src/doc/htex/ug07.htex | 151 ++++++++++++++------------------------ src/doc/htex/ug08.htex | 14 ++-- src/doc/htex/ug10.htex | 28 +++---- src/doc/htex/ug11.htex | 2 +- src/doc/htex2input.awk | 74 ++++++++++++------- src/doc/skip-graphics.awk | 6 -- src/doc/spool2tex.awk | 6 -- src/input/knot3.input | 9 +++ src/input/ug-pics.input | 43 ----------- 15 files changed, 183 insertions(+), 246 deletions(-) delete mode 100644 src/doc/skip-graphics.awk create mode 100644 src/input/knot3.input delete mode 100644 src/input/ug-pics.input diff --git a/src/doc/Makefile.in b/src/doc/Makefile.in index b01d2a81f..9f63961d7 100644 --- a/src/doc/Makefile.in +++ b/src/doc/Makefile.in @@ -1,11 +1,12 @@ #------------------------------------------------------------------ #--- #--- FriCAS -#--- Copyright (C) 2013, 2014, 2020 Ralf Hemmecke +#--- Copyright (C) 2013, 2014, 2020, 2024 Ralf Hemmecke +#--- Copyright (C) 2024 Qian Yun #--- #------------------------------------------------------------------ # The main targets of this Makefile are "all" and "doc". -# Other useful targets are "localdoc", "book.pdf", "stamp-html". +# Other useful targets are "localdoc", "book.pdf", "stamp-html", "viewports". # Whereas "all" is made during normal FriCAS build, "doc" must be # invoked separately. @@ -46,7 +47,7 @@ # # "make book.pdf" does the following: # - Copy pictures from the ps/ directory for (documentation of HyperDoc). -# - Copy pictures from tmp/*.VIEW/image.ps (target stamp-pics). +# - Copy pictures from tmp/*.VIEW/image.ps (target stamp-book-viewports). # - Generate tmo/ug09.tex with the list of examples. # - Create tmp/*.input from htex/*.htex (target ${HTEX_FILES_INPUT}). # The .input files contain the commands that should be executed. @@ -56,6 +57,10 @@ # tmp/*.spool files (target ${HTEX_FILES_SPOOL}). # - Turn the tmp/*.spool files into tmp/*.tex files (target ${HTEX_FILES_TEX}). # - Create tmp/info.tex with version information. +# - Create tmp/vp-*.input files by prepending ")assert CreateGraphics" +# to tmp/*.input files for .htex files that contain \spadgraph commands. +# - Run the tmp/vp-input files through fricas (target ${HTEX_VIEWPORTS_STAMP}) +# in order to produce the postscript pictures for the book. # - LaTeX book.tex, call makeindex, and re-latex to get references right. # - Convert book.dvi to book.ps. # - Convert book.ps to book.pdf. @@ -252,11 +257,16 @@ GEN_HTFILES = xmpexp coverex gloss # The reason for this delayed execution is that generation of the .xpm # files in *.VIEW/ without the xvfb-run program will pop up image # windows in X and will make working during compilation impossible. -VIEWPORTFILES = coverex \ - $(shell grep -lRe 'graphpaste{\|spadgraph{' ${srcdir}/ht/* ${srcdir}/htex/* \ +HT_VIEWPORTFILES = coverex \ + $(shell grep -lRe '^\\graphpaste{' ${srcdir}/ht/* \ | sed 's,.*/,,;s,\..*,,' \ - | grep -v util \ - | sort) + | sort -u) +# HTEX_VIEWPORTFILES is also used in stamp-book-viewports. +HTEX_VIEWPORTFILES = \ + $(shell grep -lRe '^\\spadgraph{' ${srcdir}/htex/* \ + | sed 's,.*/,,;s,\..*,,' \ + | sort -u) +VIEWPORTFILES = ${HT_VIEWPORTFILES} ${HTEX_VIEWPORTFILES} # This should give # VIEWPORTFILES = coverex explot2d explot3d graphics SEGBIND \ # ug00 ug01 ug07 ug08 ug10 ug11 @@ -267,11 +277,8 @@ VIEWPORTFILES = coverex \ # that do contain "paste" commands, i.e., for which .pht files must be # generated. HT_PASTEFILES = \ - $(shell grep -R '\\\(graph\|spad\)paste{' ${srcdir}/ht/*.ht \ - | sed 's/%.*//' \ - | grep 'paste{' \ - | sed 's,.*/ht/,,;s,\.ht:.*,,' \ - | grep -v util \ + $(shell grep -lRe '^\\\(graph\|spad\)paste{' ${srcdir}/ht/*.ht \ + | sed 's,.*/,,;s,\..*,,' \ | sort -u) # This should give # HT_PASTEFILES = exdiff exint exlap exlimit exmatrix explot2d explot3d \ @@ -282,10 +289,8 @@ HT_PASTEFILES = \ # and \graphpaste, respectively, in the .ht file during generation via # ht.awk. HTEX_PASTEFILES = \ - $(shell grep -R '\\spad\(command\|graph\){' ${srcdir}/htex/*.htex \ - | sed 's/%.*//' \ - | grep '\\spad\(command\|graph\){' \ - | sed 's,.*/htex/,,;s,\.htex:.*,,' \ + $(shell grep -lRe '^\\spad\(command\|graph\){' ${srcdir}/htex/*.htex \ + | sed 's,.*/,,;s,\..*,,' \ | sort -u) ################################################################### @@ -294,8 +299,12 @@ HTEX_PASTEFILES = \ # HyperDoc and book.pdf. # The list can be generated by the following command. # grep -R '\\spadcommand{)read' *| sed 's/[^ ]* //;s/[ \].*//'|sort -u +# Additionally there are ntube, tknot, images1, and knot3 that +# generate more .ps files for their use in the book. +# All these files are going to be generated from the sources in the +# .htex files in a future release of FriCAS. INPUT_EXTRA = arrows bouquet newton ribbon vectors \ - ntube tknot images1 ug-pics + ntube tknot images1 knot3 ################################################################### # For these files .ht files will be generated. @@ -507,7 +516,7 @@ mobius.VIEW: ${inputsrcdir}/mobius.input # is set. This is supposed to be done through configure.ac. # The copy command should actually appear during the "copy-to-target" # below, but it would needlessly complicate this Makefile. -viewports: ${GEN_VIEWPORTFILES_PHT} mobius.VIEW +viewports: ${GEN_VIEWPORTFILES_PHT} mobius.VIEW stamp-book-viewports ${MKDIR_P} ${viewportstargetdir} cp -r *.VIEW ${viewportstargetdir} ${STAMP} $@ @@ -627,7 +636,7 @@ HTEX_FILES = $(HTEX_UGCHAPTERS) $(HTEX_EXAMPLES) HTEX_FILES_INPUT = $(patsubst %, tmp/%.input, ${HTEX_FILES}) ${HTEX_FILES_INPUT}: tmp/%.input: ${htexsrcdir}/%.htex ${MKDIR_P} tmp - ${HTEX2INPUT} $< | ${AWK} -f ${srcdir}/skip-graphics.awk > $@ + ${HTEX2INPUT} $< > $@ HTEX_FILES_SPOOL = ${patsubst %, tmp/%.spool, ${HTEX_FILES}} ${HTEX_FILES_SPOOL}: tmp/%.spool: tmp/%.input @@ -657,21 +666,28 @@ PS_FILES_PS = ${patsubst %, %.ps, ${PS_FILES}} ${PS_FILES_PS}: %.ps: ${pssrcdir}/%.ps cp $< $@ -HTEX_PICS = SEGBIND ug00 ug01 ug07 ug08 ug10 ug11 -HTEX_PICS_INPUT = ${patsubst %, tmp/pics-%.input, ${HTEX_PICS}} -${HTEX_PICS_INPUT}: tmp/pics-%.input: ${htexsrcdir}/%.htex +# Note that one tmp/vp-*.input file may produces several postscript +# files. +HTEX_VIEWPORTS_INPUT = ${patsubst %, tmp/vp-%.input, ${HTEX_VIEWPORTFILES}} +HTEX_VIEWPORTS_STAMP = ${patsubst %, tmp/stamp-%, ${HTEX_VIEWPORTFILES}} \ + tmp/stamp-knot3 + +${HTEX_VIEWPORTS_INPUT}: tmp/vp-%.input: tmp/%.input ${MKDIR_P} tmp - ${HTEX2INPUT} $< > $@ + (echo ")assert CreateGraphics"; cat $<) > $@ + +tmp/vp-knot3.input: knot3.input ${INPUT_EXTRA_INPUT} + cp $< $@ + +${HTEX_VIEWPORTS_STAMP}: tmp/stamp-%: tmp/vp-%.input unset DAASE; FRICAS=${FRICAS}; export FRICAS; \ - echo ")read $@" | FRICAS_INITFILE='' ${XVFB} \ + echo ")read $<" | FRICAS_INITFILE='' ${XVFB} \ ${FRICAS}/bin/fricas -noht -noclef > /dev/null + ${STAMP} $@ -stamp-pics: ${INPUT_EXTRA_INPUT} ${HTEX_PICS_INPUT} ${PS_FILES_PS} - (unset DAASE; FRICAS=${FRICAS}; export FRICAS; \ - echo ')read ug-pics' | FRICAS_INITFILE='' ${XVFB} \ - ${FRICAS}/bin/fricas -noht -noclef) +stamp-book-viewports: ${HTEX_VIEWPORTS_STAMP} ${PS_FILES_PS} for f in tmp/*.VIEW/image.ps; do \ - cp $$f `echo $$f | cut -d / -f 2 | cut -d . -f 1`.ps; \ + cp $$f `echo $$f | sed 's,tmp/\(.*\)\.VIEW/image,\1,'`; \ done ${STAMP} $@ @@ -704,7 +720,7 @@ tmp/info.tex: # Convince latex to abort on error. LATEX=latex -halt-on-error -file-line-error -interaction=nonstopmode -book.dvi: stamp-pics tmp/ug09.tex tmp/info.tex ${HTEX_FILES_TEX} +book.dvi: stamp-book-viewports tmp/ug09.tex tmp/info.tex ${HTEX_FILES_TEX} TEXINPUTS=$$TEXINPUTS:${srcdir}:tmp:. ${LATEX} book.tex \ || (echo "==> Detected problem while running LaTeX."; \ echo "==> LaTeX must be installed."; \ diff --git a/src/doc/fricas.sty b/src/doc/fricas.sty index 5842e85ee..25a71b75c 100644 --- a/src/doc/fricas.sty +++ b/src/doc/fricas.sty @@ -14,8 +14,6 @@ % and Robert Sutor for the FriCAS system. \usepackage{graphicx} -\def\epsffile[#1]#2{\begin{center}\includegraphics[height=.24\textheight]{#2}\end{center}} - \usepackage{fricasmath} \usepackage{verbatim} % Needed for the discard environment. \usepackage{hyperref} diff --git a/src/doc/ht/util.ht b/src/doc/ht/util.ht index 23b777a1e..c441f0627 100644 --- a/src/doc/ht/util.ht +++ b/src/doc/ht/util.ht @@ -229,7 +229,6 @@ The page you requested was not found in the \HyperName{} database. \newcommand{\ell}{\inputbitmap{\htbmdir{}/ell.bitmap}} \newcommand{\emptyset}{\inputbitmap{\htbmdir{}/emptyset.bitmap}} \newcommand{\epsilon}{\inputbitmap{\htbmdir{}/epsilon.bitmap}} -\newcommand{\epsffile}{} \newcommand{\eta}{\inputbitmap{\htbmdir{}/eta.bitmap}} \newcommand{\exists}{\inputbitmap{\htbmdir{}/exists.bitmap}} \newcommand{\forall}{\inputbitmap{\htbmdir{}/forall.bitmap}} diff --git a/src/doc/htex/SEGBIND.htex b/src/doc/htex/SEGBIND.htex index d9e417ca7..42962869a 100644 --- a/src/doc/htex/SEGBIND.htex +++ b/src/doc/htex/SEGBIND.htex @@ -47,10 +47,7 @@ syntax for arguments to certain operations. }{ \spadcommand{sum(i^2, i = 0..n)} } -\begin{htonly} -\spadgraph{draw(x^2, x = -2..2)} -\end{htonly} -\begin{texonly} + \psXtc{ The \spadfun{draw} operation uses a \spadtype{SegmentBinding} argument as a range of coordinates. @@ -60,10 +57,8 @@ other \spadfun{draw} options use more than one }{ \spadgraph{draw(x^2, x = -2..2)} }{ -% window was 256 x 256 -\epsffile[72 72 300 300]{SEGBIND.ps} +SEGBIND } -\end{texonly} \xtc{ The left-hand side must be of type \spadtype{Symbol} but the diff --git a/src/doc/htex/ug00.htex b/src/doc/htex/ug00.htex index be23e482a..b0caca326 100644 --- a/src/doc/htex/ug00.htex +++ b/src/doc/htex/ug00.htex @@ -82,7 +82,7 @@ Draw \texht{$J_0(\sqrt{x^2+y^2})$}{\spad{J_0(sqrt(x^2+y^2))}} for }{ \spadgraph{draw(5*besselJ(0,sqrt(x^2+y^2)), x=-20..20, y=-20..20)} }{ -\epsffile[0 0 295 295]{bessintr.ps} +bessintr } Graphs in \Language{} are interactive objects you can manipulate with diff --git a/src/doc/htex/ug01.htex b/src/doc/htex/ug01.htex index c905b0ef7..cea07a7e5 100644 --- a/src/doc/htex/ug01.htex +++ b/src/doc/htex/ug01.htex @@ -672,8 +672,7 @@ This PostScript image was produced by clicking on the }{ \spadgraph{draw(cos(5*t/8), t=0..16*\%pi, coordinates==polar)} }{ -% window was 256 x 256 -\epsffile[0 0 300 324]{rose-1.ps} +rose-1 } \psXtc{ @@ -690,8 +689,7 @@ of \Language{}'s numeric and graphics capabilities. }{ \spadgraph{draw((x,y) +-> real atan complex(x,y), -\%pi..\%pi, -\%pi..\%pi, colorFunction == (x,y) +-> argument atan complex(x,y))} }{ -% window was 256 x 256 -\epsffile[72 72 285 285]{atan-1.ps} +atan-1 } An exhibit of \Gallery{} is given in the diff --git a/src/doc/htex/ug07.htex b/src/doc/htex/ug07.htex index 2d4245b4a..b715958a3 100644 --- a/src/doc/htex/ug07.htex +++ b/src/doc/htex/ug07.htex @@ -36,9 +36,11 @@ % \begin{texonly} -% +\vspace*{-2cm} \begin{figure}[htbp] -\epsffile[10 0 300 300]{knot3.ps} +\begin{center} + \includegraphics[height=.4\textheight]{knot3} +\end{center} \vskip -.5\baselineskip \caption{Torus knot of type (15,17).} \vskip .5\baselineskip @@ -129,8 +131,7 @@ quickly and efficiently. }{ \spadgraph{draw(sin(tan(x)) - tan(sin(x)),x = 0..6)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2D1VarA.ps} +2D1VarA } Notice that \Language{} compiled the function before the graph was put @@ -142,8 +143,7 @@ This time we give the graph a title. }{ \spadgraph{draw(sin(tan(x)) - tan(sin(x)),x = 10..16)} }{ -%window was 300 x 300 -\epsffile[0 0 295 295]{2D1VarB.ps} +2D1VarB } % Once again the formula is converted to a compiled function before @@ -162,8 +162,7 @@ and the second is just the range with no independent variable. }{ \spadgraph{draw(f, 0..4) \free{f}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2D1VarD.ps} +2D1VarD } % ********************************************************************* @@ -203,8 +202,7 @@ functions, one for each of the functions \spad{f} and \spad{g}. }{ \spadgraph{draw(curve(sin(t)*sin(2*t)*sin(3*t), sin(4*t)*sin(5*t)*sin(6*t)), t = 0..2*\%pi)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DppcA.ps} +2DppcA } % % @@ -214,8 +212,7 @@ optional argument to the \spadfun{draw} command. }{ \spadgraph{draw(curve(cos(t), sin(t)), t = 0..2*\%pi)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DppcB.ps} +2DppcB } % If you plan on plotting \spad{x = f(t)}, \spad{y = g(t)} as \spad{t} ranges over @@ -241,8 +238,7 @@ independent variable. }{ \spadgraph{draw(curve(f,g),0..\%pi) \free{f g}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DppcC.ps} +2DppcC } % % @@ -254,8 +250,7 @@ the first function specified in \spadfun{curve}. }{ \spadgraph{draw(curve(f,g),-4*\%pi..4*\%pi) \free{f g}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DppcE.ps} +2DppcE } % ********************************************************************* @@ -316,8 +311,7 @@ where \spad{p} is a polynomial. }{ \spadgraph{draw(p = 0, x, y, range == [-1..11, -7..7]) \free{p}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DpacA.ps} +2DpacA } % ********************************************************************* @@ -357,8 +351,7 @@ Here we turn it off. }{ \spadgraph{draw(sin(1/x),x=-2*\%pi..2*\%pi, adaptive == false)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptAd.ps} +2DOptAd } % % @@ -370,8 +363,7 @@ If on, large values are cut off according to }{ \spadgraph{draw(tan(x),x=-2*\%pi..2*\%pi, clip == true)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptCp.ps} +2DOptCp } % % @@ -384,8 +376,7 @@ The default can be determined using }{ \spadgraph{draw(sin(x),x=-\%pi..\%pi, toScale == true, unit == [1.0,1.0])} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptSc.ps} +2DOptSc } % % @@ -398,8 +389,7 @@ If only one range is specified, clipping applies to the y-axis. }{ \spadgraph{draw(sec(x),x=-2*\%pi..2*\%pi, clip == [-2*\%pi..2*\%pi,-\%pi..\%pi], unit == [1.0,1.0])} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptCpR.ps} +2DOptCpR } % \psXtc{ @@ -412,8 +402,7 @@ indicated palette color }{ \spadgraph{draw(sin(x),x=-\%pi..\%pi, curveColor == bright red())} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptCvC.ps} +2DOptCvC } % \psXtc{ @@ -426,8 +415,7 @@ palette color }{ \spadgraph{draw(sin(x),x=-\%pi..\%pi, pointColor == pastel yellow())} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptPtC.ps} +2DOptPtC } % \psXtc{ @@ -437,8 +425,7 @@ according to the indicated steps [\spad{x} interval, \spad{y} interval]. }{ \spadgraph{draw(curve(9*sin(3*t/4),8*sin(t)), t = -4*\%pi..4*\%pi, unit == [2.0,1.0])} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptUt.ps} +2DOptUt } % % @@ -450,8 +437,7 @@ for solving plane algebraic curve plots. }{ \spadgraph{draw(y^2 + y - (x^3 - x) = 0, x, y, range == [-2..2,-2..1], unit==[1.0,1.0])} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptRgA.ps} +2DOptRgA } % % @@ -460,8 +446,7 @@ A second example of a solution plot. }{ \spadgraph{draw(x^2 + y^2 = 1, x, y, range == [-3/2..3/2,-3/2..3/2], unit==[0.5,0.5])} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptRgB.ps} +2DOptRgB } % % @@ -481,8 +466,7 @@ For more details, see \spadref{ugGraphCoord}% }{ \spadgraph{draw(curve(sin(5*t),t),t=0..2*\%pi, coordinates == polar)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{2DOptPlr.ps} +2DOptPlr } % ********************************************************************* @@ -546,8 +530,7 @@ Use the {\tt pointColor} option for points. }{ \spadgraph{draw(x^2,x=-1..1,pointColor == green())} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{23DColA.ps} +23DColA } % \psXtc{ @@ -555,8 +538,7 @@ Use the {\tt curveColor} option for curves. }{ \spadgraph{draw(x^2,x=-1..1,curveColor == color(13) + 2*blue())} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{23DColB.ps} +23DColB } % ********************************************************************* @@ -596,8 +578,7 @@ Palettes can be used in specifying colors in \twodim{} graphs. }{ \spadgraph{draw(x^2,x=-1..1,curveColor == dark blue())} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{23DPal.ps} +23DPal } % ********************************************************************* @@ -1102,7 +1083,7 @@ list of options specified within the brackets. }{ \spadgraph{makeViewport2D(g,[title("Lines")])\$VIEW2D \free{g}} }{ -\epsffile[]{lines.ps} +lines } \xtc{ @@ -1161,7 +1142,7 @@ Here is the graph. }{ \spadgraph{makeViewport2D(g,[title("Graph Points")])\$VIEW2D \free{Sg gp5}} }{ -\epsffile[]{graphpoints.ps} +graphpoints } % @@ -1192,7 +1173,7 @@ Take a look. }{ \spadgraph{makeViewport2D(v)\$VIEW2D \free{Svog2}} }{ -\epsffile[]{justpoints.ps} +justpoints } @@ -1279,7 +1260,7 @@ Display the new \spadtype{TwoDimensionalViewport} containing both graphs. }{ \spadgraph{makeViewport2D(v2) \free{v22}} }{ -\epsffile[]{twographs1.ps} +twographs1 } Instead of using \spadfun{draw} to draw a graph and then extract graph data we can use \spadfun{makeObject}. @@ -1304,7 +1285,7 @@ Display the new \spadtype{TwoDimensionalViewport} containing both graphs. }{ \spadgraph{makeViewport2D(v3) \free{v33}} }{ -\epsffile[]{twographs2.ps} +twographs2 } \noOutputXtc{ The viewports \spad{v1}, \spad{v2} and \spad{v3} are no longer needed so @@ -1366,8 +1347,7 @@ default title. }{ \spadgraph{draw(cos(x*y),x=-3..3,y=-3..3)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3D2VarA.ps} +3D2VarA } % \xtc{ @@ -1387,8 +1367,7 @@ of data for the graph. }{ \spadgraph{draw(f,-\%pi..\%pi,-\%pi..\%pi) \free{f}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3D2VarB.ps} +3D2VarB } % ********************************************************************* @@ -1426,8 +1405,7 @@ the range specification with the variable name and an }{ \spadgraph{draw(curve(5*cos(t), 5*sin(t),t), t=-12..12)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DpscA.ps} +3DpscA } % \xtc{ @@ -1454,8 +1432,7 @@ Again, \Language{} supplies a default title. }{ \spadgraph{draw(curve(i1,i2,i3),0..15*\%pi) \free{i1 i2 i3}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DpscB.ps} +3DpscB } % ********************************************************************* @@ -1499,8 +1476,7 @@ here as parabolic cylindrical coordinates (see }{ \spadgraph{draw(surface(u*cos(v), u*sin(v), v*cos(u)), u=-4..4, v=0..\%pi, coordinates== parabolicCylindrical)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DpsA.ps} +3DpsA } % Again, you can graph these parametric surfaces using functions, @@ -1539,8 +1515,7 @@ choosing the toroidal coordinate system. }{ \spadgraph{draw(surface(n1,n2,n3), 1..4, 1..2*\%pi, coordinates == toroidal(1\$DFLOAT)) \free{n1 n2 n3}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DpsB.ps} +3DpsB } % ********************************************************************* @@ -1572,8 +1547,7 @@ The option \spad{title} gives your graph a title. }{ \spadgraph{draw(cos(x*y),x=0..2*\%pi,y=0..\%pi,title == "Title of Graph") } }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptTtl.ps} +3DOptTtl } % \psXtc{ @@ -1585,8 +1559,7 @@ The choices are }{ \spadgraph{draw(cos(x*y),x=-3..3,y=-3..3, style=="smooth", title=="Smooth Option")} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptSty.ps} +3DOptSty } % @@ -1610,8 +1583,7 @@ value of the parametric variable specified for a tube plot. }{ \spadgraph{draw(curve(sin(t), cos(t),0), t=0..2*\%pi, tubeRadius == .3, colorFunction == color1) \free{colorFxn1}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptCf1.ps} +3DOptCf1 } % \xtc{ @@ -1625,8 +1597,7 @@ Use the option {\tt colorFunction} for special coloring. }{ \spadgraph{draw(cos(u*v), u=-3..3, v=-3..3, colorFunction == color2) \free{colorFxn2}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptCf2.ps} +3DOptCf2 } % \xtc{ @@ -1639,8 +1610,7 @@ color also depends on the value of the function. }{ \spadgraph{draw(cos(x*y), x=-3..3, y=-3..3, colorFunction == color3) \free{colorFxn3}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptCf3.ps} +3DOptCf3 } % Normally the Cartesian coordinate system is used. @@ -1662,8 +1632,7 @@ coordinate system. }{ \spadgraph{draw(m, 0..2*\%pi,0..\%pi, coordinates == spherical, style=="shade") \free{m}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptCrd.ps} +3DOptCrd } % Space curves may be displayed as tubes with polygonal cross sections. @@ -1678,8 +1647,7 @@ encircles the specified space curve. }{ \spadgraph{draw(curve(sin(t),cos(t),0),t=0..2*\%pi, style=="shade", tubeRadius == .3)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptRad.ps} +3DOptRad } % % @@ -1692,8 +1660,7 @@ The larger this number is, the more cylindrical the tube becomes. }{ \spadgraph{draw(curve(sin(t), cos(t), 0), t=0..2*\%pi, style=="shade", tubeRadius == .25, tubePoints == 3)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptPts.ps} +3DOptPts } % \index{graphics!3D options!variable steps} @@ -1707,8 +1674,7 @@ first and second parameters of the surface function(s). }{ \spadgraph{draw(cos(x*y),x=-3..3,y=-3..3, style=="shade", var1Steps == 30, var2Steps == 30)} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DOptvB.ps} +3DOptvB } % The {\tt space} option @@ -1735,8 +1701,7 @@ into \spad{s}. }{ \spadgraph{draw(m,0..\%pi,0..2*\%pi, coordinates == spherical, space == s) \free{s m}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3Dmult1A.ps} +3Dmult1A } % % @@ -1745,8 +1710,7 @@ Add a second graph to \spad{s}. }{ \spadgraph{v := draw(curve(1.5*sin(t), 1.5*cos(t),0), t=0..2*\%pi, tubeRadius == .25, space == s) \free{s} \bound{v}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3Dmult1B.ps} +3Dmult1B } % A three-space object can also be obtained from an existing \threedim{} viewport @@ -1876,8 +1840,7 @@ enclosed in parentheses. }{ \spadgraph{makeViewport3D(space, title == "Letters") \free{space curve1 curve2 curve3 curve4 curve5 curve6 curve7 curve8}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DBuildA.ps} +3DBuildA } % ********************************************************************* @@ -1968,8 +1931,7 @@ Create and display the viewport. }{ \spadgraph{makeViewport3D(spaceC, title == "Cube") \free{pol1 pol2 pol3 pol4 pol5 pol6}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{3DBuildB.ps} +3DBuildB } % ********************************************************************* @@ -1995,8 +1957,7 @@ Graph plotted in default coordinate system. }{ \spadgraph{draw(m,0..3,0..5) \free{m}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{defcoord.ps} +defcoord } The \spad{z} coordinate comes first since the first argument of @@ -2019,8 +1980,7 @@ parameter to the \spadfun{draw} command. }{ \spadgraph{draw(m,0..3,0..5,coordinates==cartesian) \free{m cart}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{cartcoord.ps} +cartcoord } % @@ -2060,8 +2020,7 @@ Graph plotted in cylindrical coordinates. }{ \spadgraph{draw(f,0..\%pi,0..6,coordinates==cylindrical) \free{f}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{cylCoord.ps} +cylCoord } Suppose you would like to specify \smath{z} as a function of @@ -2116,8 +2075,7 @@ Graph the same function \spad{f} using the coordinate mapping of the function }{ \spadgraph{draw(f,0..3,0..2*\%pi,coordinates==newmap) \free{f new}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{newmap.ps} +newmap } % I think this is good to say here: it shows a lot of depth. RSS @@ -2171,8 +2129,7 @@ the gamma function in order to eliminate the extreme divergence it creates. }{ \spadgraph{draw(gamma,-\%pi..\%pi,-\%pi..\%pi,var1Steps==50,var2Steps==50) \free{g}} }{ -% window was 300 x 300 -\epsffile[0 0 295 295]{clipGamma.ps} +clipGamma } % ********************************************************************* diff --git a/src/doc/htex/ug08.htex b/src/doc/htex/ug08.htex index 96522cff7..59d9e33b1 100644 --- a/src/doc/htex/ug08.htex +++ b/src/doc/htex/ug08.htex @@ -617,7 +617,7 @@ values near zero and blue/violet indicates large positive imaginary values. }{ \spadgraph{draw((x,y)+-> real exp complex(x,y), -2..2, -2*\%pi..2*\%pi, colorFunction == (x, y) +-> imag exp complex(x,y), title=="exp(x+\%i*y)", style=="smooth")} }{ -\epsffile[0 0 295 295]{compexp.ps} +compexp } \begin{inputonly} @@ -633,7 +633,7 @@ see that the function is real only for a real argument. }{ \spadgraph{vp := draw((x,y) +-> real atan complex(x,y), -\%pi..\%pi, -\%pi..\%pi, colorFunction==(x,y) +->argument atan complex(x,y), title=="atan(x+\%i*y)", style=="shade"); rotate(vp,-160,-45); vp} }{ -\epsffile[0 0 295 295]{compatan.ps} +compatan } \begin{inputonly} )set message test on @@ -644,7 +644,7 @@ This is the complex Gamma function. }{ \spadgraph{draw((x,y) +-> max(min(real Gamma complex(x,y),4),-4), -\%pi..\%pi, -\%pi..\%pi, style=="shade", colorFunction == (x,y) +-> argument Gamma complex(x,y), title == "Gamma(x+\%i*y)", var1Steps == 50, var2Steps== 50)} }{ -\epsffile[0 0 295 295]{compgamm.ps} +compgamm } \psXtc{ @@ -652,7 +652,7 @@ This shows the real Beta function near the origin. }{ \spadgraph{draw(Beta(x,y)/100, x=-1.6..1.7, y = -1.6..1.7, style=="shade", title=="Beta(x,y)", var1Steps==40, var2Steps==40)} }{ -\epsffile[0 0 295 295]{realbeta.ps} +realbeta } \psXtc{ @@ -662,7 +662,7 @@ argument \texht{$x$}{\spad{x}} in the range \spad{2..14}. }{ \spadgraph{draw((alpha,x) +-> min(max(besselJ(alpha, x+8), -6), 6), -6..4, -6..6, title=="besselJ(alpha,x)", style=="shade", var1Steps==40, var2Steps==40)} }{ -\epsffile[0 0 295 295]{bessel.ps} +bessel } \psXtc{ @@ -673,7 +673,7 @@ and fixed argument \texht{$x = 5$}{\spad{x = 5}}. }{ \spadgraph{draw(besselI(alpha, 5), alpha = -12..12, unit==[5,20])} }{ -\epsffile[0 0 295 295]{modbess.ps} +modbess } \psXtc{ @@ -683,7 +683,7 @@ takes on complex values in a \spad{6 x 6} rectangle centered on the origin. }{ \spadgraph{draw((x,y) +-> real besselI(complex(x/20, y/20),5), -60..60, -60..60, colorFunction == (x,y)+-> argument besselI(complex(x/20,y/20),5), title=="besselI(x+i*y,5)", style=="shade")} }{ -\epsffile[0 0 295 295]{modbessc.ps} +modbessc } % ********************************************************************* diff --git a/src/doc/htex/ug10.htex b/src/doc/htex/ug10.htex index 06fd82fc4..00f4291fc 100644 --- a/src/doc/htex/ug10.htex +++ b/src/doc/htex/ug10.htex @@ -85,7 +85,7 @@ Draw the ribbon for \smath{z=x ^ 2}. }{ \spadgraph{draw(x^2,x=-1..1,y=0..1)} }{ -\epsffile[0 0 295 295]{ribbon1.ps} +ribbon1 } Now that was easy! @@ -106,7 +106,7 @@ so that only \spad{1} step is computed in the }{ \spadgraph{vp := draw(x^2,x=-1..1,y=0..1,var2Steps==1) \bound{d1}} }{ -\epsffile[0 0 295 295]{ribbon2.ps} +ribbon2 } The operation has created a viewport, that is, a graphics window @@ -133,7 +133,7 @@ This turns the graph so you can view it along the \smath{y}-axis. }{ \spadcommand{rotate(vp, 0, -90)\bound{d3}\free{d1}} }{ -\epsffile[0 0 295 295]{ribbon2r.ps} +ribbon2r } There are many other things you can do. @@ -177,7 +177,7 @@ Add the ribbon for }{ \spadgraph{vp := draw(x^3,x=-1..1,y=1..2,var2Steps==1, space==sp)\bound{d6}\free{d5}} }{ -\epsffile[0 0 295 295]{ribbons.ps} +ribbons } Unless you moved the original viewport, the new viewport covers @@ -193,14 +193,14 @@ Show quadrilateral polygon outlines. }{ \spadcommand{drawStyle(vp,"shade");outlineRender(vp,"on")\bound{d10}\free{d6}} }{ -\epsffile[0 0 295 295]{ribbons2.ps} +ribbons2 } \psXtc{ Enclose the ribbons in a box. }{ \spadcommand{rotate(vp,20,-60); showRegion(vp,"on")\bound{d11}\free{d10}} }{ -\epsffile[0 0 295 295]{ribbons2b.ps} +ribbons2b } This process has become tedious! @@ -302,7 +302,7 @@ for \texht{$-1 \leq x \leq 1$}{-1 <= x <= 1} }{ \spadgraph{drawRibbons([x^i for i in 1..5],x=-1..1) \free{s0}} }{ -\epsffile[0 0 295 295]{ribbons5.ps} +ribbons5 } @@ -480,14 +480,14 @@ Create a \threedim{} viewport containing that space. }{ \spadgraph{vp := makeViewport3D(sp,"Arrow")\bound{v4}\free{v3}} }{ -\epsffile[0 0 295 295]{arrow.ps} +arrow } \psXtc{ Here is a better viewing angle. }{ \spadcommand{rotate(vp,200,-60)\bound{v5}\free{v4}} }{ -\epsffile[0 0 295 295]{arrowr.ps} +arrowr } @@ -547,7 +547,7 @@ A bouquet of a dozen arrows. }{ \spadgraph{drawBouquet(12,"A Dozen Arrows")\free{b1}} }{ -\epsffile[0 0 295 295]{bouquet.ps} +bouquet } \ @@ -721,7 +721,7 @@ Draw the complex vector field of \spad{sin(x)}. }{ \spadgraph{drawComplexVectorField(sin,-2..2,-2..2) \free{readVI}} }{ -\epsffile[0 0 295 295]{vectorSin.ps} +vectorSin } \ @@ -812,7 +812,7 @@ Draw it with an odd number of steps to avoid the pole. }{ \spadgraph{drawComplex(f,-2..2,-2..2)\free{e1 readVI}} }{ -\epsffile[0 0 295 295]{complexExp.ps} +complexExp } \ @@ -1024,12 +1024,12 @@ The vector field. }{ \spadgraph{drawComplexVectorField(g^3,-3..3,-3..3)\free{n3}} }{ -\epsffile[0 0 295 295]{vectorRoot.ps} +vectorRoot } \psXtc{ The surface. }{ \spadgraph{drawComplex(g^3,-3..3,-3..3)\free{n3}} }{ -\epsffile[0 0 295 295]{complexRoot.ps} +complexRoot } diff --git a/src/doc/htex/ug11.htex b/src/doc/htex/ug11.htex index bb107c4a8..e0bec52f5 100644 --- a/src/doc/htex/ug11.htex +++ b/src/doc/htex/ug11.htex @@ -417,7 +417,7 @@ Draw the \spadfun{Gamma} function. }{ \spadgraph{drawComplex(f,-\%pi..\%pi,-\%pi..\%pi, false) \free{srs scs f}} }{ -\epsffile[0 0 300 300]{3Dgamma11.ps} +3Dgamma11 } % ********************************************************************* diff --git a/src/doc/htex2input.awk b/src/doc/htex2input.awk index 6a9a9dd37..4560c63da 100644 --- a/src/doc/htex2input.awk +++ b/src/doc/htex2input.awk @@ -11,9 +11,11 @@ BEGIN { print ")set streams calculate 7" print "outputSpacing(0)" print "-- \\end{inputonly}" + spadgraph=0 } END { + maybeCloseViewport() print ")set quit unprotected" print ")quit" } @@ -62,14 +64,12 @@ END { /^} *$/ && xtc>1 { xtc=0 - spadgraph=0 print "-- \\end{" xtcname "}" next } xtc==2 && (/^\\spadcommand{/ || /^\\spadgraph{/) { - if (match($0, /^\\spadgraph{/)) spadgraph=1 - print "-- \\begin{spadsrc}" + posspadgraph=match($0, /^\\spadgraph{/) gsub(/^\\spadcommand{/, "") gsub(/^\\spadgraph{/, "") gsub(/}$/, "") @@ -79,17 +79,31 @@ xtc==2 && (/^\\spadcommand{/ || /^\\spadgraph{/) { gsub(/\\_/, "_") gsub(/\\free{.*/, "") gsub(/\\bound{.*/, "") + gsub(/ *$/, "") + + # ")clear all" commands need special treatment + if ($0 == ")clear all") {maybeCloseViewport()} + print "-- \\begin{spadsrc}" print "-- " $0 print "-- \\end{spadsrc}" + if (xtcname=="psXtc") { - print "-- \\begin{psxtcnooutput}" - print $0 - print "-- \\end{psxtcnooutput}" + if (posspadgraph>0) {maybeCloseViewport()} + print "-- \\begin{inputonly}" + if (posspadgraph>0) { + spadgraph=1 + print ")if CreateGraphics" + print "spadgraphViewport:=" $0 + print ")endif" + } else { + print $0 + } + print "-- \\end{inputonly}" } if (xtcname=="noOutputXtc") { - print "-- \\begin{xtcnooutput}" + print "-- \\begin{inputonly}" print $0 - print "-- \\end{xtcnooutput}" + print "-- \\end{inputonly}" } if (xtcname=="xtc") { print $0 @@ -108,22 +122,16 @@ xtc==2 && /^\\begin{spadsrc}/ { getline } print "-- " $0 - if (xtcname=="psXtc") { - print "-- \\begin{psxtcnooutput}" - } - if (xtcname=="noOutputXtc") { - print "-- \\begin{xtcnooutput}" + if (xtcname=="psXtc" || xtcname=="noOutputXtc") { + print "-- \\begin{inputonly}" } if (xtcname=="xtc" || xtcname=="noOutputXtc") { if (xtcname!="nullXtc") { for (i = 1; i < n; i++) {print arr[i]} } } - if (xtcname=="psXtc") { - print "-- \\end{psxtcnooutput}" - } - if (xtcname=="noOutputXtc") { - print "-- \\end{xtcnooutput}" + if (xtcname=="psXtc" || xtcname=="noOutputXtc") { + print "-- \\end{inputonly}" } next } @@ -149,27 +157,39 @@ xtc==2 && /^\\begin{spadsrc}/ { next } -xtc==3 && /^\\epsffile/ { - print "-- " $0 - if (xtcname == "psXtc" && spadgraph == 1) { - gsub(/^\\epsffile.*{/, "") - gsub(/}$/, "") - print "-- \\begin{psxtcnooutput}" - print "write(%, \"tmp/" $0 "\", \"postscript\"); close(%)" - print "-- \\end{psxtcnooutput}" - } +xtc==3 && xtcname == "psXtc" { + print "-- \\begin{center}" + print "-- \\includegraphics[height=.25\\textheight]{" $0 "}" + print "-- \\end{center}" + print "-- \\begin{inputonly}" + print ")if CreateGraphics" + print "write(spadgraphViewport, \"tmp/" $0 "\", \"postscript\");" + print ")endif" + print "-- \\end{inputonly}" next } { print "-- " $0 if (match($0,/^\\head/)) { + maybeCloseViewport() print "-- \\begin{inputonly}" print ")clear all" print "-- \\end{inputonly}" } } +function maybeCloseViewport() { + if (spadgraph>0) { + print "-- \\begin{inputonly}" + print ")if CreateGraphics" + print "close(spadgraphViewport);" + print ")endif" + print "-- \\end{inputonly}" + } + spadgraph=0 +} + function endMacroIndex(line,parms, pp,x,bc,cc,len,found) { # assumes start of line is a macro call and returns position of final "}" x = 0 diff --git a/src/doc/skip-graphics.awk b/src/doc/skip-graphics.awk deleted file mode 100644 index 4a7e9f1d5..000000000 --- a/src/doc/skip-graphics.awk +++ /dev/null @@ -1,6 +0,0 @@ -# Discard \begin{psxtcnooutput} ... \end{psxtcnooutput}. -/^-- \\begin{psxtcnooutput}/,/^-- \\end{psxtcnooutput}/ {next} - -{ - print $0 -} diff --git a/src/doc/spool2tex.awk b/src/doc/spool2tex.awk index 38ab4c20a..6fcd74c2a 100644 --- a/src/doc/spool2tex.awk +++ b/src/doc/spool2tex.awk @@ -35,12 +35,6 @@ BEGIN { # Discard \begin{inputonly} ... \end{inputonly}. /^-- \\begin{inputonly}/,/^-- \\end{inputonly}/ {next} -# Discard \begin{xtcnooutput} ... \end{xtcnooutput}. -/^-- \\begin{xtcnooutput}/,/^-- \\end{xtcnooutput}/ {next} - -# Discard \begin{psxtcnooutput} ... \end{psxtcnooutput}. -/^-- \\begin{psxtcnooutput}/,/^-- \\end{psxtcnooutput}/ {next} - # start of xtc /^-- \\begin{xtc}/ || /^-- \\begin{noOutputXtc}/ { inxtc=1 diff --git a/src/input/knot3.input b/src/input/knot3.input new file mode 100644 index 000000000..5865ff010 --- /dev/null +++ b/src/input/knot3.input @@ -0,0 +1,9 @@ +-- chapter 7 +)read images1 +vp := % +title(vp, " "); axes(vp, "off"); rotate(vp, 0, 150) +zoom(vp, 1.9); outlineRender(vp, "off") +write(vp, "tmp/knot3", "postscript") +close(vp) + +)quit diff --git a/src/input/ug-pics.input b/src/input/ug-pics.input deleted file mode 100644 index 8d034b5a6..000000000 --- a/src/input/ug-pics.input +++ /dev/null @@ -1,43 +0,0 @@ --- section 10.1 -vp := draw(x^2,x=-1..1,y=0..1,var2Steps==1) - -rotate(vp, 0, -90) -write(vp, "tmp/ribbon2r", "postscript") - -sp := subspace(vp) -close(vp) - -vp := draw(x^3,x=-1..1,y=1..2,var2Steps==1, space==sp) - -drawStyle(vp,"shade");outlineRender(vp,"on") -write(vp, "tmp/ribbons2", "postscript") - -rotate(vp,20,-60); showRegion(vp,"on") -write(vp, "tmp/ribbons2b", "postscript") -close(vp) -)clear all - --- section 10.5 -zero := 0.0@DFLOAT -one := 1.0@DFLOAT -origin := point [zero,zero,zero,zero] -unit := point [one,one,one,zero] -)read arrows -arrow := makeArrow(origin,unit) -sp := createThreeSpace() -for a in arrow repeat sp := curve(sp,a) -vp := makeViewport3D(sp,"Arrow") -rotate(vp,200,-60) -write(vp, "tmp/arrowr", "postscript") -close(vp) -)clear all - --- chapter 7 -)read images1 -vp := % -title(vp, ""); axes(vp, "off"); rotate(vp, 90, 0) -zoom(vp, 1.9); outlineRender(vp, "off") -write(vp, "tmp/knot3", "postscript") -close(vp) - -)quit