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

latexify does not support objects of type InlineStrings.String7 #272

Closed
a2k42 opened this issue Sep 15, 2023 · 1 comment
Closed

latexify does not support objects of type InlineStrings.String7 #272

a2k42 opened this issue Sep 15, 2023 · 1 comment

Comments

@a2k42
Copy link

a2k42 commented Sep 15, 2023

I was trying to convert a csv file to a markdown table and ran into an error whenever I had strings in my file (obviously a very common scenario)

Minimal example:

df = DataFrame(CSV.File("file.csv"))
latexify(df)

There's a discourse suggesting that you need to handle AbstractString instead of just String. The breaking change happened a couple of years ago so maybe I've missed something?

AssertionError: latexify does not support objects of type InlineStrings.String7.
var"#_latexraw#45"(::Base.Pairs{Symbol, Symbol, Tuple{Symbol}, NamedTuple{(:env,), Tuple{Symbol}}}, ::typeof(Latexify._latexraw), ::InlineStrings.String7)@latexraw.jl:109
var"#process_latexify#156"(::Base.Pairs{Symbol, Symbol, Tuple{Symbol}, NamedTuple{(:env,), Tuple{Symbol}}}, ::typeof(Latexify.process_latexify), ::InlineStrings.String7)@latexify_function.jl:49
process_latexify@latexify_function.jl:40[inlined]
var"#_latexinline#98"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Latexify._latexinline), ::InlineStrings.String7)@latexinline.jl:4
_latexinline(::InlineStrings.String7)@latexinline.jl:3
[email protected]:683[inlined]
[email protected]:656[inlined]
[email protected]:610[inlined]
copyto_nonleaf!(::Matrix{LaTeXStrings.LaTeXString}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(Latexify._latexinline), Tuple{Base.Broadcast.Extruded{Matrix{Any}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}}}, ::CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, ::CartesianIndex{2}, ::Int64)@broadcast.jl:1068
[email protected]:920[inlined]
[email protected]:873[inlined]
var"#mdtable#115"(::Bool, ::Bool, ::Vector{Symbol}, ::Vector{Any}, ::Bool, ::Nothing, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Latexify.mdtable), ::Matrix{Any})@mdtable.jl:61
var"#mdtable#1"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Latexify.mdtable), ::DataFrames.DataFrame)@DataFramesExt.jl:21
mdtable(::DataFrames.DataFrame)@DataFramesExt.jl:18
var"#process_latexify#156"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Latexify.process_latexify), ::DataFrames.DataFrame)@latexify_function.jl:49
process_latexify@latexify_function.jl:40[inlined]
var"#latexify#155"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Latexify.latexify), ::DataFrames.DataFrame)@latexify_function.jl:27
latexify(::DataFrames.DataFrame)@latexify_function.jl:25
top-level scope@Local: 3[inlined]

@a2k42
Copy link
Author

a2k42 commented Oct 10, 2023

The correct usage was to use latexify(df, env=:mdtable, latex=false) as given by a later error message:

in Latexify.jl:
You are trying to create latex-maths from a String that cannot be parsed as
an expression: Hello World.

latexify will, by default, try to parse any string inputs into expressions
and this parsing has just failed.

If you are passing strings that you want returned verbatim as part of your input,
try making them LaTeXStrings first.

If you are trying to make a table with plain text, try passing the keyword
argument latex=false. You should also ensure that you have chosen an output
environment that is capable of displaying not-maths objects. Try for example
env=:table for a latex table or env=:mdtable for a markdown table.

@a2k42 a2k42 closed this as completed Oct 10, 2023
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.

1 participant