Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

how to write the leading superscript and subscript in Markdown syntax?

Writer Emily Wong

image: description of a coordinate transformation

enter image description here

I wonder how to write the leading superscript and subscript shown in the picture in Markdown syntax?

1

4 Answers

Try using <sup></sup> (<sub></sub>), as suggested in this other SO post(but indeed, the solution depends on the way it's rendered)

0

Pandoc's flavor of markdown supports a math extension:

Anything between two $ characters will be treated as TeX math.

The following string returns your desired output: $_B^AR$

Pandoc's markdown also has a superscript and subscript extension:

Superscripts may be written by surrounding the superscripted text by ^ characters; subscripts may be written by surrounding the subscripted text by ~ characters. Thus, for example,

H~2~O is a liquid. 2^10^ is 1024.

But, as far as I know, there is no support for your request, a character that combines both a subscript and a superscript.

What are you doing? Are you using Github or compiling a markdown file to pdf? Or using Jekyll? In any case you can display that (and any other math symbol) using latex inside markdown.

  • If you are using Github: No idea how to do it
  • If you are blogging using Jekyll: Use MathJax
  • If you want to compile the markdown file to pdf: Use pandoc! just compile the file using: pandoc test.md -o test.pdf

In latex you can write leading superscripts with this code:

\documentclass{article}
\begin{document}
\[
^gp = {}^gR^l_l+{}^go_l
\]
\end{document}

as explained here.

There are several ways of adding superscript and subscript to a Markdown doc:

  • Use embedded HTML, such as the <sup></sup> and <sub></sub> tags, or even something like <span> if you want more control.
  • Use Unicode for some things, like numbers (¹, ²) and some symbols (, ). See this list of characters.
  • Embed an image with the exact rendering you want using the ![alt text](image src) syntax (like this).
  • Embed LaTeX directly in the Markdown doc using $ or $$ blocks. Eg. Water, also known as H$_2$O. See the raw version of this Gist.

The first three options should work most places that use Markdown. LaTeX support isn't as widespread. For example Pandoc and GitHub now support it but StackOverflow and many other renderers don't.

I've described these options in more detail in my answer to this related question.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy