GithubHelp home page GithubHelp logo

mathjax-mhchem's People

Contributors

dpvc avatar fred-wang avatar mhchem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mathjax-mhchem's Issues

Add Benzene ring support in chemical formula

It would be great to use benzene ring in chemical formulas.

For info: Benzene ring is available in unicode as

  • ⏣ BENZENE RING WITH CIRCLE (U+23E3) and
  • ⌬ BENZENE RING (U+2323)

sans-serif support

In MathJax equations can be made to use the sans serif-font by encapsuling the math withing a {\sf [math]}, it'd be great if something like that could be done with mathjax-mhchem as well, perhaps if something like the mhchem \mhchemoptions{font=sf} was possible.

I've made a very ugly 'permanent' implementation of this in my fork swantzter/MathJax-mhchem@845ee5e

t.slice is not a function

Hi, we received an error t.slice is not a function in our sentry server. Sorry, I didn't find the TeX script to trigger this issue.

But I guess it happens in

MhchemMethods.Machine = function(parser: TexParser, name: string, machine: string) {
  try {
    let arg = parser.GetArgument(name);
    let data = mhchemParser.go(arg, machine);
    // TODO: Harvest chemical information here from data, test looping through
    //       the array.
    let tex = texify.go(data);
    parser.string = tex + parser.string.substr(parser.i);
    parser.i = 0;
  } catch (err) {
    throw new TexError(err[0], err[1], err.slice(2));
  }
};

where err is not an Array in some cases (maybe Error thrown in some of the logic inside)

Arrow <=> not in correct size when "ui/safe" is enabled

See https://jsbin.com/cadobasoho/edit?html,js,console,output

Example HTML:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>MathJax + mhchem example</title>
  <script>
    window.MathJax = {
      tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']],
        packages: {'[+]': ['mhchem']}
      },
      loader: {load: ['[tex]/mhchem', 'ui/safe']},
    };
  </script>
  <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js"></script>
</head>
<body>
  $\ce{<=>}$
</body>
</html>

In the rendered result, the upper arrow is shorter than the bottom arrow.

But if I remove "ui/safe", it looks fine.

What are the dependencies for MathJax-mhchem?

What are the actual dependencies for MathJax-mhchem from MathJax library? I am using minified version of MathJax from here. Its working fine but not with this extension. I want to use this for mobile app development so MathJax is a huge library to work with therefore I am using minified version.

missing Unicode chars for some arrows

MathJax output from mhchem builds up several arrows because there is no Unicode equivalent. This leads to poor speech without extra effort. E.g., for <=>, SRE generates

left harpoon with barb down minus under minus right harpoon with barb up

as opposed to "in equilibrium with". I suspect an actual font character would produce a superior visual rendering also, but that of course depends on the font implementation.

I saw missing characters for <=>, <<=>, and <=>> and asked some people on the Unicode Technical committee whether I missed spotting those characters given how many arrow chars they already have. The answer was that they are missing and encouraged me to submit a proposal to include any missing characters. Specifically one person said

...good idea looking for "macros" that build up symbols. If such use is widespread, with reasonably established usage, character encoding would seem appropriate.

@mhchem or @dpvc: if you can you list come up with a list of those chars, I'll work on getting a proposal together for them. If there are only three, it was suggested that they fill in the three remaining empty slots in "2B00 Miscellaneous Symbols and Arrows block".

Arrows <=>> and <<=> are not strechy

Hi all!
I having some troubles with the mhchem arrows.
If I write some code like:
\ce{<=>[{some text}][{Some text}]} --> Mathjax bring me a little arrow not adjusted with the text.

With other arrows:
\ce{<=>>[{some text}][{Some text}]}
\ce{<<=>[{some text}][{Some text}]}
Both of them bring me the same arrow like the example below (\ce{<=>}) instead of the correct arrow.

I write this using the documentation available at ftp://www.ctan.org/tex-archive/macros/latex/contrib/mhchem/mhchem.pdf

JAWS screen reader reads out <mphantom>

Hello,

Describe the bug:

To Reproduce:

  1. Go to 'katex.org' or 'https://mhchem.github.io/MathJax-mhchem/' in Chrome on Windows 10
  2. Enter \ce{SO4}
  3. Enable JAWS
  4. Output reads as "S O X sub 4"

Expected behavior:
Read out as "S O sub 4"

Environment:

  • OS : Windows 10
  • Browser : Chrome 93.0.4577.63
  • JAWS version : 2021.2105.53

Thanks for your time.

Poor MathML output

Issue Summary

The mchem packages produces very ugly MathML when there is a much better (and better for assistive technology) solution. Solving this would solve #22. Technically, this is not a bug report, but the upshot is that with the current output, recognition and proper voicing of the chemistry output is extremely difficult.

At the end of this issue is a relatively simple example that generates poor MathML output. It has (at least) four problems:

  1. there are extra mrows,
  2. multiple elements are in a single mi
  3. mphantom and mpadded are needlessly used
  4. the sup/super scripts are not attached to the chemical element they adorn

Let me go through these one by one...

The first one (extra mrows) is pretty obvious. In the output below, there is:

      <mrow data-mjx-texclass="ORD">
        <mi data-mjx-auto-op="false">SO</mi>
      </mrow>

There is no need for the mrow.

The second is also pretty obvious -- "SO" is in a single mi. That's a misuse of mi and is equivalent to putting x and y into a single mi and then making that italic (via mathvariant="italic") so that it looks ok. Given this is a chemistry package, is it hard to recognize an element and put it in its own mi? If it is a single letter, then the default italics are overridden with mathvariant as in

    <mi mathvariant="normal">S</mi>

It is valid to add mathvariant="normal" to <mi>Na</mi> if that makes generation simpler (i.e., you can always add it to any chemical element).

The third problem's solution is maybe less obvious. mphantom and mpadded are being used to force the scripts to all have the same vertical position. But MathML has a much simpler solution for this usage: mmultiscripts. From the MathML spec:

This element allows the representation of any number of vertically-aligned pairs of subscripts and superscripts, attached to one base expression. It supports both postscripts and prescripts. Missing scripts must be represented by the empty element none. All of the upper scripts should be baseline-aligned and all the lower scripts should be baseline-aligned.

Since all chemical elements have a capital letter, all scripts will be horizontally aligned.

An example of the better output, which also attaches the scripts to the element (and therefore solves the last problem) is:

<math>
    <mi>S</mi>
    <mmultiscripts>
        <mi>O</mi>
        <mn>4</mn>
        <mrow>
            <mn>2</mn>
            <mo>&#x2212;</mo>
        </mrow>
    </mmultiscripts>
</math>

I've removed the MathJaX generated attributes for clarity. Compare this to the mchem/MathJax output below.

This is also a better solution for the prescripts used in nuclear chemistry.

There is a problem for electron, proton, etc., and scripts because the base doesn't have a capital letter.
The mphantom/mpadded trick could be used here (inside an mrow around the base element), but is not ideal.
This leads to an alternative to mmultiscripts: use msub/msup/msubsup with the attributes subscriptshift and superscriptshift. There are two problems with this approach:

  1. you need to figure out the amount of shift that is appropriate (use font relative units).
  2. MathML Core does not support these attributes (MathJaX does). This means that when someday MathJaX makes use of MathML in an output jax, it will need to do something (probably ugly) to make this work.

Finally, here is the example: \ce{SO4^2−}

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mstyle mathcolor="#a33e00">
    <mrow data-mjx-texclass="ORD">
      <mrow data-mjx-texclass="ORD">
        <mi data-mjx-auto-op="false">SO</mi>
      </mrow>
      <msub>
        <mrow data-mjx-texclass="ORD">
          <mrow data-mjx-texclass="ORD">
            <mpadded width="0">
              <mphantom>
                <mi>A</mi>
              </mphantom>
            </mpadded>
          </mrow>
        </mrow>
        <mrow data-mjx-texclass="ORD">
          <mrow data-mjx-texclass="ORD">
            <mpadded height="0">
              <mn>4</mn>
            </mpadded>
          </mrow>
        </mrow>
      </msub>
      <msup>
        <mrow data-mjx-texclass="ORD">
          <mrow data-mjx-texclass="ORD">
            <mpadded width="0">
              <mphantom>
                <mi>A</mi>
              </mphantom>
            </mpadded>
          </mrow>
        </mrow>
        <mrow data-mjx-texclass="ORD">
          <mn>2</mn>
          <mo>&#x2212;</mo>
        </mrow>
      </msup>
    </mrow>
  </mstyle>
</math>

Degree symbol

It would be nice to have a shorthand for using the degree symbol, in particular one that "overlaps" with subscripts. AFAIK, the right way to do this is like:
\ce{\Delta S\rlap\degree_{rxn}} : $\ce{\Delta S\rlap\degree_{rxn}}$

I guess * is already used, but maybe something like S^* does not conflict with any commonly used notation?

Wrong interpretation of vapour phase symbol

Currently the engine interprets the state of aggregation indicated with a v as a downward arrow for precipitation, i.e. \ce{H2O (v)} = H2O ↓, it should be H2O(v) instead. I think in general the usage of 'v' is not standard, it should be 'g' instead, it might be good to support states of aggregation as a special rule, given that they are set in parenthesis. See the Green Book (pdf) p. 54.

numbers with other kinds of digits becoming acceptable

Mathjax has an option to introduce to it our own number patterns through regex. Here, @dpvc kindly modified some codes from mhchem for it to adapt with another number pattern /^(?:[\d۰-۹]+(?:[,٬'][\d۰-۹]{3})*(?:[\.\/٫][\d۰-۹]*)?|[\.\/٫][\d۰-۹]+)/. In response to my request here regarding publishing the modifications to find their way up to the mainstream version of mhchem, @dpvc directed me to open an issue here and ask if it is possible to make number patterns configurable in mhchem, as is configurable in the TeX input jax?
thanks

\pu: Wider spacing between digit groups

Currently, the thousands separator added by \pu is 2 mu = 1/9 em wide, and looks like this:

2mu-current

I think that's too narrow: I can't pick the thousands apart at a glance. It's even worse in smaller sizes - even looking quite closely, I was barely able to tell where the spaces between groups were and what was just a wide-looking kerning pair.

The Unicode character usually used for this is either U+2009 THIN SPACE or U+202F NARROW NO-BREAK SPACE, but that's not applicable to mhchem (it doesn't insert a character, but instead formats with spaces). Those glyphs are typically 1/5 to 1/6 em wide, which is significantly wider. Here's a mock-up of what 3 mu = 1/6 em looks like:

3mu-proposed

For me, that's much better!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.