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

Unexpected error while parsing \boldsymbol #107

Open
fgerick opened this issue Aug 10, 2023 · 1 comment
Open

Unexpected error while parsing \boldsymbol #107

fgerick opened this issue Aug 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@fgerick
Copy link

fgerick commented Aug 10, 2023

julia> generate_tex_elements(L"\boldsymbol{\nabla}")
ERROR: TeXParseError: unexpected error while parsing
at position 12 (string index 12)
\boldsymbol{\nabla}
           ^
Stack before
[1] TeXExpr :expr


Stacktrace:
  [1] texparse(data::String; showdebug::Bool)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/parser/parser.jl:303
  [2] texparse
    @ ~/.julia/packages/MathTeXEngine/na9MW/src/parser/parser.jl:287 [inlined]
  [3] _broadcast_getindex_evalf
    @ ./broadcast.jl:683 [inlined]
  [4] _broadcast_getindex
    @ ./broadcast.jl:656 [inlined]
  [5] _getindex
    @ ./broadcast.jl:679 [inlined]
  [6] _broadcast_getindex
    @ ./broadcast.jl:655 [inlined]
  [7] getindex
    @ ./broadcast.jl:610 [inlined]
  [8] copy
    @ ./broadcast.jl:912 [inlined]
  [9] materialize
    @ ./broadcast.jl:873 [inlined]
 [10] generate_tex_elements(str::LaTeXStrings.LaTeXString, font_family::MathTeXEngine.FontFamily)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/engine/layout.jl:301
 [11] generate_tex_elements(str::LaTeXStrings.LaTeXString)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/engine/layout.jl:295
 [12] top-level scope
    @ REPL[6]:1

caused by: TeXParseError: unsupported command \boldsymbol
at position 12 (string index 12)
\boldsymbol{\nabla}
           ^
Stack before
[1] TeXExpr :expr


Stacktrace:
  [1] _end_command_builder!(stack::DataStructures.Stack{Any}, p::Int64, data::String)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/parser/parser.jl:251
  [2] macro expansion
    @ ~/.julia/packages/MathTeXEngine/na9MW/src/parser/parser.jl:274 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/Automa/5enCH/src/codegen.jl:150 [inlined]
  [4] texparse(data::String; showdebug::Bool)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/parser/parser.jl:301
  [5] texparse
    @ ~/.julia/packages/MathTeXEngine/na9MW/src/parser/parser.jl:287 [inlined]
  [6] _broadcast_getindex_evalf
    @ ./broadcast.jl:683 [inlined]
  [7] _broadcast_getindex
    @ ./broadcast.jl:656 [inlined]
  [8] _getindex
    @ ./broadcast.jl:679 [inlined]
  [9] _broadcast_getindex
    @ ./broadcast.jl:655 [inlined]
 [10] getindex
    @ ./broadcast.jl:610 [inlined]
 [11] copy
    @ ./broadcast.jl:912 [inlined]
 [12] materialize
    @ ./broadcast.jl:873 [inlined]
 [13] generate_tex_elements(str::LaTeXStrings.LaTeXString, font_family::MathTeXEngine.FontFamily)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/engine/layout.jl:301
 [14] generate_tex_elements(str::LaTeXStrings.LaTeXString)
    @ MathTeXEngine ~/.julia/packages/MathTeXEngine/na9MW/src/engine/layout.jl:295
 [15] top-level scope
    @ REPL[6]:1

I'm happy to create a PR, but I don't know where to start.

@Kolaru Kolaru added the enhancement New feature or request label Aug 12, 2023
@Kolaru
Copy link
Owner

Kolaru commented Aug 12, 2023

The \boldsymbol command is not currently supported.

It needs to be added to the parser around here (there is a bit of doc in the parser folder to explain what this does, but essentially it should be the same as for \overline)

command_to_canonical[raw"\overline"] = TeXExpr(:argument_gatherer, [:overline, 1])

Then, the logic needs to be added to the layout system in the tex_layout function. Here is the corresponding part for the \overline command.

elseif head == :overline

For \boldsymbol, we need to look at the font files to understand where and how to grab the correct bold symbol. If we are lucky it's sufficient to just get the same glyph from the bold font.

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

No branches or pull requests

2 participants