Issue
I have a python project in jupyter notebook, and I want to display the final output with latex.
x = 5
print("The number you have inputted is ", complex(x, y), " ^ 1/", n, sep = '')
I want this to be formatted using latex:
I read a bunch of forums but the fraction wasn't working for 2digit numbers
n=10
from IPython.display import display, Markdown
display(Markdown(rf"""$ { complex(x, y) } ^ \frac{1}{n} $"""))
The best I could get:
Any suggestions would be very helpful :)
Solution
You can directly display it as Latex using Latex
. To keep the curly brackets as literals for Latex you need to use double {{
}}
. Otherwise the \frac
does not obtain the full operands.
from IPython.display import display, Latex
x=1
y=0
n=10
display(Latex(rf'$ { complex(x, y) } ^\frac{{1}}{{{n}}}$'))
Answered By - jf_
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.