asciidoctor / asciimath

Asciimath parser
MIT License
24 stars 16 forks source link

Fix behaviour of ubrace, obrace with superscript, subscript #69

Closed opoudjis closed 2 years ago

opoudjis commented 2 years ago

Issue raised in https://github.com/metanorma/metanorma/issues/235:

In Asciimath, ubrace followed by a subscript, and obrace followed by a superscript, is meant to render the subscript/superscript text under and over the expression, like with say lim. So:

ubrace(((0.5, 0, 0.5),(0, 0.5, 0.5),(0, 0, 1)))_("Adjustment to texture space")

should render as

Στιγμιότυπο 2022-01-18, 22 57 20

as you can verify at http://asciimath.org

The current behaviour of the gem, which looks like the following, is incorrect:

I've kludged some behaviour in PR #68 in markup.rb to enable that, adding :underover => true to :underbrace and :overbrace, and doing an ad hoc if branch to process it. I defer to you about how to do it properly.

pepijnve commented 2 years ago

@opoudjis do you happen to know how you would write this in latex? At the moment the same incorrect output is produced there so I would like to update that renderer as well.

anermina commented 2 years ago

It could be written in Latex like this:

\underbrace{
  \pmatrix{
     0.5 & 0 & 0.5 \cr
     0 & 0.5 & 0.5 \cr
     0 & 0 & 1
    }
  }_{\text{Adjustment to texture space}}
opoudjis commented 2 years ago

... Update?

pepijnve commented 2 years ago

I don't have any mental space to work on this project at the moment I'm afraid. This is 100% volunteer work and I'm the only developer at the moment.

opoudjis commented 2 years ago

Well, I did the PR that addressed the MathML component; would you be ok if I added to the PR the LaTeX component?

pepijnve commented 2 years ago

If you have the time, yes that would be much appreciated. I haven't merged the PR yet because I would prefer to maintain feature parity across the backends.

opoudjis commented 2 years ago

Target is:

\underbrace {
\begin{pmatrix}
0 & 1\\ 
1 & 0
\end{pmatrix} }_{\text{Hello}}
opoudjis commented 2 years ago

Latex generated is:

{\underbrace{\left ( \begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix} \right )}}_{\text{Adjustment to texture space}}

It needs to generate:

\underbrace{\left ( \begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix} \right )}_{\text{Adjustment to texture space}}

opoudjis commented 2 years ago

@pepijnve I've added the needed LaTeX update. I've ended up hardcoding underbrace and overbrace processing, because you have a less rich symbol table by default for LaTeX processing than for MathML processing.

opoudjis commented 2 years ago

... Update? The PR should be good to go.

pepijnve commented 2 years ago

I finally got round to integrating your fix. Sorry for the delay.

opoudjis commented 2 years ago

No problem, thank you!