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

Symbolic arrays with underscore names have broken latex representation #1288

Closed
cstjean opened this issue Sep 27, 2024 · 5 comments · Fixed by #1303
Closed

Symbolic arrays with underscore names have broken latex representation #1288

cstjean opened this issue Sep 27, 2024 · 5 comments · Fixed by #1303

Comments

@cstjean
Copy link

cstjean commented Sep 27, 2024

On Symbolics 6.13, a variable array with an underscore, like @variables A_out[1:10] has broken HTML when accessing its elements, A_out[1]

{969E8509-F341-4966-B641-5A615084198E}

Presumably the whole subscript ought to be enclosed in {}

@karlwessel
Copy link

A similiar problem happens when displaying an element of a part of a symbolic array:

using Symbolics

julia> @variables z[1:3]
1-element Vector{Symbolics.Arr{Num, 1}}:
 z[1:3]

julia> using Latexify

julia> latexify(z[1:2][1])
L"\begin{equation}
z_{\left[
\begin{array}{c}
1 \\
2 \\
\end{array}
\right]}_{1}
\end{equation}
"

Here is the latex-error for the above output: http://www.texrendr.com/?eqn=%5Cbegin%7Bequation%7D%0Az_%7B%5Cleft%5B%0A%5Cbegin%7Barray%7D%7Bc%7D%0A1%20%5C%5C%0A2%20%5C%5C%0A%5Cend%7Barray%7D%0A%5Cright%5D%7D_%7B1%7D%0A%5Cend%7Bequation%7D

When there are two subscripts one needs to clarify by curly braces which is the subscript of which.

@ChrisRackauckas
Copy link
Member

Thanks for the reports. I don't know if I'll get to this soon, but just dropping it that our recipes just tell Latexify to use subscript https://github.com/JuliaSymbolics/Symbolics.jl/blob/master/src/latexify_recipes.jl#L88 so my guess is that this can be MWE'd to be a Latexify recipe issue with repeated subscripts. I haven't gotten as far as building an example though, but that would be the next step to get an error onto Latexify which should be the root cause.

@karlwessel
Copy link

Thanks for the hint! I constructed a MWE and created an issue with Latexify.jl.

@karlwessel
Copy link

PR #1303 didn't fix my use case, but with korsbo/Latexify.jl#316 it now compiles and looks ok:

julia> latexify(z[1:2][1])
L"\begin{equation}
\left( z_{\left[
\begin{array}{c}
1 \\
2 \\
\end{array}
\right]} \right)_{1}
\end{equation}
"

Renders as

$$\left( z_{\left[ \begin{array}{c} 1 \\ 2 \\ \end{array} \right]} \right)_{1}.$$

@ChrisRackauckas
Copy link
Member

Okay, that's a reasonable representation.

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 a pull request may close this issue.

3 participants