# Revision history [back]

Thanks!

I have now changed several things in the sws2tex.py file including disabling syntax highlighting.

It is practical in the notebook to be able to use %hide and then %latex in the second line or only %latex, and then only have the pure latex code included in the tex file without adding the input cell with latex code in a verbatim environment. I achieve this with sws2tex by changing the following in the, class InputCell(Cell):

def _detect_language(self):
first_line = self.text.splitlines()[0]
second_line = self.text.splitlines()[1]
if first_line == '%latex':
self.language = 'latex'
elif second_line == '%latex':
self.language = 'latex'
...


and

def latex(self):
if options.hide:
first_line = self.text.splitlines()[0]
if first_line == '%hide':
return ""
if self.language == 'latex':
return ""
...


Another thing for people having problems with special letters like æ, å or å in danish: One solution is to add the following as the first line in html2latex.py:

# -*- coding: utf-8 -*-


and the following to convert the letters from the html:

entities = {
...
"aelig": 'æ',
"oslash": 'ø',
"aring": 'å',
"AElig": 'Æ',
"Oslash": 'Ø',
"Aring": 'Å'


With these changes the sage notebook becomes a near complete math/report environment for me. sws2tex makes it possible to produce very good paper print of your work done in the notebook, which (in my opinion) is not the case with the existing print function with jsMath directly from the notebook.

So thanks for sws2tex and keep up the good work! :-)

Thanks!

I have now changed several things in the sws2tex.py file including disabling syntax highlighting.

It is practical in the notebook to be able to use %hide and then %latex in the second line or only %latex, and then only have the pure latex code included in the tex file without adding the input cell with latex code in a verbatim environment. I achieve this with sws2tex by changing the following in the, class InputCell(Cell):

def _detect_language(self):
first_line = self.text.splitlines()[0]
second_line = self.text.splitlines()[1]
if first_line == '%latex':
self.language = 'latex'
elif second_line == '%latex':
self.language = 'latex'
...


and

def latex(self):
if options.hide:
first_line = self.text.splitlines()[0]
if first_line == '%hide':
return ""
if self.language == 'latex':
return ""
...


Another thing for people having problems with special letters like æ, å or å in danish: One solution is to add the following as the first line in html2latex.py:

# -*- coding: utf-8 -*-


and the following to convert the letters from the html:html to utf-8:

entities = {
...
"aelig": 'æ',
"oslash": 'ø',
"aring": 'å',
"AElig": 'Æ',
"Oslash": 'Ø',
"Aring": 'Å'


With these changes the sage notebook becomes a near complete math/report environment for me. sws2tex makes it possible to produce very good paper print of your work done in the notebook, which (in my opinion) is not the case with the existing print function with jsMath directly from the notebook.

So thanks for sws2tex and keep up the good work! :-)

Thanks!

I have now changed several things in the sws2tex.py file including disabling syntax highlighting.

It is practical in the notebook to be able to use %hide and then %latex in the second line or only %latex, and then only have the pure latex code included in the tex file without adding the input cell with latex code in a verbatim environment. I achieve this with sws2tex by changing the following in the, class InputCell(Cell):

def _detect_language(self):
first_line = self.text.splitlines()[0]
second_line = self.text.splitlines()[1]
if first_line == '%latex':
self.language = 'latex'
elif second_line == '%latex':
self.language = 'latex'
...


and

def latex(self):
if options.hide:
first_line = self.text.splitlines()[0]
if first_line == '%hide':
return ""
if self.language == 'latex':
return ""
...


Another thing for people having problems with special letters like æ, å ø or å in danish: One solution is to add the following as the first line in html2latex.py:

# -*- coding: utf-8 -*-


and the following to convert the letters from the html to utf-8:

entities = {
...
"aelig": 'æ',
"oslash": 'ø',
"aring": 'å',
"AElig": 'Æ',
"Oslash": 'Ø',
"Aring": 'Å'


With these changes the sage notebook becomes a near complete math/report environment for me. sws2tex makes it possible to produce very good paper print of your work done in the notebook, which (in my opinion) is not the case with the existing print function with jsMath directly from the notebook.

So thanks for sws2tex and keep up the good work! :-)

Thanks!

I have now changed several things in the sws2tex.py file including disabling syntax highlighting.

It is practical in the notebook to be able to use %hide and then %latex in the second line or only %latex, and then only have the pure latex code included in the tex file without adding the input cell with latex code in a verbatim environment. I achieve this with sws2tex by changing the following in the, class InputCell(Cell):

def _detect_language(self):
first_line = self.text.splitlines()[0]
try:
second_line = self.text.splitlines()[1]
self.text.splitlines()[1]
except:
second_line = ""
if first_line == '%latex':
self.language = 'latex'
elif second_line == '%latex':
self.language = 'latex'
...


and

def latex(self):
if options.hide:
first_line = self.text.splitlines()[0]
if first_line == '%hide':
return ""
if self.language == 'latex':
return ""
...


Another thing for people having problems with special letters like æ, ø or å in danish: One solution is to add the following as the first line in html2latex.py:

# -*- coding: utf-8 -*-


and the following to convert the letters from the html to utf-8:

entities = {
...
"aelig": 'æ',
"oslash": 'ø',
"aring": 'å',
"AElig": 'Æ',
"Oslash": 'Ø',
"Aring": 'Å'


With these changes the sage notebook becomes a near complete math/report environment for me. sws2tex makes it possible to produce very good paper print of your work done in the notebook, which (in my opinion) is not the case with the existing print function with jsMath directly from the notebook.

So thanks for sws2tex and keep up the good work! :-)