【问题标题】:Display an astropy Quantity within a LaTeX string在 LaTeX 字符串中显示 astropy Quantity
【发布时间】:2017-04-05 01:46:02
【问题描述】:

我正在寻找一种在 IPython 笔记本中呈现 LaTeX 字符串中的 astropy 变量的方法。例如,给定一个简单的前提,

from astropy.constants import c
import astropy.units as u
from astropy import log

光速默认渲染为:

只需在 ipython 提示符下键入即可。现在,如果我想将它嵌入到字符串中怎么办?如何跳上 astropy 已经使用的相同渲染火车来打印像 'Speed limit: {}'.format(c) 这样的示例字符串?

到目前为止,我尝试过的所有内容,包括 LaTeX 格式字符串的变体,都只显示一个 ASCII 字符串作为输出:

【问题讨论】:

  • 这实际上是 stackoverflow.com/questions/13208286/… 的副本,请在此处查看接受的答案。
  • 我不同意。您链接的答案解释了如何使用 ipython 显示功能打印乳胶代码,并且不会产生可接受的输出,例如 display(Math('{}'.format(c)))。这个问题专门询问如何将 astropy.units 模块中已经存在的乳胶功能扩展到更一般的情况。

标签: python latex ipython-notebook astropy


【解决方案1】:

可能有一个更优雅的解决方案,但这有效:

【讨论】:

    猜你喜欢
    • 2020-05-25
    • 2021-12-26
    • 2020-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-19
    • 2015-09-09
    • 1970-01-01
    相关资源
    最近更新 更多