Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've created an extended version of the script given by Thorsten and posted it on GitHub. This way I will keep it updated were I to make changes or receive suggestions: https://github.com/louisgag/sagemath-scripts/blob/master/sageToLatex.sage

LATEX PACKAGES REQUIRED:

*) add the following two lines to the header of you main Latex file if theses packages are not already declared:

\usepackage{esdiff} % for non-italic derivatives

\usepackage{breqn} % automatic linebreaks for eqns

INSTRUCTIONS:

1) paste the whole sageToLatex.sage file somewhere near the beginning of your worksheet and uncomment the following line to set the boolean printArticle as such:

printArticle = bool(1) # enable if want to print the text and equations for the article

2) in your document, include, where desired, the following string additions:

if (printArticle):
   latexPrint += 'YOUR TEXT,' + get_expression('derivative(x/b + 5 + sqrt(3/b),x)', isEqn=bool(1))

3) at the end of your document create the Latex file that you can then include (ex: \input{myEqns.tex}) in your master Latex document:

if (printArticle):
    fLATEX=open('myEqns.tex','w')
    fLATEX.write(latexPrint)
    fLATEX.close()

I've created an extended version of the script given by Thorsten and posted it on GitHub. This way I will keep it updated were I to make changes or receive suggestions: https://github.com/louisgag/sagemath-scripts/blob/master/sageToLatex.sagesageToLatex.sage

LATEX PACKAGES REQUIRED:

*) add the following two lines to the header of you main Latex file if theses packages are not already declared:

\usepackage{esdiff} % for non-italic derivatives

\usepackage{breqn} % automatic linebreaks for eqns

INSTRUCTIONS:

1) paste the whole sageToLatex.sage file somewhere near the beginning of your worksheet and uncomment the following line to set the boolean printArticle as such:

printArticle = bool(1) # enable if want to print the text and equations for the article

2) in your document, include, where desired, the following string additions:

if (printArticle):
   latexPrint += 'YOUR TEXT,' + get_expression('derivative(x/b + 5 + sqrt(3/b),x)', isEqn=bool(1))

3) at the end of your document create the Latex file that you can then include (ex: \input{myEqns.tex}) in your master Latex document:

if (printArticle):
    fLATEX=open('myEqns.tex','w')
    fLATEX.write(latexPrint)
    fLATEX.close()