[sage-support] Re: convertor Sage - TeX - PDF

2009-11-09 Thread Stan Schymanski

Hi Marik,

Thanks for that. For some reason, it does not work on the pdf I 
downloaded, but if I create a pdf myself, it works. The comment in the 
pdf could mention right-click to make it clearer. Great work! I hope 
this script will make it into sage some time!! It still produced a lot 
of error messages and formatting glitches with the worksheet I tried it 
on, but it is a good start.

Cheers
Stan

ma...@mendelu.cz wrote:

 On 6 lis, 16:05, Stan Schymanski schym...@gmail.com wrote:
   
 By the way, how do you get the attachment out of the pdf? I tried
 clicking on the graphic, but couldn't find any fuseful options in Acrobat 8.

 

 Right click - save embeded file to disk
 you can also use pdftk, se my previous messege in this thread.

 Robert


 
   



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-07 Thread Stochastix

I have a similar but slightly different request.
When I have a plot in sage, say of a function x- sin(x), I would like
to be able to do something like what is explained in

http://www.texample.net/tikz/examples/gnuplot-basics/

for gnuplot and pgf. This means, extracting the relevant numerical
values and leaving pgf deal with axis, ticks, grid, captions and
additional stuff in order to keep the same fonts as in LaTeX for both
the text and the pictures.

Any idea ?


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-07 Thread William Stein

On Sat, Nov 7, 2009 at 4:40 AM, Stochastix
laurent.decreusef...@gmail.com wrote:

 I have a similar but slightly different request.
 When I have a plot in sage, say of a function x- sin(x), I would like
 to be able to do something like what is explained in

 http://www.texample.net/tikz/examples/gnuplot-basics/

 for gnuplot and pgf. This means, extracting the relevant numerical
 values and leaving pgf deal with axis, ticks, grid, captions and
 additional stuff in order to keep the same fonts as in LaTeX for both
 the text and the pictures.

 Any idea ?

You can easily extract the relevant numerical values for all elements
of plots.  E.g.,

sage:  L = list(plot(sin)[0])

Another example:

sage: a = plot(sin) + plot(cos)
sage: a[0]
Line defined by 200 points
sage: a[1]
Line defined by 200 points
sage: list(a[1])[:10]

[(-1.0, 0.54030230586813977),
 (-0.98921646193235457, 0.54934475026523821),
 (-0.97881737105892419, 0.55800432723415849),
 (-0.96672470607055161, 0.567998237362355),
 (-0.95509177118254784, 0.57753384135311991),
 (-0.94833678316216885, 0.58303517065191224),
 (-0.94399062303568926, 0.58656067742426055),
 (-0.93148561011253583, 0.59664242831390957),
 (-0.92443618000428662, 0.60228477505404343),
 (-0.90878687891761545, 0.61470306127180685)]

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-07 Thread Jason Grout

Stochastix wrote:
 I have a similar but slightly different request.
 When I have a plot in sage, say of a function x- sin(x), I would like
 to be able to do something like what is explained in
 
 http://www.texample.net/tikz/examples/gnuplot-basics/
 
 for gnuplot and pgf. This means, extracting the relevant numerical
 values and leaving pgf deal with axis, ticks, grid, captions and
 additional stuff in order to keep the same fonts as in LaTeX for both
 the text and the pictures.
 
 Any idea ?


In addition to what William said, I think we ought to eventually support 
pgf (either through matplotlib or on our own).  This would be very handy 
in sagetex, for example.

Note that we already use pgf to draw graphs (vertex/line things) in latex.

There has been interest in a pgf backend to matplotlib (what we use to 
actually draw 2d graphics most of the time): 
http://www.mailinglistarchive.com/html/matplotlib-us...@lists.sourceforge.net/2009-08/msg00358.html

I played with making a pgf backend to matplotlib once, but ran out of 
time to experiment with it.

Jason



-- 
Jason Grout


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-06 Thread ma...@mendelu.cz



On 6 lis, 16:11, Jason Grout jason-s...@creativetrax.com wrote:

 Sure, I suppose, if you want to do it by hand.  We were trying to make
 it so that you just uploaded the pdf to the sage notebook.

 Jason

Ah, so the problem is that you want not to install pdftk and all its
dependencies on each Sage server. Right? Since otherwise I guess that
unpacking sws could be done automatically.

Robert
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-02 Thread Stan Schymanski

Dear Wilfried,

The tutorial looks great! How did you do the numbered head lines and the 
index? Is the sage worksheet itself published somewhere?

Cheers
Stan

Wilfried_Huss wrote:

 On 29 Okt., 12:44, ma...@mendelu.cz ma...@mendelu.cz wrote:
   
 Hello all, the conversion into PDF has been discussed several times
 here.

 One option is to print into a PDF file. This is another possibility:

 I wrote for myself a simple converter from Sage worksheets to PDF via
 PDF LaTeX
 

 Great, this is exactly what I need.

   
 You can see the outputs in the bulletted list 
 athttp://user.mendelu.cz/marik/sage/
 , for examplehttp://user.mendelu.cz/marik/sage/dr.pdf

 The initial version of the script is 
 athttp://user.mendelu.cz/marik/sage/sage2tex
 and is neither cleanly written nor clever too much, but still better
 than get a wire into your eye - as we say in Czech :)

 For whom is this topic worth

 Feel free to use it or modify as you need.
 

 I have modified the skript a little bit. It now first builds a list of
 text-, input- and output
 cells, and then converts each sell to latex. This makes things much
 easier. I also
 added syntax highlighting for python, html and latex input cells, and
 if the output is not
 a tex formula it is put into a verbatim environment.

 The HTML-LaTeX conversion is still done by a bunch of regular
 expressions, so this
 will need some improvements. But it already works very well.

 You can find the new version of the script at:
http://www.math.tugraz.at/~huss/sage/sws2tex.py

 And here are example outputs:
http://www.math.tugraz.at/~huss/sage/sage_tutorium.pdf
http://www.math.tugraz.at/~huss/sage/sws2pdf_test.pdf

 Would you agree to release your initial script under the GPL or an
 other Sage compatible
 licence? I hope this can be improved to a point where it could be
 included into Sage, for
 this it needs a proper licence.

 Cheers,
 Wilfried Huss
 
   


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-01 Thread Wilfried_Huss



On 29 Okt., 12:44, ma...@mendelu.cz ma...@mendelu.cz wrote:
 Hello all, the conversion into PDF has been discussed several times
 here.

 One option is to print into a PDF file. This is another possibility:

 I wrote for myself a simple converter from Sage worksheets to PDF via
 PDF LaTeX

Great, this is exactly what I need.

 You can see the outputs in the bulletted list 
 athttp://user.mendelu.cz/marik/sage/
 , for examplehttp://user.mendelu.cz/marik/sage/dr.pdf

 The initial version of the script is 
 athttp://user.mendelu.cz/marik/sage/sage2tex
 and is neither cleanly written nor clever too much, but still better
 than get a wire into your eye - as we say in Czech :)

 For whom is this topic worth

 Feel free to use it or modify as you need.

I have modified the skript a little bit. It now first builds a list of
text-, input- and output
cells, and then converts each sell to latex. This makes things much
easier. I also
added syntax highlighting for python, html and latex input cells, and
if the output is not
a tex formula it is put into a verbatim environment.

The HTML-LaTeX conversion is still done by a bunch of regular
expressions, so this
will need some improvements. But it already works very well.

You can find the new version of the script at:
   http://www.math.tugraz.at/~huss/sage/sws2tex.py

And here are example outputs:
   http://www.math.tugraz.at/~huss/sage/sage_tutorium.pdf
   http://www.math.tugraz.at/~huss/sage/sws2pdf_test.pdf

Would you agree to release your initial script under the GPL or an
other Sage compatible
licence? I hope this can be improved to a point where it could be
included into Sage, for
this it needs a proper licence.

Cheers,
Wilfried Huss
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-01 Thread ma...@mendelu.cz



On 1 lis, 13:49, Wilfried_Huss h...@finanz.math.tugraz.at wrote:
 On 29 Okt., 12:44, ma...@mendelu.cz ma...@mendelu.cz wrote:

  Hello all, the conversion into PDF has been discussed several times
  here.

  One option is to print into a PDF file. This is another possibility:

  I wrote for myself a simple converter from Sage worksheets to PDF via
  PDF LaTeX

 Great, this is exactly what I need.

  You can see the outputs in the bulletted list 
  athttp://user.mendelu.cz/marik/sage/
  , for examplehttp://user.mendelu.cz/marik/sage/dr.pdf

  The initial version of the script is 
  athttp://user.mendelu.cz/marik/sage/sage2tex
  and is neither cleanly written nor clever too much, but still better
  than get a wire into your eye - as we say in Czech :)

  For whom is this topic worth

  Feel free to use it or modify as you need.

 I have modified the skript a little bit.


Great, I have seen that you improved it a lot! Thanks.

I have two another improvements (and changed the script at
http://user.mendelu.cz/marik/sage/sage2tex )

First:

The following lines can be used to process tables created by
html.table command, see the file http://user.mendelu.cz/marik/sage/integral.pdf

obsah=string.replace(obsah,table class=\table_form\,{\
\offinterlineskip\\halign{\\vrule \\vrule width 0 pt height 14pt depth
5pt # \\vrule  # \\cr\\noalign{\\hrule})

obsah=string.replace(obsah,tbody,%)
obsah=string.replace(obsah,/tbody,%)
obsah=string.replace(obsah,/table,\\noalign{\\hrule}}})
obsah=string.replace(obsah,tr,\\global\\def\\optcr{\\vskip 2
pt\\hrule})
obsah=string.replace(obsah,tr class =\row-a\,\\global\\let\
\optcr\\relax{})
obsah=string.replace(obsah,tr class =\row-b\,\\global\\let\
\optcr\\relax{})
obsah=string.replace(obsah,/tr,\\cr\\noalign{\\hrule\
\optcr})
obsah=string.replace(obsah,th,\\quad\\textbf{)
obsah=string.replace(obsah,/th,}  )
obsah=string.replace(obsah,td,\\quad )
obsah=string.replace(obsah,/td,  )


Second:  TeX does not understand \textcolor[HTML]{ff}{stuff}. So
these lines convert into \textcolor[HTML]{FF}{stuff} (replacement
for previous version of this regexp substitution)

regular=re.compile(rspan style=\color: #(.*?);\)
obsah=regular.sub(lambda x: \\textcolor[HTML]{+x.group(1).upper()
+}{,obsah)



 You can find the new version of the script at:
    http://www.math.tugraz.at/~huss/sage/sws2tex.py

 And here are example outputs:
    http://www.math.tugraz.at/~huss/sage/sage_tutorium.pdf
    http://www.math.tugraz.at/~huss/sage/sws2pdf_test.pdf

 Would you agree to release your initial script under the GPL or an
 other Sage compatible
 licence? I hope this can be improved to a point where it could be
 included into Sage, for
 this it needs a proper licence.

I am O.K. with any free licence, GNU GPL,  Creative Commons or any
other.

In fact, the script was so simple that I was not thinking about any
licence.

I have no skills in programing in Python or any other object oriented
langugae and you cannot expect, that I can help to improve it into a
form which could be used for sufficiently big set of sage worksheets,
including complicated html, 3D graphics, included external pictures
and some other things.

Would you like to work a bit deeper on conversion between Sage and
TeX? If yes, then everything is up to you and from my point of view it
is sufficient to state somewhere, that the initial version was based
on the work of Robert Marik.

Thank you very much
Robert


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: convertor Sage - TeX - PDF

2009-11-01 Thread ma...@mendelu.cz



On 1 lis, 15:08, ma...@mendelu.cz ma...@mendelu.cz wrote:

 I have two another improvements (and changed the script at 
 http://user.mendelu.cz/marik/sage/sage2tex)


btw: another improvement in current http://user.mendelu.cz/marik/sage/sage2tex
(from October 30) are lines

lines 46-48
worksheet=open(sage_worksheet/worksheet.txt,'r')
title = worksheet.readline()
worksheet.close()

lines 184-190 from TeX preamble:

\usepackage{eso-pic}
\definecolor{mygreen}{RGB}{10,80,40}

\AddToShipoutPicture{\hbox to \paperwidth{\color{mygreen}\vrule
width 0.5em height\paperheight
\raise 2pt\hbox to \paperwidth{\tiny\hss\color{mygreen}\textrm {Robert
Ma\v{r}\'{\i}k}: \titlename \quad \hss Sage worksheet converted by
\href{http://user.mendelu.cz/marik/sage/sage2tex}{\texttt{sage2tex}}
\qquad}}}%

and  line 206
+\\def\\titlename{+do_substitutions(title)+


this is used to write name of the author and name of the worksheet in
bottom line.

The name of the author is hardwired in my version, however it could be
perhaps passed from command line or config file.

I am thinking also on possibility how to translate the stuff D
[0,0]\left(y\right) into y''. I think that the simplest solution is to
allow users custom substitutions specified from command line or from
config file. And I think that there is a trac which will fix this
notation.


Questions to more experienced Sage users and developers:
--

when exporting sws file and unpacking, I do not understand the
following

1. what is the difference between sage_workseet/worksheet.html and
sage_workseet/worksheet.txt  ? (neglecting the ffirst two lines, the
rest is identical in my notebooks)

2. My worksheet.html looks like this

{{{id=1|
x,y=var('x y')
///
}}}

{{{id=2|
plot(sin(x),(x,0,3))
///
htmlfont color='black'img src='cell://sage0.png'/font/html
}}}

{{{id=3|
plot(sin(x),(x,0,6),filename=sage0.pdf)
///
htmlfont color='black'img src='cell://sage0.pdf'/font/html
}}}

{{{id=4|
plot3d(x^2-y^2,(x,-1,1),(y,-1,1),viewer='tachyon')
///
}}}

{{{id=5|

///
}}}

Why is line like htmlfont color='black'img src='cell://
sage0.png'/font/html missing in the output for cell id=4. The
file with the picture is in the directory and the picture is in the
notebook - exactly like for output of 2d plot in cell id=2. Is there
any reason to skip it, or is it a bug?

Thank you.
Robert




--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---