tex cells aren't centered with text and are clipped

Compare this sample notebook in “old” Observable:

And in “new” Observable:

https://observablehq.com/d/1652c91181b0e2d9

The tex cell is centered with the text in “old” Observable, but is centered with the wider page in “new” Observable. I think in most cases the desire is more likely to be to center the equation with the text.

The issue seems to be that the CSS rule for max-width: 640px; doesn’t include .katex-display in “new” Observable.

Also, if you look at the second equation on the page, you will notice that it is slightly clipped at the top and bottom in “new” Observable. (At least it is in Chrome on Windows for me.)

The issue here seems to be overflow-y: hidden; on .katex-display in “new” Observable.

Hmmm. These changes were suggested by @nxrix ( Removed max-width for .katex-display by nxrix · Pull Request #191 · observablehq/notebook-kit · GitHub and Fixing katex overflow issue by nxrix · Pull Request #184 · observablehq/notebook-kit · GitHub ) so you can see some context there as to why they were added. I’m not sure what the best solution is, though.

Sorry! When I was fixing the KaTeX overflow issue, I didn’t have any text cells in my test notebook, so I didn’t realize the purpose of the max-width: 640px constraint. Now I can see why it’s needed, and I agree that it should be added back to .katex-display.

As for the vertical clipping, it’s a consequence of the CSS overflow rules when overflow-x: auto is set; the y overflow also gets set to auto, which causes vertical scrollbars, so I had to use overflow-y: hidden. The simplest workaround I’ve found so far is to add padding: 1px 0 to .katex-display.

observablehq.com/d/409bd3978912d30f
I tested a few approaches, and this CSS seems to fix the clipping:

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
}

However, it might cause other issues. So the best solution is to keep the old behavior.