Skip to content

Commit b9e5d1e

Browse files
committed
Make \symbf and \symsf handle Greek italics as in LaTeX.
1 parent f798364 commit b9e5d1e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

ts/input/tex/base/BaseConfiguration.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import './BaseMappings.js';
3434
import {getRange} from '../../../core/MmlTree/OperatorDictionary.js';
3535
import ParseOptions from '../ParseOptions.js';
3636
import {ParseUtil} from '../ParseUtil.js';
37+
import {TexConstant} from '../TexConstants.js';
38+
39+
const MATHVARIANT = TexConstant.Variant;
3740

3841
/**
3942
* Remapping some ASCII characters to their Unicode operator equivalent.
@@ -53,17 +56,17 @@ new CharacterMap('remap', null, {
5356
*/
5457
export function Other(parser: TexParser, char: string) {
5558
const font = parser.stack.env['font'];
56-
let def = font ?
57-
// @test Other Font
58-
{mathvariant: parser.stack.env['font']} : {};
59+
const ifont = parser.stack.env['italicFont'];
60+
// @test Other Font
61+
let def = font ? {mathvariant: font} : {};
5962
const remap = (MapHandler.getMap('remap') as CharacterMap).lookup(char);
6063
const range = getRange(char);
6164
const type = range[3]
6265
// @test Other
6366
// @test Other Remap
6467
let mo = parser.create('token', type, def, (remap ? remap.char : char));
65-
const variant = (range[4] ||
66-
(ParseUtil.isLatinOrGreekChar(char) ? parser.configuration.mathStyle(char, true) : ''));
68+
const style = (ParseUtil.isLatinOrGreekChar(char) ? parser.configuration.mathStyle(char, true) || ifont : '');
69+
const variant = (range[4] || (font && style === MATHVARIANT.NORMAL? '' : style));
6770
if (variant) {
6871
mo.attributes.set('mathvariant', variant);
6972
}

ts/input/tex/base/BaseMappings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ new sm.CommandMap('macros', {
439439
symrm: ['MathFont', VARIANT.NORMAL],
440440
symup: ['MathFont', VARIANT.NORMAL],
441441
symnormal: ['MathFont', ''],
442-
symbf: ['MathFont', VARIANT.BOLD],
442+
symbf: ['MathFont', VARIANT.BOLD, VARIANT.BOLDITALIC],
443443
symbfup: ['MathFont', VARIANT.BOLD],
444444
symit: ['MathFont', VARIANT.ITALIC],
445445
symbfit: ['MathFont', VARIANT.BOLDITALIC],
@@ -448,7 +448,7 @@ new sm.CommandMap('macros', {
448448
symbffrak: ['MathFont', VARIANT.BOLDFRAKTUR],
449449
symscr: ['MathFont', VARIANT.SCRIPT],
450450
symbfscr: ['MathFont', VARIANT.BOLDSCRIPT],
451-
symsf: ['MathFont', VARIANT.SANSSERIF],
451+
symsf: ['MathFont', VARIANT.SANSSERIF, VARIANT.SANSSERIFITALIC],
452452
symsfup: ['MathFont', VARIANT.SANSSERIF],
453453
symbfsf: ['MathFont', VARIANT.BOLDSANSSERIF],
454454
symbfsfup: ['MathFont', VARIANT.BOLDSANSSERIF],

ts/input/tex/base/BaseMethods.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,13 @@ BaseMethods.Hash = function(_parser: TexParser, _c: string) {
308308
/**
309309
* Handle \mathrm, \mathbf, etc, allowing for multi-letter runs to be one <mi>.
310310
*/
311-
BaseMethods.MathFont = function(parser: TexParser, name: string, variant: string) {
311+
BaseMethods.MathFont = function(parser: TexParser, name: string, variant: string, italic: string = '') {
312312
const text = parser.GetArgument(name);
313313
let mml = new TexParser(text, {
314314
multiLetterIdentifiers: parser.options.identifierPattern,
315315
...parser.stack.env,
316316
font: variant,
317+
italicFont: italic,
317318
noAutoOP: true
318319
}, parser.configuration).mml();
319320
parser.Push(parser.create('node', 'TeXAtom', [mml]));

0 commit comments

Comments
 (0)