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

Inline math at arbitrary position in text #4

Closed
shenkev opened this issue May 11, 2017 · 3 comments
Closed

Inline math at arbitrary position in text #4

shenkev opened this issue May 11, 2017 · 3 comments

Comments

@shenkev
Copy link

shenkev commented May 11, 2017

Suppose

var text = 25 is 5 2

and we only want to render 5^2 but we don't know what the text is beforehand. Is this possible?

Mathjax node would render the entire string if we we wrapped it around text.

@pyramation
Copy link
Contributor

pyramation commented May 13, 2017

@shenkev are you saying you'd like to render the entire text string and inline?

@SamyPesse I'm happy to make an example, I found a way to pull this off with your library.

In fact, you don't even need to use the nodes, only the context is required:

const defaultOptions = {
  showProcessingMessages: false,
  messageStyle: 'none',
  showMathMenu: false,
  tex2jax: {
    processEnvironments: true,
    inlineMath: [['$', '$'], ['\\(', '\\)']],
    displayMath: [['$$', '$$'], ['\\[', '\\]']],
    preview: 'none',
    processEscapes: true
  }
};

class App extends Component {
  render() {
    return (
      <Context options={defaultOptions}>
        <div>
          25 is $5^2$
        </div>
      </Context>
    );
  }
}

@pyramation
Copy link
Contributor

here's a pull request to add to the readme so future users can find how to achieve this: #12

@shenkev shenkev closed this as completed May 15, 2017
@pyramation
Copy link
Contributor

pyramation commented May 22, 2017

@SamyPesse is there a way to support this original issue? I noticed you have to create all of the inline nodes, when it's not necessary as MathJax with parse text + tex as in this example.

I personally don't want to use the MathJax.Node, I think it's too granular to type for every equation, as it defeats the purpose of writing LaTeX. Is there a way to make something like this MathJax.Context example work?

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

No branches or pull requests

2 participants