From 79337297019e9724fb273f4d959396b3b195994e Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Wed, 12 May 2021 22:32:14 +0800 Subject: [PATCH] docs: mention wrapping in inline mode (#2972) * docs: mention wrapping in inline mode * Apply suggestions from code review Co-authored-by: Erik Demaine * Add some CSS examples. * fixup! docs/issues: remove fleqn thing * Minor tweaks * Link to custom CSS Co-authored-by: Erik Demaine --- docs/issues.md | 21 +++++++++++++++++++++ docs/options.md | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/issues.md b/docs/issues.md index 546f28a3..bf5c5e9c 100644 --- a/docs/issues.md +++ b/docs/issues.md @@ -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; } +``` + diff --git a/docs/options.md b/docs/options.md index 768e42a2..3533a819 100644 --- a/docs/options.md +++ b/docs/options.md @@ -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.