Add configurable piecewise command - #3056
Open
Shrookin wants to merge 2 commits into
Open
Conversation
Shrookin
marked this pull request as ready for review
August 4, 2026 18:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new
\\piecewise{n}LaTeX input command. The command creates a nativecasesarray withneditable rows, with an expression placeholder and a condition placeholder in each row.It also adds an upstream-generic
compactvirtual-keyboard keycap class for tall structured labels such as a two-row piecewise template. The class scales the rendered label to fit the standard keycap without changing the inserted LaTeX.Why
Constructing a piecewise function currently requires manually inserting a cases environment and adding rows. A parameterized command gives MathLive users and virtual-keyboard integrations a compact, discoverable way to create the structure they need:
Structured keycap labels can exceed the normal key height. The documented
compactclass gives keyboard integrations a supported way to make those labels readable and fully visible.How
piecewisewith the LaTeX command parser alongside the existing environments.casesarray used by regular cases editing, populated with MathLive placeholders.cases,dcases, andrcasesbehavior is unchanged.\\begin{cases}...\\end{cases}representation, so the resulting value does not depend on a nonstandard command.compactvirtual-keyboard class, scaling only the rendered key label.Verification
npx jest test/latex.test.ts --runInBand— 87 tests passed, 34 snapshots passed.npx tsc --noEmit --pretty false— passed.npx eslint src/public/virtual-keyboard.ts— passed.npm run build— passed; static CSS and API documentation regenerated.npx playwright test test/playwright-tests/virtual-keyboard.spec.ts -g "compact keycap"— passed in Chromium, Firefox, and WebKit.npx playwright test test/playwright-tests/physical-keyboard.spec.ts -g "piecewise command"— passed in Chromium, Firefox, and WebKit.This branch is based on the latest upstream
masterand MathLive0.110.0, which is also the latest published npm version.