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

as_latex_escaped: two small issues #472

Open
rauschma opened this issue Apr 13, 2023 · 0 comments
Open

as_latex_escaped: two small issues #472

rauschma opened this issue Apr 13, 2023 · 0 comments

Comments

@rauschma
Copy link

rauschma commented Apr 13, 2023

First of all: I’m delighted that as_latex_escaped() exists! Not many libraries support LaTeX.

I have encountered two minor issues:

  • The last two components of RGB colors are flipped, i.e. the numbers in \textcolor[RGB]{38,210,139} should appear in this order: 38,139,210
  • A backslash should be escaped as \textbackslash{}, not as a double-backslash \\ (which is a line break in LaTeX).

Fix

Escaping

In general, I’m escaping as following in LaTeX:

HashMap::from([
    (r"#", r"\#"),
    (r"$", r"\$"),
    (r"%", r"\%"),
    (r"&", r"\&"),
    (r"~", r"\textasciitilde{}"),
    (r"_", r"\_"),
    (r"^", r"\textasciicircum{}"),
    (r"\", r"\textbackslash{}"),
    (r"{", r"\{"),
    (r"}", r"\}"),
])

Due due commandchars=\\\{\}, only these entries are needed inside Verbatim:

HashMap::from([
    (r"\", r"\textbackslash{}"),
    (r"{", r"\{"),
    (r"}", r"\}"),
])
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

No branches or pull requests

1 participant