PDF output

Messages in english

Modérateur : xcasadmin

belanger
Messages : 59
Inscription : jeu. juil. 27, 2017 3:26 pm

PDF output

Message par belanger » dim. sept. 13, 2020 8:26 pm

I just got back my first Xcas homework from my students.
To my surprise, some of them put it in Python mode even though
I never mentioned it to them. (Maybe not that surprising; Python
is the introductory computer language here.) Some of them didn't
know what the ps output was, though. Is there a straightforward
way to get a copy of a session in pdf?

Jay

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: PDF output

Message par parisse » lun. sept. 14, 2020 9:57 am

PS support under Windows requires two additional software Ghostscript and GSView http://www.cs.wisc.edu/~ghost/. Under linux and MacOS convert session.ps session.pdf will do the job.
Alternatively, you can clone the session in Xcas for Firefox, then the browser is certainly able to export to PDF.

XcasEngGuy
Messages : 145
Inscription : mer. janv. 13, 2010 3:20 pm

Re: PDF output

Message par XcasEngGuy » jeu. sept. 17, 2020 6:09 pm

If you have Cygwin installed (Windows computer) the following script will produce a nice landscape PDF. Save tex file from File>LaTex>Latex preview in the Xcas menu. Then run the script.

if [ $# -eq 0 ]
then
echo 'Convert tex file to PDF'
echo 'Usage: latex_pdf <tex file> [<zoom option>]'
echo 'optional <zoom option> from 10 to 10000 - 1000 is 1:1 zoom'
else
sed -i 's/\\documentclass{article}/\\documentclass[landscape]{article}\n\\usepackage{fullpage}/' $1
fn=$(cygpath -u $1 | sed -e 's?.*/??g' -e 's/.[Tt][Ee][Xx]$//')
latex $fn.tex
if [ $# -lt 2 ]
then
dvips $fn.dvi # -t letter -t landscape -Ppdf $fn.dvi
else
dvips -x $2 $fn.dvi # -t letter -t landscape -Ppdf -x $2 $fn.dvi
fi
ps2pdf $fn.ps $fn.pdf
rm $fn.aux
rm $fn.dvi
# rm $fn.log
# rm $fn.ps
cygstart $fn.pdf
fi
Dernière modification par XcasEngGuy le jeu. sept. 22, 2022 6:09 pm, modifié 1 fois.

XcasEngGuy
Messages : 145
Inscription : mer. janv. 13, 2010 3:20 pm

Re: PDF output

Message par XcasEngGuy » jeu. sept. 22, 2022 6:08 pm

I noticed that the new Latex input option in this forum is kicking in at random times. In my post above, the script is corrupted by the Latex conversion. Note, by using "view source" in chrome you can still see the original script.

(edit) I used backquotes in the original script and they appear to have triggered the Latex. I edited the post and used $( ) instead and that fixed it.

Répondre