Page MenuHomePhabricator

different treatment of \overbrace and \underbrace in chem formula
Open, LowPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Set render mode to client side svg
  • enter formula
H2O (l) ->[+\overbrace{237.2 \ kJ / mol}^{\ce{electricity}}][+\underbrace{48.6 \ kJ /mol}_{\ce{heat}}] {H2} + 1/2 O2

What happens?:

Renders as

image.png (546×132 px, 20 KB)

What should have happened instead?:

There are three difference between the top and bottom

  • placement of the term electricity, ideally this should be above the brace
  • spacing around the / symbol
  • mol in italics rather than Roman

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Details

Other Assignee
Physikerwelt
Related Changes in Gerrit:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Physikerwelt moved this task from Inbox to Needs clarification on the Math board.
Physikerwelt updated Other Assignee, added: Physikerwelt.
Physikerwelt added subscribers: mhchem, Physikerwelt.

@mhchem, could you confirm whether this is expected mhchem behaviour?

In an arrow label, ^ after \overbrace{…} and _ after \underbrace{…} are treated differently by mhchemParser (MathJax and our PHP port give the same TeX):

\ce{H2O ->[+\overbrace{237.2 \ kJ / mol}^{\ce{electricity}}][+\underbrace{48.6 \ kJ /mol}_{\ce{heat}}] H2}

  • Upper label: \overbrace{237.2 \ kJ / mol}{\vphantom{A}}^{\mathrm{electricity}} The content stays plain TeX, and the ^ becomes a chemical superscript on a \vphantom instead of attaching to the brace.
  • Lower label: \underbrace{48.6\ k\,\mathrm{J}~/\mathrm{mol}}_{\mathrm{heat}} The content is converted as chemistry.

The LaTeX package mhchem (v4.10) treats both labels alike. The attached comparison shows mhchem in LaTeX next to the TeX that WikiTexVC generates:


Related: \ce{\underbrace{a}} gives "Extra close brace or missing open brace" in MathJax, while LaTeX mhchem typesets it.

Workaround until then, which renders as intended in MathJax and in WikiTexVC: switch the labels to math mode.
\ce{H2O (l) ->[$+\overbrace{\pu{237.2 kJ/mol}}^{\text{electricity}}$][$+\underbrace{\pu{48.6 kJ/mol}}_{\text{heat}}$] H2 + 1/2 O2}

Change #1350658 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] WIP: Convert \ce and \pu in the parser only

https://gerrit.wikimedia.org/r/1350658

Change #1350658 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Convert \ce and \pu in the parser only

https://gerrit.wikimedia.org/r/1350658