-
Notifications
You must be signed in to change notification settings - Fork 156
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
Customize variable Latex display #1385
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1385 +/- ##
===========================================
+ Coverage 3.95% 79.72% +75.76%
===========================================
Files 51 51
Lines 4824 4917 +93
===========================================
+ Hits 191 3920 +3729
+ Misses 4633 997 -3636 ☔ View full report in Codecov by Sentry. |
@jpfairbanks does something like this cover your needs? |
This is definitely an improvement to allow specifying custom latex for printing symbols. The other two issues are:
|
Is there a reason not to use the https://juliapy.github.io/SymPy.jl/dev/reference/#SymPy.@syms-Tuple syntax where one can specify |
I am open to suggestions on how to handle namespacing in this PR. Now it applies any custom Latex expression only to the non-namespaced part of a variable name. This is compatible with MTK without modifications to MTK, so I think it is a simple first step. An alternative could be for Symbolics to not make this distinction, but simply apply the custom Latex expression to the whole variable name. Maybe that is more natural as a pure Symbolics modification, but MTK would require changes to preserve the custom Latex expression when namespaces are prepended to variables. This "joining process" could be a natural place for MTK systems to hook into with a custom Latex expression for their namespace. Maybe it could work like @variables x0 [latex = "x_0"]
@named sys = NonlinearSystem([x0 ~ 0]; latex = raw"\mathtt{custom}")
latexify(sys.x0) # should display as \mathtt{custom}.x_0 and one could pass
I think this requires more substantial modifications to the Latex pipeline. But I don't think the changes in this PR would conflict with that in the future.
I went with |
I propose this to (optionally) let users customize how variables are displayed in Latex.
\mathtt
-ed multi-letter variables).@variables x0 [latex = "x_0"]
, the default rendering is overridden.\mathtt
to be similar to the default. This is to make it compatible with hierarchical MTK models.Example: