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:
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:
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:
$\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
Thank you for considering this small but valuable improvement to math rendering in Discourse!
Discuss this on our forum.