Skip to content

Commit

Permalink
PGFPlotsX: fix latexification
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Jul 7, 2022
1 parent 2ab3e9b commit 709dd3d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/backends/pgfplotsx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1164,15 +1164,16 @@ end

pgfx_sanitize_string(p::PlotText) = PlotText(pgfx_sanitize_string(p.str), p.font)
function pgfx_sanitize_string(s::AbstractString)
isempty(s) && return s
c = s
s = replace(s, r"\\?\#" => "\\#")
s = replace(s, r"\\?\%" => "\\%")
s = replace(s, r"\\?\_" => "\\_")
s = replace(s, r"\\?\&" => "\\&")
s = replace(s, r"\\?\{" => "\\{")
s = replace(s, r"\\?\}" => "\\}")
s = map(split(s, "")) do s
isascii(s) ? s : latexify(s)
end |> join
# s = replace(s, r"\\?\{" => "\\{")
# s = replace(s, r"\\?\}" => "\\}")
s = join(map(c -> isascii(c) ? c : latexify(c), collect(s)))
s
end
@require LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" begin
using .LaTeXStrings
Expand All @@ -1182,6 +1183,7 @@ end
return LaTeXString(s)
end
end

@require UnitfulRecipes = "42071c24-d89e-48dd-8a24-8a12d9b8861f" begin
using .UnitfulRecipes
function pgfx_sanitize_string(s::UnitfulRecipes.UnitfulString)
Expand Down Expand Up @@ -1339,7 +1341,7 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
string(letter, "ticklabels") =>
string("{\$", join(tick_labels, "\$,\$"), "\$}"),
)
elseif tick_labels isa Vector{LaTeXString}
elseif tick_labels isa Vector{Latexify.LaTeXString}
push!(opt, string(letter, "ticklabels") => join(tick_labels))
end
elseif axis[:showaxis]
Expand Down

0 comments on commit 709dd3d

Please sign in to comment.