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

Org writer: Use LaTeX style maths deliminators #7196

Merged
merged 2 commits into from
Apr 1, 2021
Merged

Org writer: Use LaTeX style maths deliminators #7196

merged 2 commits into from
Apr 1, 2021

Conversation

tecosaur
Copy link
Contributor

@tecosaur tecosaur commented Apr 1, 2021

Like Markdown, Org supports LaTeX fragments. However, while many Markdown flavours like the TeX-style $ / $$, as mentioned in the Org manual [1], Org works better with LaTeX-style \( \) / \[ \] delimiters. It also supports LaTeX environments (\begin{*} ... \end{*}) without any form of escaping, but that is best left to another patch.

[1]: https://orgmode.org/manual/LaTeX-fragments.html

Like Markdown, Org supports LaTeX fragments. However, while many
Markdown flavours like the TeX-style $ / $$, as mentioned in the Org
manual [1], Org works better with LaTeX-style delimiters. It also
supports LaTeX environments (\begin{*} ... \end{*}) without any form of
escaping, but that is best left to another patch.

[1]: https://orgmode.org/manual/LaTeX-fragments.html
@tarleb
Copy link
Collaborator

tarleb commented Apr 1, 2021 via email

@tecosaur
Copy link
Contributor Author

tecosaur commented Apr 1, 2021

As it is currently, pandoc will export LaTeX maths snippets in a format that Org does not recognise as maths. The cause of this is mentioned in this point of that manual page:

To avoid conflicts with currency specifications, single ‘$’ characters are only recognized as math delimiters if the enclosed text contains at most two line breaks, is directly attached to the ‘$’ characters with no whitespace in between, and if the closing ‘$’ is followed by whitespace, punctuation or a dash. For the other delimiters, there is no such restriction, so when in doubt, use ‘(...)’ as inline math delimiters.

So, I can create a simple markdown file like

Say I have some $a$s and some $b$s. They are recognised as inline maths.

Clearly, these are parsed as maths elements:

~$ pandoc -f markdown -t latex inline-maths.md
Say I have some \(a\)s and some \(b\)s. They are recognised as inline maths.

Now, if I convert to Org

~$ pandoc -f markdown -t org inline-maths.md
Say I have some $a$s and some $b$s. They are recognised as inline maths.

Except, these are not maths elements in Org, due to the requirements quoted above, specifically

  • "the closing ‘$’ is followed by whitespace, punctuation or a dash"

The form that Org better supports, and that acts as pandoc expects, is LaTeX-style delimiters.

@tarleb
Copy link
Collaborator

tarleb commented Apr 1, 2021 via email

@tecosaur
Copy link
Contributor Author

tecosaur commented Apr 1, 2021

Glad I was able to clear that up 🙂 I've updated the test suite to match, hopefully this all looks good to you now.

@tarleb tarleb merged commit 4371223 into jgm:master Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants