Python 如何在 Jupyter Notebook 中做上标和下标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46011785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 17:24:45  来源:igfitidea点击:

How to do superscripts and subscripts in Jupyter Notebook?

pythonjupyter-notebookipython-notebookjupyterdata-science

提问by PraveenHarris

I want to to use numbers to indicate references in footnotes, so I was wondering inside of Jupyter Notebook how can I use superscripts and subscripts?

我想使用数字来表示脚注中的引用,所以我想知道在 Jupyter Notebook 内部如何使用上标和下标?

回答by James Draper

You can do this inside of a markdown cell. A markdown cell can be created by selecting a cell then pressing the esckey followed by the Mkey. You can tell when you have converted a cell to markdown when In [ ]:seen to the right of the default code cell is gone. Then you can input the following code that uses latexwith markdownto represent sub/super-scripts:

您可以在降价单元格内执行此操作。可以通过选择一个单元格,然后按esc键,然后按键来创建降价单元格M。当In [ ]:默认代码单元格右侧消失时,您可以判断何时将单元格转换为 Markdown 。然后你可以输入以下代码,使用带有markdown的latex来表示子/超级脚本:

Latex subscript:

$x_{2}$

Latex superscript:

$x^{2}$

You can find more detailed examples here.

您可以在此处找到更详细的示例。

Please comment below if you are still having difficulty.

如果您仍然遇到困难,请在下面发表评论。

回答by user9179129

<sup>superscript text </sup>also works, and might be better because latex formatting changes the whole line etc.

<sup>superscript text </sup>也可以工作,并且可能会更好,因为乳胶格式会改变整行等。

回答by brawny84

What a meta question! One needs to use Markdown to answer Markdown syntax questions. Markdown does have the <sup></sup>and <sub></sub>tags that will adjust text to super- or sub- script, respectively in the typeface of the current block. If you are using the scripts for mathematical statements like thisthe LaTeX transformation makes sense. If you are using the scripts for footnotes or perhaps for something like chemical formulas (e.g. H2O) it might be preferable to use the first method rather than LaTeX. Mixing fonts is generally not considered a good graphics/typography practice!

什么元问题!需要使用 Markdown 来回答 Markdown 语法问题。Markdown 确实有<sup></sup><sub></sub>标签,可以分别将当前块的字体中的文本调整为上标或下标。如果您使用的是脚本数学命题 这样的LaTeX的转型是有道理的。如果您将脚本用于脚注或可能用于化学式(例如 H 2O)之类的内容,则最好使用第一种方法而不是 LaTeX。混合字体通常不被认为是一个好的图形/排版实践!

回答by Giorgio

You can use HTML 'superscript '

您可以使用 HTML '上标'

http://wikimarkup.wikia.com/wiki/How_to_superscript_text

http://wikimarkup.wikia.com/wiki/How_to_superscript_text

You can also use Latex $foo^{superscript}$, but the font used to render the text will change and you might not like how it looks.

您也可以使用 Latex $foo^{superscript}$,但用于呈现文本的字体会发生变化,您可能不喜欢它的外观。