Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of KaTeX in markdown tables causes overflow and responsiveness issues #9785

Open
6 of 7 tasks
farlowdw opened this issue Jan 24, 2024 · 2 comments
Open
6 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution external This issue is caused by an external dependency and not Docusaurus. status: needs more information There is not enough information to take action on the issue.

Comments

@farlowdw
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • 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:

img1

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:

img2

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

Self-service

  • I'd be willing to fix this bug myself.
@farlowdw farlowdw added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 24, 2024
@farlowdw
Copy link
Author

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!

@Josh-Cena
Copy link
Collaborator

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.

@Josh-Cena Josh-Cena added status: needs more information There is not enough information to take action on the issue. external This issue is caused by an external dependency and not Docusaurus. bug An error in the Docusaurus core causing instability or issues with its execution and removed bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution external This issue is caused by an external dependency and not Docusaurus. status: needs more information There is not enough information to take action on the issue.
Projects
None yet
Development

No branches or pull requests

3 participants
@Josh-Cena @farlowdw and others