-
-
Notifications
You must be signed in to change notification settings - Fork 78
TeX reader: handle \boldsymbol based on content style #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously \boldsymbol always applied TextBold. Now it applies TextBoldItalic for content that is normally italic (latin letters, lowercase greek) and TextBold for content that is normally upright (uppercase greek, numbers).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the handling of \boldsymbol and \bm commands in the TeX reader to apply bold styling based on the default style of the content. Previously, these commands always applied TextBold regardless of content type, which was incorrect for content that should be italic in math mode (like Latin letters and lowercase Greek letters).
Changes:
- Apply
TextBoldItalicfor content normally rendered italic (Latin letters, lowercase Greek letters, operators) - Apply
TextBoldfor content normally rendered upright (uppercase Greek letters, numbers) - Move
\boldsymboland\bmhandling from thestyleOpsmap to special-case logic in thestyledfunction
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/reader/tex/boldsymbol.test | New test file verifying correct bold styling for mixed content including lowercase Greek (α), Latin letters (b, D), uppercase Greek (Γ), operators (+, =, ÷), demonstrating both TextBoldItalic and TextBold applications |
| src/Text/TeXMath/Readers/TeX/Commands.hs | Removed \boldsymbol and \bm from styleOps map with explanatory comment noting special handling in TeX.hs |
| src/Text/TeXMath/Readers/TeX.hs | Added special handling for \boldsymbol and \bm in the styled function, implemented applyBoldsymbol function with content-aware styling logic, and added isDefaultUpright helper to identify uppercase Greek letters and digits |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| -- This includes uppercase Greek letters. | ||
| isDefaultUpright :: Char -> Bool | ||
| isDefaultUpright c = | ||
| -- Uppercase Greek letters (Α-Ω, excluding lowercase range) |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment "excluding lowercase range" is misleading. The range \x0391 to \x03A9 naturally doesn't include lowercase Greek letters (which start at \x03B1), so nothing is being actively excluded. Consider revising to: "Uppercase Greek letters (U+0391 to U+03A9)" or simply "Uppercase Greek letters (Α-Ω)".
| -- Uppercase Greek letters (Α-Ω, excluding lowercase range) | |
| -- Uppercase Greek letters (Α-Ω) |
| EStyled TextNormal xs -> EStyled TextBold xs | ||
| EStyled TextItalic xs -> EStyled TextBoldItalic xs | ||
| EStyled TextBold xs -> EStyled TextBold xs | ||
| EStyled TextBoldItalic xs -> EStyled TextBoldItalic xs |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch-all case wraps unhandled expression types (like ESub, ESuper, EFraction, etc.) entirely in TextBoldItalic, rather than recursively applying the bold style to their components. For example, \boldsymbol{x^2} would wrap the entire superscript expression instead of applying bold to both the base and exponent separately. Consider adding explicit handling for compound expressions if the current behavior doesn't match LaTeX semantics.
| EStyled TextBoldItalic xs -> EStyled TextBoldItalic xs | |
| EStyled TextBoldItalic xs -> EStyled TextBoldItalic xs | |
| ESub base sub -> ESub (applyBoldsymbol base) (applyBoldsymbol sub) | |
| ESuper base sup -> ESuper (applyBoldsymbol base) (applyBoldsymbol sup) | |
| EFraction num den -> EFraction (applyBoldsymbol num) (applyBoldsymbol den) |
Summary
\boldsymboland\bmcommands to apply the correct bold style based on the content's default styleTextBoldItalicfor content that is normally italic (latin letters, lowercase greek)TextBoldfor content that is normally upright (uppercase greek letters, numbers)Previously,
\boldsymbolalways appliedTextBoldregardless of the content, which was incorrect. In LaTeX,\boldsymbol{x}should produce bold italic x, while\boldsymbol{\Gamma}should produce bold upright Gamma.Test plan
test/reader/tex/boldsymbol.test\boldsymbol{x}→ TextBoldItalic\boldsymbol{\Gamma}→ TextBold\boldsymbol{\alpha}→ TextBoldItalic\bm{y}→ TextBoldItalicClose #280
This is the effect of applying the modified texmath: