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

Misplaced equation when converting from markdown to ODT #7777

Closed
nopria opened this issue Dec 27, 2021 · 13 comments
Closed

Misplaced equation when converting from markdown to ODT #7777

nopria opened this issue Dec 27, 2021 · 13 comments

Comments

@nopria
Copy link

nopria commented Dec 27, 2021

Explain the problem.
If I convert to ODT the following simple markdown document

### Title title title title

Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text:

$$μ_1 = 0,8\ \left(\frac{60{°}-α}{30{°}}\right) = 0.64$$

using the command

pandoc test.md -s --self-contained -o test.odt

I get the equation wrongly placed between two lines of text, while it should be after the end of text.

see https://stackoverflow.com/q/70472898/694360

Pandoc version?

I'm using

pandoc 2.16.2 Compiled with pandoc-types 1.22.1, texmath 0.12.3.2, skylighting 0.12.1, citeproc 0.6, ipynb 0.1.0.2

under Ubuntu 20.04.3 running on Windows Subsystem for Linux (WSL 2).

@mb21
Copy link
Collaborator

mb21 commented Dec 27, 2021

the XML that is generated (in content.xml when unzipping the odt file) is:

<text:p text:style-name="First_20_paragraph">Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text:</text:p>
<text:p text:style-name="Text_20_body">
  <draw:frame draw:style-name="fr2" text:anchor-type="paragraph">
  <draw:object xlink:href="Formula-0/" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame>
</text:p>

so seems like the formula is just places as some sort of floating object? what do you think it should be?

@nopria
Copy link
Author

nopria commented Dec 27, 2021

The ODT structure seems correct, so is it a LibreOffice bug? I also noticed that editing inside Libre Office and switching to 'as char' anchor type, moves the anchor from the end of the text to the middle of the text, which is not correct in my opinion.

Changing the code so to use anchor-type="as-char" and centering the paragraph of the equation would solve the issue, but I don't know if that would be the right thing to do.

A non-optimal workaround is to add a line break just before the equation

<br/>$$equation$$

knowing that the added line-break will be oddly placed after the equation.

Update

I discovered that the issue show up only if the equation is too high. In fact, it doesn't show up with $$\frac{1}{2}$$, but it does with $$\frac{1^2}{2^A}$$.

@nopria
Copy link
Author

nopria commented Dec 28, 2021

I asked about this issue on LibreOffice forum and I got some hints which are beyond my knowledge, but hopefully clearer to some pandoc contributor:

https://ask.libreoffice.org/t/misplaced-equation-possible-bug/72111?u=nopria

@jgm
Copy link
Owner

jgm commented Dec 28, 2021

I opened this in MS Word and the equation displayed after the text.

@jgm
Copy link
Owner

jgm commented Dec 28, 2021

Setting anchor-type to frame gets the vertical position right, but loses the centering.

@nopria
Copy link
Author

nopria commented Dec 28, 2021

Setting anchor-type to "character" also fix the vertical placement. Since the standalone equation (i.e. "$$...$$") is placed in a dedicated paragraph, why not center it? Stand alone equations usually are centered, isn't it?

@jgm jgm closed this as completed in 7d56650 Dec 29, 2021
@jgm
Copy link
Owner

jgm commented Dec 29, 2021

I think I've fixed this -- can you test?

@nopria
Copy link
Author

nopria commented Dec 29, 2021

Sorry, I can't test, I tried to install the master branch compiling it from source but after a couple of times kicking me out of WSL2 without errors during stack setup (which after some retries finally completed) I'm stuck at stack install with an error ending with:

...
texmath          >    |
texmath          > 29 | import Data.Semigroup ((<>))
texmath          >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
texmath          >
texmath          > /tmp/stack-028a91e584afeb75/texmath-0.12.3.3/src/Text/TeXMath/Writers/TeX.hs:30:1: warning: [-Wunused-imports]
texmath          >     The import of ‘Control.Applicative’ is redundant
texmath          >       except perhaps to import instances from ‘Control.Applicative’
texmath          >     To import instances alone, use: import Control.Applicative()
texmath          >    |
texmath          > 30 | import Control.Applicative ((<$>), Applicative)
texmath          >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
texmath          > [20 of 20] Compiling Text.TeXMath
texmath          >
texmath          > copy/register
texmath          > Installing library in /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/texmath-0.12.3.3-5fCW13MbAhZ90vZrVrZkJ4
texmath          > Registering library for texmath-0.12.3.3..
Progress 2/3

--  While building package commonmark-pandoc-0.2.1.1 (scroll up to its section to see the error) using:
      /home/nopria/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Maybe that was above the capabilities of Windows Subsystem for Linux.

@jgm
Copy link
Owner

jgm commented Dec 29, 2021

Hm. Not sure, the part you quote only contains a warning, so the true error must be further up (it says it concerns commonmark-pandoc). Scroll up further to find it.

@nopria
Copy link
Author

nopria commented Dec 29, 2021

You're right, here it is:

~/pandoc-master/pandoc$ stack install
commonmark-pandoc> configure
commonmark-pandoc> Configuring commonmark-pandoc-0.2.1.1...
commonmark-pandoc> build
texmath          > configure
commonmark-pandoc> Preprocessing library for commonmark-pandoc-0.2.1.1..
commonmark-pandoc> Building library for commonmark-pandoc-0.2.1.1..
commonmark-pandoc> [1 of 1] Compiling Commonmark.Pandoc
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:24:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Math.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 24 | import Commonmark.Extensions.Math
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:25:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Emoji.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 25 | import Commonmark.Extensions.Emoji
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:26:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Wikilinks.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 26 | import Commonmark.Extensions.Wikilinks
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:27:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/PipeTable.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 27 | import Commonmark.Extensions.PipeTable
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:28:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Strikethrough.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 28 | import Commonmark.Extensions.Strikethrough
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:29:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Superscript.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 29 | import Commonmark.Extensions.Superscript
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:30:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Subscript.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 30 | import Commonmark.Extensions.Subscript
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:31:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/DefinitionList.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 31 | import Commonmark.Extensions.DefinitionList
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:32:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Attributes.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 32 | import Commonmark.Extensions.Attributes
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:33:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Footnote.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 33 | import Commonmark.Extensions.Footnote
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:34:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/TaskList.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 34 | import Commonmark.Extensions.TaskList
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
commonmark-pandoc> /tmp/stack-028a91e584afeb75/commonmark-pandoc-0.2.1.1/src/Commonmark/Pandoc.hs:35:1: error:
commonmark-pandoc>     Bad interface file: /home/nopria/.stack/snapshots/x86_64-linux-tinfo6/43d763fdb4499772e702c1542ecdcc8f75b072c3ffd7aa4151074ba71839f18b/8.10.7/lib/x86_64-linux-ghc-8.10.7/commonmark-extensions-0.2.2.1-L5l7OaUz4fDyyV2tazh4E/Commonmark/Extensions/Smart.hi
commonmark-pandoc>         Data.Binary.getPrim: end of file
commonmark-pandoc>    |
commonmark-pandoc> 35 | import Commonmark.Extensions.Smart
commonmark-pandoc>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
commonmark-pandoc>
texmath          > Configuring texmath-0.12.3.3...

@jgm
Copy link
Owner

jgm commented Dec 30, 2021

Not sure what is going on there, but I don't think it's a problem with the library itself; rather, a problem with your stack setup. You could try deleting (better, moving) your ~/.stack directory and trying the build again.

@nopria
Copy link
Author

nopria commented Dec 30, 2021

stack setup aborted 3-4 times kicking me out of WSL (without any message) before completing on retry, so I guess there was some problem with it. However, running again stack setup says only stack will use a sandboxed GHC it installed, without errors or warnings, and running again stack install gives the same error above.

By the way, if you already tested the fix it's fine for me, I'll wait for next pandoc release 2.16.3.

@jgm
Copy link
Owner

jgm commented Dec 30, 2021

It should be in a nightly soon. (You could also try using cabal install.)

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

3 participants