Subscript and Superscript

Subscript and superscript text is common in mathematical expressions and chemical formulas. When rendered, the size of subscripted and superscripted text is reduced. Subscripted text is placed at the baseline and superscripted text above the baseline. The size and precise placement of the text depends on the font and other stylesheet parameters applied to the converted document.

Subscript and superscript syntax

Text is rendered as subscript (below the baseline) when you enclose it in a pair of tildes (~). Text is rendered as superscript (above the baseline) when you enclose it in a pair of carets (^)

Superscript and subscript have unique boundary constraints in AsciiDoc that are neither constrained nor unconstrained. Rather, they are unconstrained with the key restriction that the text must be continuous. (It may not contain spaces). This restriction is in place to avoid unexpected behavior where ~ and ^ have meaning in other contexts. It’s a tradeoff to have a more predictable syntax.

Subscript

One tilde (~) on either side of a continuous run of text makes it subscript.

Superscript

One caret (^) on either side of a continuous run of text makes it superscript.

Example 1. Subscript and superscript syntax
"`Well the H~2~O formula written on their whiteboard could be part
of a shopping list, but I don't think the local bodega sells
E=mc^2^,`" Lazarus replied.

The result of Example 1 is rendered below.

“Well the H2O formula written on their whiteboard could be part of a shopping list, but I don’t think the local bodega sells E=mc2,” Lazarus replied.

If you need to include spaces in the superscript or subscript text, you must use the attribute reference {sp} in place of the space character.

Example 2. Superscript syntax that contains spaces
The deepest body of water is Deep Creek Lake.^[citation{sp}needed]^

To write text that makes use of more complex variations and combinations of superscript and subscript, such as in equations and formulas, you’re encourages to use the stem block or inline macro.