On Thu, Apr 25, 2024 at 09:36:45PM +0800, Qian Yun wrote:
> With this patch, the book.pdf uses PS format images instead of
> using imagemagick to "covert" from bitmap xpm images.

Good.

> Also as Ralf wishes, now the build of book is independent from
> build of hypertex pages.
> 
> P.S to Ralf, this patch uses a few lines of your noOutputXtc patch,
> you should upstream that first.

There is some problem with this.  On my machine I got faulty
'TEXTFILE.tex', it contained '\begin{noOutputXtc}' but no
matching end part, causing documentaion build failure.

For me titles of pictures are too small, in bitmapped version
title letters are of comparable size to text letters, in .ps
version are smaller and almost unreadable when text has comfortable
size.

I also noticed problem which has nothing to do with the patch:
in 5.4.5 there is an example computing 100!.  In HyperDoc
number appears fine, but in the .pdf it is truncated.

In slightly different spirit: book convention of having separate
page numbers in "front matter" and in main part IMO is misguided
in .pdf: viewer allows navigation by page number, but number on
pages and numbers in viewer frequently diverge.  IMO it would be
good to adopt uniform numbering.  Also, maybe print full section
number in the page header, that is 5.4.5 instad of current 5.4.

> Also after this patch, src/doc/ps/arrowr.ps SEGBIND.ps knot3.ps
> ribbon2r.ps ribbons2.ps ribbons2b.ps can be removed, saves 1.3MB
> and 81123 lines from repo.
> 
> https://github.com/oldk1331/fricas/commit/46b2e034148674eb05834d8a642d337b1162b897.patch

I think that they should be removed in the same commit as your
patch (when it goes in).

> From: Qian Yun <oldk1...@gmail.com>
> Date: Thu, 25 Apr 2024 21:27:43 +0800
> Subject: [PATCH] generate book with ps image instead of bitmap image
> 
> ---
>  src/doc/Makefile.in       | 29 +++++++++++++++--------------
>  src/doc/fricas.sty        |  4 +++-
>  src/doc/htex/SEGBIND.htex |  2 +-
>  src/doc/htex2input.awk    | 28 ++++++++++++++++++++++++++--
>  src/doc/spool2tex.awk     |  3 +++
>  src/doc/ugepsf.awk        | 24 ------------------------
>  src/input/images1.input   |  7 ++++++-
>  src/input/ug-pics.input   | 28 ++++++++++++++++++++++++++++
>  8 files changed, 82 insertions(+), 43 deletions(-)
>  delete mode 100644 src/doc/ugepsf.awk
>  create mode 100644 src/input/ug-pics.input
> 
> diff --git a/src/doc/Makefile.in b/src/doc/Makefile.in
> index 7093802ec..68e214a62 100644
> --- a/src/doc/Makefile.in
> +++ b/src/doc/Makefile.in
> @@ -46,9 +46,7 @@
>  #
>  # "make book.pdf" does the following:
>  # - Copy pictures from the ps/ directory for (documentation of HyperDoc).
> -# - Convert the *.VIEW/image.xpm pictures to .ps images (target stamp-pics).
> -#   That expects all the .VIEW/ directories to exist (make viewports).
> -#   It needs the convert program from ImageMagick. See ugepsf.awk.
> +# - Copy pictures from tmp/*.VIEW/image.ps (target stamp-pics).
>  # - 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.
> @@ -138,7 +136,6 @@ UGSYSCMD2HELP = ${AWK} -f ${srcdir}/syscmd.awk
>  HTEX2INPUT    = ${AWK} -f ${srcdir}/htex2input.awk
>  SPOOL2TEX     = ${AWK} -f ${srcdir}/spool2tex.awk
>  UGEXAMPLES    = ${AWK} -f ${srcdir}/ugexamples.awk
> -UGEPSF        = ${AWK} -f ${srcdir}/ugepsf.awk
>  
>  ###################################################################
>  # Most of the variables below are designed in the following way: If
> @@ -297,7 +294,8 @@ HTEX_PASTEFILES = \
>  # HyperDoc and book.pdf.
>  # The list can be generated by the following command.
>  # grep -R '\\spadcommand{)read' *| sed 's/[^ ]* //;s/[ \].*//'|sort -u
> -INPUT_EXTRA = arrows bouquet newton ribbon vectors
> +INPUT_EXTRA = arrows bouquet newton ribbon vectors \
> +              ntube tknot images1 ug-pics
>  
>  ###################################################################
>  # For these files .ht files will be generated.
> @@ -634,7 +632,9 @@ ${HTEX_FILES_INPUT}: tmp/%.input: ${htexsrcdir}/%.htex
>  HTEX_FILES_SPOOL = ${patsubst %, tmp/%.spool, ${HTEX_FILES}}
>  ${HTEX_FILES_SPOOL}: tmp/%.spool: tmp/%.input
>       ${MKDIR_P} tmp
> -     echo ")read $<" | FRICAS_INITFILE='' ${INTERPSYS} > $@
> +     (unset DAASE; FRICAS=${FRICAS}; export FRICAS; \
> +             echo ')read $<' | FRICAS_INITFILE='' ${XVFB} \
> +             ${FRICAS}/bin/fricas -noht -noclef > $@)
>  
>  HTEX_FILES_TEX = ${patsubst %, tmp/%.tex, ${HTEX_FILES}}
>  ${HTEX_FILES_TEX}: tmp/%.tex: tmp/%.spool
> @@ -645,17 +645,12 @@ tmp/ug09.tex: tmp/examples.list
>       ${MKDIR_P} tmp
>       ${UGEXAMPLES} $< > $@
>  
> -pics.mk:
> -     grep 
> '\(\\head{\|\\psXtc\|\xtc\|\\noOutputXtc\|\\nullXtc\|epsffile\|\\spadgraph\)' 
> ${srcdir}/htex/ug*.htex \
> -     | ${UGEPSF} > $@
> -
>  ###################################################################
>  # There are a number of pictures for sections in book.pdf that
>  # demonstrate the use of HyperDoc.
>  PS_FILES = \
>    exit help home up  \
> -  ribbon2r ribbons2 ribbons2b \
> -  2Dctrl 3Dctrl SEGBIND arrowr knot3 \
> +  2Dctrl 3Dctrl \
>    h-alldoms h-allrank h-atsearch h-brfront h-comsearch h-consearch   \
>    h-docsearch h-gensearch h-matargs h-matats h-matdesc h-matexamp    \
>    h-matexports h-matimp h-matinv h-matmap h-matops h-matpage         \
> @@ -665,8 +660,14 @@ PS_FILES_PS = ${patsubst %, %.ps, ${PS_FILES}}
>  ${PS_FILES_PS}: %.ps: ${pssrcdir}/%.ps
>       cp $< $@
>  
> -stamp-pics: pics.mk viewports ${PS_FILES_PS}
> -     ${MAKE} -f pics.mk pics
> +stamp-pics: ${INPUT_EXTRA_INPUT} ${HTEX_FILES_SPOOL} ${PS_FILES_PS}
> +     ${MKDIR_P} tmp
> +     (unset DAASE; FRICAS=${FRICAS}; export FRICAS; \
> +             echo ')read ug-pics' | FRICAS_INITFILE='' ${XVFB} \
> +             ${FRICAS}/bin/fricas -noht -noclef)
> +     for f in tmp/*.VIEW/image.ps; do \
> +             cp $$f `echo $$f | cut -d / -f 2 | cut -d . -f 1`.ps; \
> +     done
>       ${STAMP} $@
>  
>  ###################################################################
> diff --git a/src/doc/fricas.sty b/src/doc/fricas.sty
> index 5d734a023..de186b06c 100644
> --- a/src/doc/fricas.sty
> +++ b/src/doc/fricas.sty
> @@ -16,7 +16,8 @@
>  \usepackage{epsf}
>  \def\epsfsize#1#2{.24\textheight}
>  \let\spadepsffilesave\epsffile
> -\def\epsffile[#1]#2{\begin{center}\spadepsffilesave[#1]{#2}\end{center}}
> +%\def\epsffile[#1]#2{\begin{center}\spadepsffilesave[#1]{#2}\end{center}}
> +\def\epsffile[#1]#2{\begin{center}\includegraphics[height=.24\textheight]{#2}\end{center}}
>  
>  \usepackage{fricasmath}
>  \usepackage{verbatim} % Needed for the discard environment.
> @@ -24,6 +25,7 @@
>  \usepackage{color}
>  \usepackage{listings}
>  \usepackage{makeidx}
> +\usepackage{graphicx}
>  \makeindex
>  
>  % We use xparse for the definition of a number of verbatim-like
> diff --git a/src/doc/htex/SEGBIND.htex b/src/doc/htex/SEGBIND.htex
> index fb6e1c1f8..d9e417ca7 100644
> --- a/src/doc/htex/SEGBIND.htex
> +++ b/src/doc/htex/SEGBIND.htex
> @@ -58,7 +58,7 @@ This is an example of a two-dimensional parametrized plot;
>  other \spadfun{draw} options use more than one
>  \spadtype{SegmentBinding} argument.
>  }{
> -\spadcommand{draw(x^2, x = -2..2)}
> +\spadgraph{draw(x^2, x = -2..2)}
>  }{
>  % window was 256 x 256
>  \epsffile[72 72 300 300]{SEGBIND.ps}
> diff --git a/src/doc/htex2input.awk b/src/doc/htex2input.awk
> index 48b06a983..60f362212 100644
> --- a/src/doc/htex2input.awk
> +++ b/src/doc/htex2input.awk
> @@ -62,11 +62,13 @@ END {
>  
>  /^} *$/ && xtc>1 {
>      xtc=0
> +    spadgraph=0
>      print "-- \\end{" xtcname "}"
>      next
>  }
>  
>  xtc==2 && (/^\\spadcommand{/ || /^\\spadgraph{/) {
> +    if (match($0, /^\\spadgraph{/)) spadgraph=1
>      print "-- \\begin{spadsrc}"
>      gsub(/^\\spadcommand{/, "")
>      gsub(/^\\spadgraph{/, "")
> @@ -79,7 +81,13 @@ xtc==2 && (/^\\spadcommand{/ || /^\\spadgraph{/) {
>      gsub(/\\bound{.*/, "")
>      print "-- " $0
>      print "-- \\end{spadsrc}"
> -    if (xtcname=="xtc" || xtcname=="noOutputXtc") {print $0}
> +    if (xtcname=="psXtc" || xtcname=="noOutputXtc") {
> +        print "-- \\begin{xtcnooutput}"
> +    }
> +    if (xtcname=="xtc" || xtcname=="noOutputXtc" || xtcname=="psXtc") {print 
> $0}
> +    if (xtcname=="psXtc" || xtcname=="noOutputXtc") {
> +        print "-- \\end{xtcnooutput}"
> +    }
>      next
>  }
>  
> @@ -114,7 +122,23 @@ xtc==2 && /^\\begin{spadsrc}/ {
>      next
>  }
>  
> -/^}{/ && xtc==2 {next}
> +/^}{/ && xtc==2 {
> +    xtc=3
> +    next
> +}
> +
> +xtc==3 && /^\\epsffile/ {
> +    print "-- " $0
> +    if (xtcname == "psXtc" && spadgraph == 1) {
> +        gsub(/^\\epsffile.*{/, "")
> +        gsub(/}$/, "")
> +        print "-- \\begin{xtcnooutput}"
> +        print "write(%, \"tmp/" $0 "\", \"postscript\")"
> +        print "close(%%(-2))"
> +        print "-- \\end{xtcnooutput}"
> +    }
> +    next
> +}
>  
>  {
>      print "-- " $0
> diff --git a/src/doc/spool2tex.awk b/src/doc/spool2tex.awk
> index 6fcd74c2a..a459cdd92 100644
> --- a/src/doc/spool2tex.awk
> +++ b/src/doc/spool2tex.awk
> @@ -35,6 +35,9 @@ BEGIN {
>  # Discard \begin{inputonly} ... \end{inputonly}.
>  /^-- \\begin{inputonly}/,/^-- \\end{inputonly}/ {next}
>  
> +# Discard \begin{xtcnooutput} ... \end{xtcnooutput}.
> +/^-- \\begin{xtcnooutput}/,/^-- \\end{xtcnooutput}/ {next}
> +
>  # start of xtc
>  /^-- \\begin{xtc}/ || /^-- \\begin{noOutputXtc}/ {
>      inxtc=1
> diff --git a/src/doc/ugepsf.awk b/src/doc/ugepsf.awk
> deleted file mode 100644
> index e39ddde9e..000000000
> --- a/src/doc/ugepsf.awk
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -/:\\head/ {
> -    sub(/.*{/,"")
> -    sub(/}/,"")
> -    view=$0 "Page"
> -    n=0
> -}
> -
> -(/:\\psXtc/ || /:\\xtc/ || /:\\noOutputXtc/ || /:\\nullXtc/) {n++}
> -
> -/:\\spadgraph/ {spadgraph=1}
> -
> -/:\\epsffile/ {
> -    sub(/.*{/,"")
> -    gsub(/}/,"")
> -    sub(/.*\//,"")
> -    if (spadgraph==1) {
> -        print "pics: " $0
> -    } else {
> -        print "no-pics: " $0
> -    }
> -    print $0 ": " view n ".VIEW/image.xpm"
> -    print "\tconvert $< $@"
> -    spadgraph=0
> -}
> diff --git a/src/input/images1.input b/src/input/images1.input
> index c74dac6a1..3f9425150 100644
> --- a/src/input/images1.input
> +++ b/src/input/images1.input
> @@ -5,4 +5,9 @@
>  
>  -- draw a (15,17) torus knot
>  
> -torusKnot(15,17, 0.1, 6, 700)
> +vp := torusKnot(15,17, 0.1, 6, 700)
> +
> +title(vp, ""); axes(vp, "off"); rotate(vp, 90, 0)
> +zoom(vp, 1.9); outlineRender(vp, "off")
> +write(vp, "tmp/knot3.ps", "postscript")
> +close(vp)
> diff --git a/src/input/ug-pics.input b/src/input/ug-pics.input
> new file mode 100644
> index 000000000..ced3a84c0
> --- /dev/null
> +++ b/src/input/ug-pics.input
> @@ -0,0 +1,28 @@
> +-- chapter 10
> +vp := draw(x^2,x=-1..1,y=0..1,var2Steps==1)
> +
> +rotate(vp, 0, -90)
> +write(vp, "tmp/ribbon2r.ps", "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.ps", "postscript")
> +
> +rotate(vp,20,-60); showRegion(vp,"on")
> +write(vp, "tmp/ribbons2b.ps", "postscript")
> +close(vp)
> +
> +vp := makeViewport3D(sp,"Arrow")
> +
> +rotate(vp,200,-60)
> +write(vp, "tmp/arrowr.ps", "postscript")
> +close(vp)
> +
> +-- chapter 7
> +)read images1
> +
> +)quit


-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/ZirSbfUuc4oPX3aw%40fricas.org.

Reply via email to