Julia: Inconsistent unicode/LaTeX symbol commands

Created on 30 Apr 2017  ยท  10Comments  ยท  Source: JuliaLang/julia

\mbfA for ๐€ and
\mscrA for ๐’œ and
\mfrakA for ๐”„ but
\BbbA for ๐”ธ

Double-struck got messed up: \Bbb (BlackBordBold) instead of \mbbA. This is the issue.

Taking it further: Ideally we would like to use the LaTeX commands, such as \mathbf{A}, but I guess it was decided that's too long (and I agree) so it's shortened to \mbfA. If the argument to deviate from LaTeX is to make it shorter, then i'd suggest to also remove the m. However, I'd like to raise the discussion of instead (or in addition) using shortenings of the unicode names, such as \bA for ๐€, since its unicode name is MATHEMATICAL BOLD CAPITAL A, as seen in https://www.w3.org/TR/xml-entity-names/bold.html. Thus we have
\bA for ๐€ (bold)
\sA for ๐’œ (script)
\fA for ๐”„ (frak)
\dA for ๐”ธ (double-struck)
\iA for ๐ด (italic)
\ssA for ๐–  (sans-serif)
\ssbiA for ๐˜ผ (MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL A).

It is debatable which of \sA and \ssA should be is ๐–  (sans-serif). If script gets demoted it can be \scA for ๐’œ (script).

I suggest allowing short and sweet unicode shortenings (as explained) and full LaTeX style commands (perhaps without the braces, i.e. \mathbfA instead of \mathbf{A}).

(You might wonder "Why do I care?". I use unicode inputs in other places, and there is no de-facto standard repository for unicode <-> latex etc. The mindset is scientific writing, this repo is like-minded and is popular, I'm okay with setting the standards in here. Otherwise, point me in the right direction, then also this project should track this de-facto repository of unicode mappings.)

The file in question is latex_symbols.jl.

REPL unicode

Most helpful comment

Would still be nice to simplify/rationalize the tab completions for different font variations if we can agree on something, since the current abbreviations are pretty unwieldy and counter-intuitive.

I would tend to prefer something like \bA for ๐€ (bold) \sA for ๐’œ (script), \fA for ๐”„ (frak), \bbA for ๐”ธ (blackboard bold), \iA for ๐ด (italic), \ssA for ๐–  (sans-serif) \ssbiA for ๐˜ผ (sans-serif, bold, italic).

All 10 comments

There is another thread about this somewhere. Perhaps discourse or the old mailing lists.
That talks about that the symbol map was based on something (MathJax's table maybe?),
and it has only been haphazardly updated to match that sources patch's.
(This is from memory so I might have the story wrong.)

There are some defacto standards eg: https://github.com/wspr/unicode-math
Which is used for JuliaString/LaTeX_Entities.jl

And the standard for unicode names for math symbols: https://www.w3.org/2003/entities/2007xml/MathMap-9.txt

I see, so Julia uses wspr/unicode-math? But these shortcuts are not standard, and unfortunately inconsistent as I showed. I don't know why \BbbC is still around, it's an old thing from amsmath that has been deprecated and replaced by the standardized \mathbb{C}.

The latex_symbols list (added in #6911 and subsequently extended) was mainly based on the W3C mapping and the unicode-math LaTeX package. In particular, the \mscrA and \BbbA mappings come from there.

The basic issue is that I wanted to avoid the can of worms of defining our own custom abbreviations, as opposed to adopting something relatively widespread like the unicode-math package.

I chose not to support tab-completion of LaTeX functions like \mathbb{A} in order to avoid giving a false impression of actual LaTeX support. Also, I was concerned about unwanted interactions with completion of Julia syntax employing {...}.

I'm not opposed to defining additional (shorter) abbreviations. (The m prefix always bugged me since it seems redundant, for example.) But be prepared for an epic bikeshed argument over what abbreviations people prefer.

Thanks for the background!

Because of https://xkcd.com/927 I think standard LaTeX commands, e.g. \mathbb{A}, should be used. I don't think anyone will assume the REPL starts doing LaTeX typesetting :) But yeah, deciding such things can be difficult, it's largely based on personal preference.

My reasons for wanting to clean up the Julia repository of unicode-latex mappings were to use these mappings for other things. Since I realize that perhaps not everyone agrees with my choices, I created this: https://github.com/ViktorQvarfordt/unicode-latex. A mapping between unicode symbols and (standard) LaTeX commands. Furthermore, in that repo I also created a LaTeX package from this that allows ฮฑ as a synonym for \alpha, like unicode-math but without needing to use an alternative font, or xetex/luatex. See https://github.com/wspr/unicode-math/issues/388 for further discussion.

Though I assume participants of this thread are aware of this, it is perhaps worth noting for other readers that customizing unicode completions is fairly easy and probably the best way to pick and choose from the numerous TeX package notations.

# add this to ~/.juliarc.jl
let latex_symbols = Base.REPLCompletions.latex_symbols
          # Choose a more math-like name for unicode representations
          latex_symbols["\\Reals"]     = latex_symbols["\\BbbR"]
          latex_symbols["\\Naturals"]  = latex_symbols["\\BbbN"]
          latex_symbols["\\Integers"]  = latex_symbols["\\BbbZ"]
          latex_symbols["\\Rationals"] = latex_symbols["\\BbbQ"]
          latex_symbols["\\Complexes"] = latex_symbols["\\BbbC"]
          # or even shorter
          latex_symbols["\\R"] = latex_symbols["\\BbbR"]
          latex_symbols["\\N"] = latex_symbols["\\BbbN"]
          latex_symbols["\\Z"] = latex_symbols["\\BbbZ"]
          latex_symbols["\\Q"] = latex_symbols["\\BbbQ"]
          latex_symbols["\\C"] = latex_symbols["\\BbbC"]
end

This will give you exactly what you personally prefer, no compromise required. It should also instantaneously work in Jupyter and Juno, if I'm not mistaken.

You might then consider adding same abbreviations to some default my.sty using \newcommand{\Reals}{\ensuremath{\BbbR}}, or whatever representation you prefer in LaTeX.

Didn't find it being mentioned in the manual, though.

Would still be nice to simplify/rationalize the tab completions for different font variations if we can agree on something, since the current abbreviations are pretty unwieldy and counter-intuitive.

I would tend to prefer something like \bA for ๐€ (bold) \sA for ๐’œ (script), \fA for ๐”„ (frak), \bbA for ๐”ธ (blackboard bold), \iA for ๐ด (italic), \ssA for ๐–  (sans-serif) \ssbiA for ๐˜ผ (sans-serif, bold, italic).

In any case, \BbbA is really the odd one out.

Unfortunately, \bA and \iA won't work, because they create an ambiguity for bold \eta (which would become \beta, conflicting with ฮฒ) and italic n (which would become \in, conflicting with โˆˆ).

One option would be to terminate all font choices with f, so that it becomes \bfA, \ifA, \ffA, \bbfA, \ssfA, etcetera.

Closed by #25980.

Was this page helpful?
0 / 5 - 0 ratings