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$