[OS X TeX] TeXShop 5.02: issue with TeX4ht and Sage code
Herbert Schulz
herbs2 at mac.com
Fri Sep 2 08:22:46 EDT 2022
> On Sep 1, 2022, at 8:12 PM, Murray Eisenberg <murrayeisenberg at gmail.com> wrote:
>
> This concerns the TeXShop 5.02 TeX4ht engine rendering of the file Fourier.tex that is in
>
> ~/Library/TeXShop/New/Demo/Fourier-for-TeXShop
>
> folder. Namely, when its first line is changed to...
>
> % !TEX TS-program = TeX4ht
>
> …and the source Fourier.tex is typeset (consequently, by the new TeX4ht engine, which calls tex4ht), something weird happens to one piece of Sage code in Section 9 “Interactive Experiments,” namely, in the example “A Sage Calculation”:
>
> <h4>A Sage Computation</h4>
> Type your own Sage computation below and click “Evaluate”.
> <div class="compute"><script type="text/x-sage">
> u, v = var('u,v')
> sage: fx = (3+sin(v)+cos(u))*cos(2*v)
> sage: fy = (3+sin(v)+cos(u))*sin(2*v)
> sage: fz = sin(u)+2*cos(v)
> sage: parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi),
> ....: frame=False, color="red")
> </script></div>
>
> Although that’s valid Sage code, when I typeset it with the TeX4ht engine, the html output for the SAge code appears as the following:
>
> u, v = var('u,v')
>
>
> sage: fx = (3+sin(v)+cos(u))*cos(2*v)
> sage: fy = (3+sin(v)+cos(u))*sin(2*v)
> sage: fz = sin(u)+2*cos(v)
> sage: parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi),
> ....: frame=False, color="red”)
>
> And then, when I click the Evaluate buttion under that Sage cell, I get an error:
>
> File "/tmp/ipykernel_1809651/351844888.py", line 8
> Ellipsis.: frame=False, color="red")
>
> ^
>
> SyntaxError: invalid syntax
>
> Merely editing that Sage cell in-place directly in the displayed html page so as to delete the two blank lines allows the code to be properly evaluated by SageCell and produce the expected 3D graphical output.
>
> Is this some quirk of TeX4ht?
>
> —
> Murray Eisenberg murrayeisenberg at gmail.com
> Mobile (413)-427-5334
> 503 King Farm Blvd #101
> Rockville, MD 20850-6667
Howdy,
While I don't understand what is happening I can reproduce this. The two `blank' lines are each actually filled with multiple spaces. The real problems are the `sage:' and the `....:' and then the spaces don't do anything. The code in the Fourier.tex file should be
u, v = var('u,v')
fx = (3+sin(v)+cos(u))*cos(2*v)
fy = (3+sin(v)+cos(u))*sin(2*v)
fz = sin(u)+2*cos(v)
parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi), frame=False, color="red")
Note: the parametric_plot3d command is all one line that may be wrapped on your email reader.
Good Luck,
Herb Schulz
herbs2 at mac.com
More information about the MacOSX-TeX
mailing list