Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Printing latex

I am using sage and would like to implement a function that prints a variable in latex, so I can copy and paste it directly into my latex file. However I am unsure how to do this. This is what I have attempted:

def printlatex(a):
    return '$', latex(a), '$'
a = 1*2
printlatex(a)

This returns ('$', 2, '$')

How would I implement the function so it returns $2$

Printing latex

I am using sage and would like to implement a function that prints a variable in latex, so I can copy and paste it directly into my latex file. However I am unsure how to do this. This is what I have attempted:

def printlatex(a):
    return '$', latex(a), '$'
a = 1*2
printlatex(a)

This returns the tuple ('$', 2, '$'), which I don't want.

How would I implement the function so it returns $2$