Skip to content

Inconsistent unicode/LaTeX symbol commands #21646

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

Closed
ViktorQvarfordt opened this issue Apr 29, 2017 · 10 comments
Closed

Inconsistent unicode/LaTeX symbol commands #21646

ViktorQvarfordt opened this issue Apr 29, 2017 · 10 comments
Labels
REPL Julia's REPL (Read Eval Print Loop) unicode Related to unicode characters and encodings

Comments

@ViktorQvarfordt
Copy link
Contributor

ViktorQvarfordt commented Apr 29, 2017

\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.

@oxinabox
Copy link
Contributor

oxinabox commented Apr 30, 2017

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

@ararslan ararslan added the unicode Related to unicode characters and encodings label Apr 30, 2017
@ViktorQvarfordt
Copy link
Contributor Author

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}.

@stevengj
Copy link
Member

stevengj commented May 1, 2017

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 {...}.

@stevengj
Copy link
Member

stevengj commented May 1, 2017

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.

@stevengj stevengj added the REPL Julia's REPL (Read Eval Print Loop) label May 1, 2017
@ViktorQvarfordt
Copy link
Contributor Author

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 latex3/unicode-math#388 for further discussion.

@m-j-w
Copy link
Contributor

m-j-w commented May 4, 2017

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.

@stevengj
Copy link
Member

stevengj commented Sep 22, 2017

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).

@mschauer
Copy link
Contributor

mschauer commented Oct 6, 2017

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

@stevengj
Copy link
Member

stevengj commented Feb 9, 2018

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.

@stevengj
Copy link
Member

Closed by #25980.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop) unicode Related to unicode characters and encodings
Projects
None yet
Development

No branches or pull requests

6 participants