tomduck/pandoc-eqnos

Wrong style for eq numbers in epub formats

cplerch opened this issue · 10 comments

Wrong style for eq numbers in epub formats

Eq numbers in both epub formats supported by pandoc (epub2 and epub3) appear to the right of the equation at some fixed distance (\qquad ?) - while in html format they are placed correctly on the right margin of the surrounding text. Furthermore in epub2 the equation block is not centered but aligned with the left text margin.
The wrong numbering in epub is not only an aestetic problem: the eq numbers become part of the math and thus change the semantics of the equation (think math audio readers or copy latex to clipboard facilities).
Since I assume that this is a bug and not an intention I had a short look to the code. I noticed that none of the epub format can get processed correctly in function process_equation at line 201, because these formats (epub, epub2, epub3) are missing in line 144 ?

I believe that in all these cases (html, html5, epub2, or epub3) with mathml output the template should be:

<span id="eq:iii" style="display: inline-block; position: relative; width: 100%">
    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
        <semantics>
            ...
            <annotation encoding="application/x-tex"> xxx </annotation>
        </semantics>
    </math>
    <span style="position: absolute; right: 0em; top: 50%; line-height:0; text-align: right">(nnn)</span>
</span>

Hint: The math display="block" attribute effectively centers the equation on the page. If mathml is not used, then the horizontal alignment should be done by css.

I agree that this is a problem. Thank you for the detail, which is helpful.

This is now fixed in the nextrelease branch.

Tried nextrelease but for epub formats the tag (i.e. the visual eq number) still appears hard-coded in the LaTeX source, just separated by a \qquad from the the math - same as before. I've tested with version 1.4.4 and an adaption of your demo.md file as attached:
demo4.md.txt

I just tested it and am getting correct results. Maybe you are still using the master release by accident?

To upgrade from nextrelease, use

pip install --upgrade git+https://github.com/tomduck/pandoc-eqnos.git@nextrelease --user

Note that I have just pushed out a beta release in the 2.0 branch which cleans up a variety of epub issues across all three of pandoc-fignos/eqnos/tablenos. I expect that 2.0.0 will be the next full release.

Note that there is also a pandoc-eqnos 2.0 beta available. It can be installed using

pip install pandoc-eqnos --user --upgrade  --pre

v2.0.0-beta is working fine.
Will close this issue, but perhaps open another one for suggesting small optimizations of the markup surrounding the math elements in epub output (which will take some time).
Thanks for your efforts!

Hi, @cplerch. Did you still want to suggest other "small optimizations of the markup surrounding the math elements in epub output"? I'm closing in on releasing version 2.0 of all of the filters. It would be great to get the epub support just right. Please go ahead and open another Issue if interested. Thanks, Tom.