簡體   English   中英

Jupyter Notebook iPython中的Latex

[英]Latex in Jupyter Notebook iPython

我在 jupyter notebook 中有一個 python 項目,我想用 latex 顯示最終的 output。

x = 5
print("The number you have inputted is ", complex(x, y), " ^ 1/", n, sep = '')

我希望使用 latex 對其進行格式化:

輸入要格式化


我閱讀了一堆論壇,但分數不適用於 2digit 數字

n=10
from IPython.display import display, Markdown
display(Markdown(rf"""$ { complex(x, y) } ^ \frac{1}{n} $"""))

我能得到的最好的:

輸入要格式化


任何建議都會非常有幫助:)

您可以使用 Latex 直接將其顯示為Latex 要將大括號保留為 Latex 的文字,您需要使用 double {{ }} 否則\frac不會獲得完整的操作數。

from IPython.display import display, Latex

x=1
y=0
n=10

display(Latex(rf'$ { complex(x, y) } ^\frac{{1}}{{{n}}}$'))

Jupyterlab 中的 Output: 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM