Jupyter Notebook iPython 中的乳胶

问题描述

我在 jupyter notebook 中有一个 python 项目,我想用 Latex 显示最终输出

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

我希望使用 Latex 对其进行格式化:

Input to be formatted


我阅读了很多论坛,但分数不适用于 2 位数字

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

我能得到的最好的:

Input to be formatted


任何建议都会非常有帮助:)

解决方法

您可以使用 Latex 直接将其显示为 Latex。要将大括号保留为 Latex 的文字,您需要使用双 {{ }}。否则 \frac 不会获得完整的操作数。

from IPython.display import display,Latex

x=1
y=0
n=10

display(Latex(rf'$ { complex(x,y) } ^\fracconst [likes,setLikes] = useState(0);

  useEffect( async () => {

    const query = await getDevsApi();    //This returns a collection of data I can map.
    const likes = query.map(like => like.upvotes);    //The problem  here is,it returns an array of data... How do I get individual data for each user? and set it at as the current state in the setLikes() below.

    setLikes(likes)

  },[]);

{{{n}}}$'))

Jupyterlab 中的输出: enter image description here