Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting subscripts and superscripts #895

Closed
SharonKartika opened this issue Oct 6, 2021 · 2 comments
Closed

Inserting subscripts and superscripts #895

SharonKartika opened this issue Oct 6, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@SharonKartika
Copy link

Currently superscripts can be inserted either using LaTeX blocks, or by manually inserting <sub> and <sup> HTML elements. Are there any alternative (easier) methods by which I can achieve this?
For instance, Typora uses x^2^ for superscripts and x~2~ for subscripts in markdown files. How would I have these dispaly as superscripts and subscripts in generated webpages?
Thanks.

@tlienart
Copy link
Owner

tlienart commented Oct 6, 2021

Hello @SharonKartika

Yes you're right and no there are no alternative methods. The way I'd do it currently is one of the following:

  • inserting raw html as you said
  • creating a \sub and \sup command which insert raw html (e.g. \newcommand{\sup}[1]{~~~<sup>~~~#1~~~</sup>~~~})
  • writing the subscript within a KateX block (e.g. $\text{foo}^\text{bar}$ or if it's just maths $x^2$ or x$^2$ if you don't want a different font)

It is possible to extend the parser but in that case I would prefer the LaTeX style abc^{def}. Though in LaTeX they allow this only in math mode which would amount to doing x$^2$. Allowing this in non math mode is a little tricky because the natural symbol for subscript is _ but there's ambiguity between that and emphasis i.e. x_2_3 at the moment will be x<em>2</em>3 and would be ambiguous with x<sub>2<sub>3</sub></sub>.

Lastly, could you give me a couple of examples of what you'd like? one thing is that if you're always doing this for maths, then doing it within a $..$ is probably better; or if you're always using the same combination like name<sup>TM</sup> then it's probably easier to just create a command for that like \tm. Anyway if you can think of a common use case where this would be helpful for you there may be other ways that might work nicely and wouldn't require a change to the parser 😄

@tlienart tlienart added the enhancement New feature or request label Oct 6, 2021
@SharonKartika
Copy link
Author

Thanks.
I think I'll use \sub and \sup commands as you mentioned.
My most common use case is for writing chemical compounds and chemical reactions. In the editor I use (Typora) I can write, O~2~ for a subscripted 2. I could use $O_2$, but that would change the font of O, and O$_2$ similarly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants