docusaurus
docusaurus copied to clipboard
Usage of KaTeX in markdown tables causes overflow and responsiveness issues
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the
npm run clear
oryarn clear
command. - [X] I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).
Description
TLDR: Usage of KaTex in a markdown table causes overflow issues that are especially notable on mobile (i.e., responsiveness becomes a real issue).
Overflow issues with KaTeX have been discussed to some degree previously. There it was noted a simple CSS fix could handle the display overflow mentioned:
.math.math-display {
overflow-x: auto;
}
KaTeX mentions in their docs that CSS is customizable to some extent and that the following can be used to make individual equations scrollable horizontally:
.katex-display { overflow: auto hidden }
But I think I've discovered another "overflow"-ish kind of issue when using KaTeX with Docusaurus -- if you use any math at all in a markdown table, then the page containing the markdown table has responsiveness issues, especially on mobile when the markdown table is bigger.
Reproducible demo
https://stackblitz.com/edit/github-dnaesk-uowaem?file=docs%2Fintro.md
Steps to reproduce
The repro linked above has a markdown table in intro.md
where just the number 4
is rendered with KaTeX. Click "Open in New Tab" and toggle the device toolbar in dev tools. Reducing the screen size demonstrates the issue.
Expected behavior
When the 4
being typeset with KaTeX is removed, there's no responsiveness issue:
The general scrolling behavior (math present or not) for tables should be just like this.
Actual behavior
Typesetting anything in a markdown table with KaTeX leads to overflow-based responsiveness issues:
It's clear that somehow the content with the 4
is causing responsiveness issues (the problem is less noticeable if the 4
is moved to an earlier column in the table). Once the 4
is removed, there's no responsiveness issue, as demonstrated above.
Your environment
- Public source code: https://stackblitz.com/edit/github-dnaesk-uowaem?file=docs%2Fintro.md
- Public site URL: https://stackblitz.com/edit/github-dnaesk-uowaem?file=docs%2Fintro.md
- Docusaurus version used: 3.1.0
- Environment name and version: chrome 120.0.6099.234
Self-service
- [ ] I'd be willing to fix this bug myself.
Since it's not up to Docusaurus maintainers to account for all the behaviors of KaTeX, it seems like maybe this problematic behavior is slightly outside the scope of a proper Docsuaurus issue, but the problem was brought up on the community Discord server and didn't get any traction there either. Since it's problematic behavior, I thought it should at least be mentioned even though perhaps the issue should be closed because it's not up to Docusaurus maintainers to make KaTeX play nicely with everything. Just know if you've noticed this issue in a Docusaurus project then you're not alone!
Hi, thanks for the detailed report and the in-depth research! Yeah I can see a problem here. I wonder if it's because the formula sets an absolute position for itself, so even when it's hidden, it still takes horizontal placeholder space.