Skip to content
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

Feature request: Improve equation number style in docx output #29

Open
shixuguo opened this issue Jan 9, 2018 · 8 comments
Open

Feature request: Improve equation number style in docx output #29

shixuguo opened this issue Jan 9, 2018 · 8 comments

Comments

@shixuguo
Copy link

shixuguo commented Jan 9, 2018

based on pandoc-eqnos, I can do some simple numbered work in converting markdown to docx.

however, the style in docx seems wrong.

in current style, the equation and number looks like below

default

where the equation and number are both in OMML, and there are two space between equation and number.

More common style for numbered equation is as below:

2

equation and number are in a three-column table.
equation is centered and number is right-aligned .
and the number should be plain text not in OMML.

I have tried code below:

+----+:-----------------:+--------------:+
|         | $$y=f(x)$$         | {#eq:1}           |
+-----+-----------------+---------------+

and pandoc-eqnos failed.

@tomduck
Copy link
Owner

tomduck commented Jan 13, 2018

Thanks for this input, @shixuguo. For some time now I have wanted to improve the docx output for pandoc-eqnos and friends. I know that there is a lot of interest. However, I don't use docx myself, and am not nearly knowledgeable enough about OOXML or OMML. If you know about these things and can provide some testing support, then we can look into such an enhancement. What do you think?

Your trial table code didn't work because the equation attributes need to be immediately adjacent to the equation itself.

@shixuguo
Copy link
Author

shixuguo commented Jan 13, 2018

I also have little knowledge about OMML, but in China a lot of journals only accept docx. So I think it's a very helpful enhancement.
I want to do some help, as long as you can point out what should I do.
if you mean some test work, I will be glad to do them.

I know in current design, equation attributes need to be immediately adjacent to the equation itself.
But I think it's a wrong design or it's an inflexible design for equation number.
So is it possible to design a more flexible form for equation number?

@tomduck
Copy link
Owner

tomduck commented Jan 14, 2018

I agree that this should be addressed. If you can help with testing that would be great. I will first need to review similar (incomplete) work done in pandoc-fignos and will get back to you.

@tomduck
Copy link
Owner

tomduck commented Jan 14, 2018

A quick note about this:

I know in current design, equation attributes need to be immediately adjacent to the equation itself. But I think it's a wrong design or it's an inflexible design for equation number. So is it possible to design a more flexible form for equation number?

The attributes need to be immediately next to the equation. However, this does not mean that the equation number needs to go immediately next to the equation. Pandoc-eqnos writes custom TeX and html to position the equation number, for example. We need to do something similar for docx. This will involve figuring out what OOXML to write.

@tomduck
Copy link
Owner

tomduck commented Jan 14, 2018

I have created a wiki page to help organize a solution to this problem:

https://github.com/tomduck/pandoc-eqnos/wiki/Development#docx-output

@tomduck tomduck changed the title wrong style for equation numbers Feature request: Improve equation number style in docx output Aug 9, 2018
@ebranlard
Copy link

ebranlard commented Sep 1, 2019

This might be slightly off-topic since it's not about the style per se, but more about how the equations are internally defined. I can open another issue if you'd prefer.

I'm enclosing a simple docx that contains one equation and one reference. The style might not be the best and I believe others use different formats. What is important here is that the bookmark has auto-numbering and it's listed as an "equation" and not a simple "bookmark". As a result, adding more equation to the document and updating using F9 will update all the equation numbers. (This applies to figures and tables as well, as referenced by the issues mentioned above).

Looking at the xml, the part where the bookmark is defined is:

<w:bookmarkStart w:name="_Ref18177439" w:id="1"/>
-<w:r>
<w:t xml:space="preserve">Equation </w:t>
</w:r>
-<w:r w:rsidR="00684D32">
<w:fldChar w:fldCharType="begin"/>
</w:r>
-<w:r w:rsidR="00684D32">
<w:instrText xml:space="preserve"> SEQ Equation \* ARABIC </w:instrText>
</w:r>
-<w:r w:rsidR="00684D32">
<w:fldChar w:fldCharType="separate"/>
</w:r>
-<w:r w:rsidR="00092964">
-<w:rPr>
<w:noProof/>
</w:rPr>
<w:t>1</w:t>
</w:r>
-<w:r w:rsidR="00684D32">
-<w:rPr>
<w:noProof/>
</w:rPr>
<w:fldChar w:fldCharType="end"/>
</w:r>
<w:bookmarkEnd w:id="1"/>

The citation is :

-<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
-<w:r>
<w:instrText xml:space="preserve"> REF _Ref18177439 \h </w:instrText>
</w:r>
-<w:r>
<w:fldChar w:fldCharType="separate"/>
</w:r>
-<w:r>
<w:t xml:space="preserve">Equation </w:t>
</w:r>
-<w:r>
-<w:rPr>
<w:noProof/>
</w:rPr>
<w:t>1</w:t>
</w:r>
-<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
-<w:r>
<w:t xml:space="preserve"> </w:t>
</w:r>
<w:bookmarkStart w:name="_GoBack" w:id="0"/>
<w:bookmarkEnd w:id="0"/>

I hope that can help. Thank you so much for your work!

Test-Equation.docx

@tomduck
Copy link
Owner

tomduck commented Sep 7, 2019

Thanks for this, @ebranlard. I am nearing completion of my work on version 2.0 of each filter. I expect to work on docx support this fall. It has been a long time in coming, mostly because it is difficult to determine what should actually be done (I am not a docx user). So, the info you have provided me will be most helpful.

Cheers,
Tom

@llyu
Copy link

llyu commented Nov 25, 2019

It would look better using <m:eqArr> to numbering the equation. Here are sample files to show the difference in displaying the equation number.

The equation part in the origin file is:

<m:oMath>
    <m:r><m:t>y=f(x)  (1)</m:t></m:r>
</m:oMath>

test.docx
test

And, the equation part using the <m:eqArr> modifier goes like:

<m:oMath>
    <m:eqArr>
        <m:eqArrPr><m:maxDist m:val="1"/></m:eqArrPr>
            <m:e>
                <m:r><m:t>y=f(x)#(1)</m:t></m:r>
            </m:e>
        </m:eqArr>
</m:oMath>

test_eqArr.docx
test_eqArr

I am trying to create a custom filter based on the <m:eqArr> modifier. However, as a newbie to Python, it is a bit difficult for me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants