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

Allow named units to have a LaTeX representation (WIP) #1069

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

rieder
Copy link
Member

@rieder rieder commented Sep 3, 2024

No description provided.

@rieder rieder requested a review from a team as a code owner September 3, 2024 14:15
@rieder
Copy link
Member Author

rieder commented Sep 3, 2024

Meant to allow for nice LaTeX representations like R_{\odot} instead of RSun

@rieder
Copy link
Member Author

rieder commented Sep 4, 2024

@spzwart @LourensVeen I'd like your thoughts on this.
The aim is to allow us to use this in e.g. axes for plots, where using "RSun" just looks stupid and manually putting in the unit leads to potential unit errors (I just found one in the book).

@LourensVeen
Copy link
Collaborator

Sounds like a good idea. The one thing that comes to mind is that these symbols are probably in Unicode, and that we could do that. But I'm not sure how well Unicode works in LaTeX, although it will probably work in plotting software.

Maybe something to test, it's nicer and more modern. On the other hand, LaTeX is still very widely used in science, so if Unicode doesn't solve the problem then it'll be good to have for sure.

@rieder
Copy link
Member Author

rieder commented Sep 11, 2024

Unicode can work (☉ for \odot etc), but some older LaTeX implementations don't accept unicode. Also, unicode doesn't do sub/superscript etc.
We could easily also add a unicode representation, where we write L☉ instead of LSun for example, but I think that wouldn't be as directly beneficial (matplotlib parses LaTeX, so that immediately works).

@rieder
Copy link
Member Author

rieder commented Oct 30, 2024

Ready to merge I think.

Copy link
Collaborator

@LourensVeen LourensVeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice and simple, doesn't hurt anything, and can be expanded over time with more LaTeX as people want it or if someone gets bored 😄.

@rieder rieder merged commit 8f44615 into amusecode:main Oct 31, 2024
5 of 6 checks passed
@rieder rieder deleted the feature/latex_units branch October 31, 2024 15:20
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

Successfully merging this pull request may close these issues.

2 participants