Old font command support: \rm, \sf, \tt, \bf, \it#675
Merged
gagern merged 3 commits intoKaTeX:masterfrom Apr 7, 2017
Merged
Conversation
This was referenced Apr 6, 2017
gagern
approved these changes
Apr 7, 2017
Collaborator
gagern
left a comment
There was a problem hiding this comment.
LGTM. It might make sense to add a comment about how building these old commands on \text… relies on the broken behavior of the latter, and would need adjustment when that gets fixed. But we have it in the bug and in the screenshot, so a comment is not vital. We probably should move the consumeSpaces implementation to the MacroExpander at some point, as any space after any command gets eaten. But that can be in a follow-up PR once #605 has landed.
Member
Author
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.
This fixes #252 by supporting old LaTeX (2.09)
\rm,\sf,\tt,\bf,\ttcommands. (\sland\scaren't supported because their analogous\textsland\textscaren't supported in KaTeX, from lack of fonts.) These old (LaTeX 2.09) font commands are defined inarticle.clsas follows:The last argument is how they behave in math mode. For example,
\rm xxxbehaves like\mathrm{xxx}in math mode but\normalfont\rmfamily xxx(not supported by KaTeX) in text mode, whereas\sl xxxbehaves like\textsl{xxx}.I also noticed that the parsing of implicit groups didn't correctly parse spaces. For example,
\text{x\large y}outputs a space in current KaTeX, but not LaTeX (the space is part of the macro name). This is now fixed for size and styling commands, in addition to the newly supported old-font commands.This was surprisingly easy to implement -- unfortunately, because existing font commands (e.g.
\textbf) are implemented as if they are full-reset commands (like\bf), whereas they are only supposed to set one aspect of the font. That's for another issue... (#676)