Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ React component to display math formulas.
$ npm i react-mathjax --save
```

### Usage
### Basic Usage

```js
const MathJax = require('react-mathjax')
Expand All @@ -31,3 +31,32 @@ module.exports = () => {
);
}
```

### Text and equations

If you want to render TeX with text + equations in line, you can simply pass in `tex2jax` options to MathJax and use the `Context` component:

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

module.exports = () => {
return (
<MathJax.Context options={options}>
<div>
Here is a $r_2(n) = \\{ (a,b) \\in \\mathbb{Z} | a^2 + b^2 = n \\}$, which counts the number of representations of $n$ as a number of 2 squares.
</div>
</MathJax.Context>
);
};
```