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

Display Function Cannot Combine Vector Arrows with Subscripts In Jupyter Notebooks #26549

Open
NSC9 opened this issue Apr 28, 2024 · 1 comment

Comments

@NSC9
Copy link

NSC9 commented Apr 28, 2024

I am using Sympy v1.9

Screenshot from 2024-04-27 20-01-39

display(Symbol('v\u20D7'))
v0,v0x=symbols('v_0 v_0x')
display(v0,v0x)
display(Symbol(f'{v0}\u20D7'))

As one can see, splicing a subscripted symbol into another symbol to add a vector on top simply puts the arrow above the subscripted zero.

@sylee957
Copy link
Member

sylee957 commented Apr 28, 2024

I'm not familiar about the tricks with \u20D7, however, it looks you are using the unicode combining characters. https://en.wikipedia.org/wiki/Combining_character

However, I don't think that the combining character is compatible with every LaTeX as you expected, beyond basic cases,
and I don't think that this is any issue with SymPy, because it happens before SymPy. v_0\u20D7 is interpreted as 3 glyphs, v, _, 0\u20D7.

Obviously, there are more advanced tricks with unicode that may work around this, and you may combine with unicode subscripts, such as Symbol('v\u20D7\u2080') for workaround, however, that may not be desirable because you may face much more confusing compatibility issues with LaTeX later.

I may suggest to wrap symbol names inside LaTeX control sequences like \overrightarrow, such as
Symbol('\overrightarrow{v_0}') and it should display correctly as $\overrightarrow{v_0}$

I also generally suggest to avoid tricks with unicode, and try to find LaTeX control sequences that does same work. I rarely use unicode combining characters, or unicode subscripts or superscripts, because they are not sufficient for many math formula.

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