# Functieverzoek: Ondersteuning voor \\nicefrac in Discourse Math (\\KaTeX/\\MathJax)

**URL:** https://meta.discourse.org/t/feature-request-support-for-nicefrac-in-discourse-math-katex-mathjax/372841
**Category:** Feature
**Tags:** math
**Created:** [3 juli 2025 om 21:27 UTC](https://meta.discourse.org/t/feature-request-support-for-nicefrac-in-discourse-math-katex-mathjax/372841 "2025-07-03T21:27:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [3 juli 2025 om 21:27 UTC](https://meta.discourse.org/t/feature-request-support-for-nicefrac-in-discourse-math-katex-mathjax/372841/1 "2025-07-03T21:27:58Z")

</div>

## 🧩 Feature Request: Add Support for `\nicefrac` in Discourse Math Rendering

### Summary

Please add support for the `\nicefrac{a}{b}` command in Discourse math rendering. This diagonal-style fraction is compact and ideal for inline expressions, improving readability without disrupting line spacing.

* * *

### 🧪 Why `\nicefrac`?

- Produces clean, **diagonal (slashed) fractions** like `$ \nicefrac{1}{2} $`
- More elegant than `1/2` and less bulky than `\dfrac{1}{2}`
- Common in physics, statistics, and mathematical writing

* * *

### 📦 Implementation Notes

Discourse might be able to support math via **KaTeX** or **MathJax** , depending on the installed plugin. This feature request outlines implementation for both:

#### ✅ MathJax

MathJax might support `\nicefrac` if an extension is loaded:

```js
MathJax.Hub.Config({
  TeX: {
    extensions: ["AMSmath.js", "nicefrac.js"]
  }
});

```

This could mean no core changes are needed — so you could just update the plugin config to enable the extension.

#### 🔧 KaTeX

KaTeX does **not** support `\nicefrac` natively. It might be possible that the following workaround macro can be added:

```js
macros: {
  "\\nicefrac": "\\raisebox{.5ex}{\\footnotesize #1}/\\raisebox{-.25ex}{\\footnotesize #2}"
}

```

Alternatively, it might be worth investigating support through third-party KaTeX extensions such as `katex-extension`.

* * *

### 🔍 Reproduction

Try rendering the following:

```plaintext
$\nicefrac{3}{4}$

```

Result in KaTeX:

> `KaTeX parse error: `Undefined control sequence: \nicefrac`

Result in MathJax (if extension not loaded):

> ~~`LaTeX Error: Command \nicefrac undefined`~~ `MathJax parse error: `Undefined control sequence: \nicefrac`

* * *

### ✅ Expected Behavior

- `$ \nicefrac{3}{4} $` renders a proper diagonal fraction
- Might be able to work consistently across both KaTeX and MathJax ~~installs~~ providers
- Hopefully, No parse errors or user confusion

* * *

### 💬 Motivation

- `\nicefrac` is widely used in LaTeX documents and teaching materials
- Inline fractions appear more naturally in text
- Improves math formatting in STEM-heavy Discourse communities

* * *

### 🔗 References

- [KaTeX GitHub Issue – \nicefrac support](https://github.com/KaTeX/KaTeX/issues/1267)
- [MathJax Docs – nicefrac.js Extension](https://docs.mathjax.org/en/latest/input/tex/extensions/nicefrac.html)

Thank you for considering this small but valuable improvement to math rendering in Discourse!
