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

Add support for additional LaTeX delimiters #18

Open
SteelWagstaff opened this issue Jul 18, 2019 · 7 comments
Open

Add support for additional LaTeX delimiters #18

SteelWagstaff opened this issue Jul 18, 2019 · 7 comments
Labels
authoring tools related to content creation & the authoring interface, visual & text editors, & publication menus Small - 3 Planning Poker T-Shirt Size third party related to third party tools, services, integrations or plugins

Comments

@SteelWagstaff
Copy link
Member

SteelWagstaff commented Jul 18, 2019

Many advanced math users, especially those who spend time writing in LaTeX, are used to \( ... \), \[...\] or the $ character behaving as special math delimiters. Other solutions, like WP QuickLaTeX, give users an advanced feature option to declare a page as a latexpage with a shortcode, and furthermore lets them declare $ as a math delimiter (when activated, they can use $. to denote a 'regular' dollar sign). MathJax 3.0 permits similar behavior through the use of custom delimiters: https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options.

Proposed:

  1. We should add support for \( ... \) and \[...\] as valid delimiters in our LaTeX/MathJax plugin.

  2. We should allow users to choose whether or not to treat single dollar signs as math delimiters. To do so, we should add an option to the MathJax settings page that allows users to treat dollar signs as math delimiters. When selected we should add the inline math and process escapes configuration options described in the MathJax documentation. This would allow them to use additional delimiters (like those described here: i.e. $ as a math delimiter and \$ to create a 'regular' dollar sign) throughout the book.

@SteelWagstaff SteelWagstaff added the Small - 3 Planning Poker T-Shirt Size label Aug 14, 2019
@SteelWagstaff SteelWagstaff changed the title Allow users to treat a single $ as a math delimiter for books Allow users to define additional math delimiters Oct 1, 2019
@SteelWagstaff
Copy link
Member Author

Regex: "/\\$\\$.+\\$\\$|\\\\\\[.+\\\\\\]|\\\\\\(.+\\\\\\)/"

@SteelWagstaff SteelWagstaff changed the title Allow users to define additional math delimiters Add support for additional LaTeX delimiters Nov 8, 2019
@pkra
Copy link

pkra commented Nov 8, 2019

This is how MathJax itself searches: https://github.com/mathjax/MathJax-src/blob/master/ts/input/tex/FindTeX.ts

@SteelWagstaff SteelWagstaff added authoring tools related to content creation & the authoring interface, visual & text editors, & publication menus third party related to third party tools, services, integrations or plugins labels Nov 28, 2019
@SteelWagstaff
Copy link
Member Author

@SteelWagstaff
Copy link
Member Author

SteelWagstaff commented Feb 3, 2020

For #1 above, I think we'd want to set up MathJax to use a local configuration file (see http://docs.mathjax.org/en/v2.7-latest/configuration.html#using-a-configuration-file) and use the following configs settings:

MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [ ['\\(','\\)'] ]
    displayMath: [ ['$$','$$'], ['\[','\]'] ]
  }
});

This would cause \( ... \) to act as inline math delimiters, and ``$$...$$and[ ... ]` to act as display math delimiters.

For #2 above, we could also add a setting to the config menu that allows authors to use $ globally in the book as a math delimiter. If checked, the setting would result in a config statement that looked like this:

MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [ ['$','$'], ['\\(','\\)'] ]
    displayMath: [ ['$$','$$'], ['\[','\]'] ]
   processEscapes: true
  }
});

@SteelWagstaff
Copy link
Member Author

SteelWagstaff commented Feb 5, 2020

@connerbw recommended looking at how Jetpack handles $latex as a model for what we’ll need to do to get other delimiters working for various export formats. See https://github.com/Automattic/jetpack/blob/master/projects/plugins/jetpack/modules/latex.php

See our current method for supporting $latex as a delimiter here: https://github.com/pressbooks/pressbooks/blob/4cdee460dcc1800c7437297c9c45574650b6d814/inc/class-mathjax.php#L326-L426

@SteelWagstaff
Copy link
Member Author

See also https://github.com/pkra/mathjax-node-page/blob/master/lib/tex.js (for v2 of MathJax)

@SteelWagstaff
Copy link
Member Author

There is a GPL-licensed WordPress MathJax plugin that supports several kinds of delimiters: https://github.com/phillord/mathjax-latex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authoring tools related to content creation & the authoring interface, visual & text editors, & publication menus Small - 3 Planning Poker T-Shirt Size third party related to third party tools, services, integrations or plugins
Projects
None yet
Development

No branches or pull requests

2 participants