feat: \underbracket and \overbracket#4147
Conversation
Greptile SummaryThis PR adds support for
The implementation is clean, minimal, and leverages existing code effectively. All changes are consistent with the codebase patterns. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 0d94372 |
There was a problem hiding this comment.
Nice, thanks for picking this up!
You can download the new screenshot outputs from the failing CI tasks; they're uploaded as artifacts.
I'd consider merging the underbrace and underbracket tests, but don't feel strongly.
More importantly, I'm not sure the line widths are correct (seems too thin).
Also not sure about the height... should it be shorter?
\underline{hello}
\underbracket{hello}_{world}
\underbrace{hello}_{world} LaTeX (with \usepackage{mathtools})

Unless there's another package that defines \underbracket?
There's also an issue with spacing before and after, but \underbrace has that too.
|
Thanks for the feedback, I'll work on the dimensions. |
|
I am commenting just to say that this PR is cool. @grigoriy-reshetniak, you are the first contributor other than me to use SVGs to extend KaTeX. I'm happy that someone has been able to follow and extend the methods that I used. @edemaine has been maintaining KaTeX by himself for a while now, and I'm glad that you have stepped up to give him some support. |
e3d0647 to
4613b81
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4147 +/- ##
==========================================
+ Coverage 93.15% 93.30% +0.14%
==========================================
Files 91 91
Lines 6795 6810 +15
Branches 1582 1585 +3
==========================================
+ Hits 6330 6354 +24
- Misses 429 454 +25
+ Partials 36 2 -34
... and 14 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
edemaine
left a comment
There was a problem hiding this comment.
Looks great! Can you add the screenshots from the Screenshotter actions' uploaded artifacts?
Actually, a big oversight that CI passes! I confirmed that --verify doesn't give an exit code when a screenshot is missing, only (presumably) when there's a mismatch. We should fix in another PR.
Unfortunately, I'm not able to find them. I'm able to see artifacts from failed builds, like https://github.com/KaTeX/KaTeX/actions/runs/22549692911, but its not available for successful ones (I believe because no diff is introduced), like https://github.com/KaTeX/KaTeX/actions/runs/22796025639?pr=4147. This is KaTeX output in dev server for
This is LaTeX output for the
It seems to me that it's pretty close now. |
Actually I think this was #4158! Hopefully it works now. |
|
I ran
If I were to nit pick, I'd say the green (KaTeX) under/overbracket is slightly thicker. Did you get the line thickness measurement from LaTeX somewhere, or did you eyeball it? If it's from LaTeX, I'm happy to keep it as is; maybe just a browser rendering thing. The horizontal spacing looks perfect! And ignore the sub/superscripts looking so different; that's #3972. |
|
I did it by eye. However, I've checked documentation for mathtools and in
KaTeX Per my understanding of documentation What do you think? |
|
I think I must have red and green backwards. Indeed, the texcmp README says green is LaTeX. (I was confused because LaTeX is the red channel, but light is additive, so...) So overbracket is indeed too thin, and I'd up it to 120 like the documentation says. \documentclass{article}
\begin{document}
$
\newlength\LEN
\setlength\LEN{1em}
\showthe\LEN
\setlength\LEN{0.277777ex}
\showthe\LEN
$
\end{document}measures 1em at 10.00002pt and 5/18 ex at 1.19595pt, so 5/18 ex = 0.119595 em. Very close to 0.120em. I agree it looks thick, but compatibility is a clearer target. In the future, we could try to make the thickness configurable — if that's even possible... |
|
I agree that To define If you really want to make the thickness configurable, there is a go-by in current KaTeX settings. |
|
Next thing I need to do -- update docker images for screenshotter. I'm not able to run it on arm architecture so I have to take image from artifacts. |
edemaine
left a comment
There was a problem hiding this comment.
Looks good! Just need to resolve a docs conflict.
6b0a862 to
1273009
Compare
1273009 to
5b5ee4f
Compare
|
🎉 This PR is included in version 0.16.42 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [0.16.42](KaTeX/KaTeX@v0.16.41...v0.16.42) (2026-03-24) ### Features * \underbracket and \overbracket ([KaTeX#4147](KaTeX#4147)) ([5be9abb](KaTeX@5be9abb))
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [katex](https://katex.org) ([source](https://github.com/KaTeX/KaTeX)) | [`0.16.40` → `0.16.44`](https://renovatebot.com/diffs/npm/katex/0.16.40/0.16.44) |  |  | --- ### Release Notes <details> <summary>KaTeX/KaTeX (katex)</summary> ### [`v0.16.44`](https://github.com/KaTeX/KaTeX/blob/HEAD/CHANGELOG.md#01644-2026-03-27) [Compare Source](KaTeX/KaTeX@v0.16.43...v0.16.44) ##### Bug Fixes - remove extra \jot space at bottom of align/gather/etc. ([#​4184](KaTeX/KaTeX#4184)) ([3870ee9](KaTeX/KaTeX@3870ee9)) ### [`v0.16.43`](https://github.com/KaTeX/KaTeX/blob/HEAD/CHANGELOG.md#01643-2026-03-26) [Compare Source](KaTeX/KaTeX@v0.16.42...v0.16.43) ##### Bug Fixes - use makeEm() consistently to truncate long CSS decimals ([#​4181](KaTeX/KaTeX#4181)) ([0967dcc](KaTeX/KaTeX@0967dcc)) ### [`v0.16.42`](https://github.com/KaTeX/KaTeX/blob/HEAD/CHANGELOG.md#01642-2026-03-24) [Compare Source](KaTeX/KaTeX@v0.16.41...v0.16.42) ##### Features - \underbracket and \overbracket ([#​4147](KaTeX/KaTeX#4147)) ([5be9abb](KaTeX/KaTeX@5be9abb)) ### [`v0.16.41`](https://github.com/KaTeX/KaTeX/blob/HEAD/CHANGELOG.md#01641-2026-03-24) [Compare Source](KaTeX/KaTeX@v0.16.40...v0.16.41) ##### Bug Fixes - \sout in text mode ([#​4173](KaTeX/KaTeX#4173)) ([e748578](KaTeX/KaTeX@e748578)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44Ni4wIiwidXBkYXRlZEluVmVyIjoiNDMuOTkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Renovate Bot <renovate@zarantonello.dev> Co-committed-by: Renovate Bot <renovate@zarantonello.dev>













What is the new behavior after this PR?
Adds support for
\underbracketand\overbracket.I wasn't able to update screenshots due to images incompatibility.
Closes #4103