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

Is there any way to represent atoms and atomic masses? #27

Open
javiermanzano opened this issue Aug 30, 2022 · 2 comments
Open

Is there any way to represent atoms and atomic masses? #27

javiermanzano opened this issue Aug 30, 2022 · 2 comments

Comments

@javiermanzano
Copy link

Hi, the library is totally incredible, but I've found that I could not represent something like this

image

I've used like this and it seems to work with latex, but not with this project

https://tex.stackexchange.com/questions/25975/how-to-typeset-indices-before-a-symbol

This is an atom

${}^1_2X^3_4$

image

Any help will be appreciated.

Thanks!

@kgram
Copy link
Owner

kgram commented Aug 30, 2022

@javiermanzano Hm, currently there is not. You can make indices using underscores (x_y) and exponentiation using (x^y), but no way to overlay them, and no way to write them before the variable name.

I'm not opposed to adding it, though, only I'd need to understand the syntax a little better, and need to come up with some kind of plain-text version for the parser to understand. The TeX version strikes me as pretty bad and hacky (which is kinda why I avoided TeX when I started this project). As I read it, it's some kind of empty element with the top/bottom index and then the variable with the second pair. This wouldn't work here, since both sets of coordinates should be part of the variable, and the 1 and 3 in your example don't actually have anything to do with exponents. TeX can get away with nonsense notation like that, just like it can have adjacent operators and stuff like that, since there is no evaluation or manipulation, but it breaks in this model.

I'll have to think a bit about it. My first though is some kind of variation of indexes in variables. Currently, multiple indexes are treated as indices-of-indices, but this was mostly to do something ,it's not my impression that this is particularly common (I'd probably have to make sure before breaking everything though). Then, the indices would start with bottom-right and move counter-clockwise with _ as separator. This would mean your example would become X_4_3_1_2, and your first image U___235_92 (with 3 _s indicates that the two right indices are blank). It wouldn't handle positive/negative ion signs though.

My second thought is a special-case function with a custom renderer (such as sqrt and sum already has). Maybe ch(X, 1, 2, 3, 4) and ch(U, 235, 92). Ions could be ch_p/ch_n (the thorium example you linked would be ch_p(T, 227, 90)). That would make it a renderer-only change, which would be far easier to implement.

It is also possible that this could work better as a separate package. It's not like these kinds of notations are mixed with normal math notation in any way, so maybe a similar package for chemical notation would be the best solution. Then it could have a proper parser, so you could just write something like 2C+15H+3U{235,92}+T{227,90+}->15H2O... well, assuming a very weird reaction, but you get the gist. My problem here is again ignorance about requirements, and probably time to actually implement it.

If you have any suggestions or thoughts that would be highly appreciated.

@javiermanzano
Copy link
Author

javiermanzano commented Aug 31, 2022

hi @kgram

Thank you for your quick response. I think first 2 options look incredible great :)

I could be helping you if needed. I don't mind creating a PR to see if could make it work. Which one do you thing it's the best option? I feel that first one seems to be the most easy one for me.

If you could give me some guidance I could take a look and create a PR if that works for you.

The requirements in this case are pretty ambiguous because we need to display a lot of different symbols. We are collaborating with a students marketplace for lessons content, so there will be different topics, from physics to chemistry.

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

No branches or pull requests

2 participants