docs: mention wrapping in inline mode (#2972)

* docs: mention wrapping in inline mode

* Apply suggestions from code review

Co-authored-by: Erik Demaine <edemaine@mit.edu>

* Add some CSS examples. 

* fixup! docs/issues: remove fleqn thing

* Minor tweaks

* Link to custom CSS

Co-authored-by: Erik Demaine <edemaine@mit.edu>
This commit is contained in:
Mingye Wang
2021-05-12 22:32:14 +08:00
committed by GitHub
parent aec39f6daf
commit 7933729701
2 changed files with 24 additions and 1 deletions

View File

@@ -49,3 +49,24 @@ the version of the JavaScript file (katex.js), which is defined in `katex.versio
If it is not loaded properly, it'll show:
> The KaTeX stylesheet is not loaded!
## CSS customization
KaTeX's CSS is customizable to some extent. For example, to make individual
display equations scrollable horizontally:
```css
.katex-display { overflow: auto hidden }
```
To allow line breaks in display equations (unlike LaTeX):
```css
.katex-display > .katex { white-space: normal }
/* Add space between broken lines: */
.katex-display > .base { margin: 0.25em 0 }
/* Compensate by reducing space around display math */
.katex-display { margin: 0.5em 0; }
```

View File

@@ -4,7 +4,9 @@ title: Options
---
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
- `displayMode`: `boolean` (default: `false`). If `true` the math will be rendered in display mode. If `false` the math will be rendered in inline mode. Differences between the two modes include:
- Display mode starts in `\displaystyle`, so `\int` and `\sum` are large, for example; while inline mode starts in `\textstyle`, where subscripts and superscripts usually don't stack on top of operators like `\sum`. You can always manually switch between `\displaystyle` and `\textstyle` using those commands.
- Display mode centers math on its on line and disables automatic line breaking (though you can customize this behavior with [custom CSS](issues.md)). In inline mode, KaTeX allows line breaks after outermost relations (like `=` or `<`) or binary operators (like `+` or `\times`), the same as TeX.
- `output`: `string`. Determines the markup language of the output. The valid choices are:
- `html`: Outputs KaTeX in HTML only.
- `mathml`: Outputs KaTeX in MathML only.