Repository navigation
fix(macros): define \arraystretch so \renewcommand works - #4320
Open
Thanatos9404 wants to merge 1 commit into
Open
Thanatos9404 wants to merge 1 commit into
Thanatos9404 wants to merge 1 commit into
Conversation
LaTeX defines \arraystretch as 1 in lttab.dtx, so
\renewcommand{\arraystretch}{2} is the usual way to stretch an array,
and \newcommand{\arraystretch} fails. KaTeX read the macro but never
defined it, so \renewcommand failed with "command \arraystretch does not
yet exist". Define it as 1, and use that default in arrays without
expanding it, so that it still costs no macro expansions.
Fixes KaTeX#2668
Contributor
[Medium impact] The PR appears safe to merge. SummaryDefines
Thanatos9404 explicitly identifies these changes as intentional: Reviews (1) · Last reviewed commit: "fix(macros): define \arraystretch so \re..." · Reviewed by Greptile |
This branch has not been deployed
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 is the previous behavior before this PR?
\renewcommand{\arraystretch}{2}, the usual LaTeX way to stretch an array, failed with "\renewcommand{\arraystretch} when command \arraystretch does not yet exist; use \newcommand". KaTeX read\arraystretchinarray.tsbut never defined it. LaTeX defines it as 1 in lttab.dtx, so there\renewcommandworks and\newcommand{\arraystretch}fails.What is the new behavior after this PR?
\arraystretchis defined as1inmacros.ts, as in LaTeX, so\renewcommand{\arraystretch}{1.5}works.\defand themacrosoption work as before. When\arraystretchstill has this default,array.tsuses it without expanding it, so arrays still cost no macro expansions;\begin{matrix}keeps parsing withmaxExpand: 0.As in LaTeX:
\newcommand{\arraystretch}{...}now fails;\providecommand{\arraystretch}{...}now does nothing;\arraystretchrenders1instead of an undefined control sequence error.No test or doc in the repo uses those.
New test next to "should grab \arraystretch" (
\renewcommand,\newcommand, andmaxExpand: 0); it fails on main. All jest tests and snapshots pass, andpnpm test:lintandpnpm test:tsare clean.Fixes #2668