Following this lead, I tried this in a Github README.md:
<span style="vertical-align: baseline; position: relative;top: -0.5em;>text in superscript</span>
Does not work, the text appears as normal. Help?
In LaTeX you indicate superscript with the ^ and subscript with _ . Curly braces ( { and } ) can be used to group characters. You also need to escape spaces with a backslash.
Subscripts and Superscripts To indicate a subscript, use the underscore _ character. To indicate a superscript, use a single caret character ^ . Note: this can be confusing, because the R Markdown language delimits superscripts with two carets.
GitHub Flavored Markdown, often shortened as GFM, is the dialect of Markdown that is currently supported for user content on GitHub.com and GitHub Enterprise. This formal specification, based on the CommonMark Spec, defines the syntax and semantics of this dialect. GFM is a strict superset of CommonMark.
Use the <sup></sup>
tag (<sub></sub>
is the equivalent for subscripts). See this gist for an example.
<sup>
and <sub>
tags work and are your only good solution for arbitrary text. Other solutions include:
Unicode
If the superscript (or subscript) you need is of a mathematical nature, Unicode may well have you covered.
I've compiled a list of all the Unicode super and subscript characters I could identify in this gist. Some of the more common/useful ones are:
⁰
SUPERSCRIPT ZERO (U+2070)¹
SUPERSCRIPT ONE (U+00B9)²
SUPERSCRIPT TWO (U+00B2)³
SUPERSCRIPT THREE (U+00B3)ⁿ
SUPERSCRIPT LATIN SMALL LETTER N (U+207F)People also often reach for <sup>
and <sub>
tags in an attempt to render specific symbols like these:
™
TRADE MARK SIGN (U+2122)®
REGISTERED SIGN (U+00AE)℠
SERVICE MARK (U+2120)Assuming your editor supports Unicode, you can copy and paste the characters above directly into your document.
Alternatively, you could use the hex values above in an HTML character escape. Eg, ²
instead of ²
. This works with GitHub (and should work anywhere else your Markdown is rendered to HTML) but is less readable when presented as raw text/Markdown.
Images
If your requirements are especially unusual, you can always just inline an image. The GitHub supported syntax is:
![Alt text goes here, if you'd like](path/to/image.png)
You can use a full path (eg. starting with https://
or http://
) but it's often easier to use a relative path, which will load the image from the repo, relative to the Markdown document.
If you happen to know LaTeX (or want to learn it) you could do just about any text manipulation imaginable and render it to an image. Sites like Quicklatex make this quite easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With