Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mathit and mathbf don't go together

2,395 views
Skip to first unread message

Gabriel

unread,
Oct 13, 2010, 12:03:00 PM10/13/10
to
I am using sansmath.sty (because the rest of the text is in sans-
serif, too).

I would like to typeset a lowercase ell in math mode with serifs and
bold, or in italics and bold.

However, none of the combinations I've tried work.
Here are some of the combinations, I have tried:
\mathbf{\mathrm{l}}
\mathrm{\mathbf{l}}
\mathnormal{\mathbf{l}}
\mathbf{\mathit{l}}
etc. ...

Could some kind soul explain to me, how to achieve the effect?
Or is it impossible?

I am using pdflatex 2007, amsmath, and sansmath like this:
\usepackage{sansmath} \sansmath
\renewcommand{\familydefault}{\sfdefault}

Thanks a lot in advance.

Best regards,
Gabriel.

Ulrike Fischer

unread,
Oct 13, 2010, 12:17:22 PM10/13/10
to
Am Wed, 13 Oct 2010 09:03:00 -0700 (PDT) schrieb Gabriel:

> I am using sansmath.sty (because the rest of the text is in sans-
> serif, too).
>
> I would like to typeset a lowercase ell in math mode with serifs and
> bold, or in italics and bold.
>
> However, none of the combinations I've tried work.
> Here are some of the combinations, I have tried:
> \mathbf{\mathrm{l}}
> \mathrm{\mathbf{l}}
> \mathnormal{\mathbf{l}}
> \mathbf{\mathit{l}}
> etc. ...
>
> Could some kind soul explain to me, how to achieve the effect?
> Or is it impossible?

Unlike the text command \textbf/\textit etc the math command doesn't
change one aspect of a font but switch to a specific font. So you
can't combine them. You will have to define a (e.g.) "\mathbfit"
math alphabet along the lines of the original definition

\DeclareMathAlphabet{\mathbf}{OT1}{cmr}{bx}{n}

sansmath declares \mathsfbf and \mathsfsl. Perhaps this is already
what you need.


--
Ulrike Fischer

Gabriel

unread,
Oct 13, 2010, 3:35:15 PM10/13/10
to

> Unlike the text command \textbf/\textit etc the math command doesn't
> change one aspect of a font but switch to a specific font. So you
> can't combine them. You will have to define a (e.g.) "\mathbfit"
> math alphabet along the lines of the original definition
>
> \DeclareMathAlphabet{\mathbf}{OT1}{cmr}{bx}{n}
>
> sansmath declares \mathsfbf and \mathsfsl. Perhaps this is already
> what you need.


Not quite, but thanks to your hints and looking at sansmath.sty, I
have now defined

\DeclareMathAlphabet{\mathrmbf}{\encodingdefault}{\rmdefault}{bx}{n}

It seems to work just fine - I hope it is a good way to do it?

Thanks a million for the quick answer!

G

Donald Arseneau

unread,
Oct 13, 2010, 7:31:50 PM10/13/10
to
Gabriel <snoop...@googlemail.com> writes:

> \DeclareMathAlphabet{\mathrmbf}{\encodingdefault}{\rmdefault}{bx}{n}
>
> It seems to work just fine - I hope it is a good way to do it?

Sounds good to me!


--
Donald Arseneau as...@triumf.ca

Will Robertson

unread,
Oct 14, 2010, 3:07:15 AM10/14/10
to
On Oct 14, 2:17 am, Ulrike Fischer <ne...@nililand.de> wrote:
>
> Unlike the text command \textbf/\textit etc the math command doesn't
> change one aspect of a font but switch to a specific font.

Off-topic slightly: I'm considering changing this for unicode-math,
since I find commands like \mathbfsfit to be a little cumbersome, and
I can see occasional scenarios where mixing \mathbf and \mathit and
\mathsf might be useful.

Do you have any thoughts on this?

Cheers,
Will

Ulrike Fischer

unread,
Oct 14, 2010, 3:53:12 AM10/14/10
to
Am Thu, 14 Oct 2010 00:07:15 -0700 (PDT) schrieb Will Robertson:


>> Unlike the text command \textbf/\textit etc the math command doesn't
>> change one aspect of a font but switch to a specific font.

> Off-topic slightly: I'm considering changing this for unicode-math,
> since I find commands like \mathbfsfit to be a little cumbersome, and
> I can see occasional scenarios where mixing \mathbf and \mathit and
> \mathsf might be useful.
>
> Do you have any thoughts on this?

On the whole (but I don't know much about unicode-math) I would say,
don't do it.

In math all fonts are carefully setup so that every command and
symbol uses a specific font: letters use the specific font for
letters, operators the font for operators. You have to declare a new
mathversion if you want to change "overall look" of the font setup.
This is by design as in math the font used for a symbol is important
for the meaning and should not change in different environments. So
I think it is inconsequent to introduce "aspect switches". If
someone needs a specific font for a specific symbol he should
declare it (and define a sensible command for the symbol so that he
doesn't have to write \mathbfsfit all the time).

Also I think you will run into technical problems: In unicode-math
all the \math...-comands probably use EU1/2-encoding. But you can't
prevent that people declare e.g.

\documentclass[11pt]{book}
\usepackage[LSF,T1]{fontenc}
\DeclareMathAlphabet{\mathchess}{LSF}{skaknew}{m}{n}
\begin{document}
$a= \mathchess{K}$
\end{document}


--
Ulrike Fischer

Donald Arseneau

unread,
Oct 14, 2010, 4:17:03 AM10/14/10
to
Ulrike Fischer <ne...@nililand.de> writes:

> Am Thu, 14 Oct 2010 00:07:15 -0700 (PDT) schrieb Will Robertson:
> > Off-topic slightly: I'm considering changing this for unicode-math,
> > since I find commands like \mathbfsfit to be a little cumbersome, and
> > I can see occasional scenarios where mixing \mathbf and \mathit and
> > \mathsf might be useful.
> >
> > Do you have any thoughts on this?
>
> On the whole (but I don't know much about unicode-math) I would say,
> don't do it.

me too.

(apologies to AOL)

--
Donald Arseneau as...@triumf.ca

Will Robertson

unread,
Oct 14, 2010, 8:13:56 AM10/14/10
to
On Oct 14, 6:17 pm, Donald Arseneau <a...@triumf.ca> wrote:
> Ulrike Fischer <ne...@nililand.de> writes:
> > Am Thu, 14 Oct 2010 00:07:15 -0700 (PDT) schrieb Will Robertson:
> > > Off-topic slightly: I'm considering changing this for unicode-math,
> > > since I find commands like \mathbfsfit to be a little cumbersome, and
> > > I can see occasional scenarios where mixing \mathbf and \mathit and
> > > \mathsf might be useful.
>
> > > Do you have any thoughts on this?
>
> > On the whole (but I don't know much about unicode-math) I would say,
> > don't do it.
>
> me too.


So what happens if someone puts a sans serif unicode math char into
\mathbf{} ? How is that different to writing \mathbf{\mathsf{A}} ?
It's not about changing fonts any more.

Unicode-math doesn't use the standard way to change math fonts because
math alphabetic glyphs have their own code points. So \mathbf and all
others are completely reimplemented.

W

Ulrike Fischer

unread,
Oct 14, 2010, 9:16:47 AM10/14/10
to
Am Thu, 14 Oct 2010 05:13:56 -0700 (PDT) schrieb Will Robertson:

> So what happens if someone puts a sans serif unicode math char into
> \mathbf{} ? How is that different to writing \mathbf{\mathsf{A}} ?

Well assuming that say mathbf points to the font FontA, and \mathsf
to FontB I would expect the first to give me the unicode math char
described by the argument from FontA and the second the glyph from
fontB

> Unicode-math doesn't use the standard way to change math fonts because
> math alphabetic glyphs have their own code points. So \mathbf and all
> others are completely reimplemented.

If this means that \mathbf{A} in unicode math is (or will)
implemented so that it doesn't insert an A (U 41) of a specific font
but switch to another glyph or to a glyph variant in the current
(unicode) math font: I think you shouldn't do this - at least not as
default. Define new commands with names that show that something new
is going on, e.g. \unimathbf, and offer an option to overload the
standard \math command by the new commands.

The list of possible \math-fonts-commands is not closed. Every
package or class can define its own variants as I did with the
\mathchess example, or sansmath is doing it. You can't reimplement
everyone and you can't really prevent people from redeclaring
\mathbf later and it will be confusing to have commands with similar
names like \mathbf, \mathcal but very different behaviour.


--
Ulrike Fischer

Will Robertson

unread,
Oct 14, 2010, 9:55:17 AM10/14/10
to
On Oct 14, 11:16 pm, Ulrike Fischer <ne...@nililand.de> wrote:
>
> If this means that \mathbf{A} in unicode math is (or will)
> implemented so that it doesn't insert an A (U 41) of a specific font
> but switch to another glyph or to a glyph variant in the current
> (unicode) math font: I think you shouldn't do this - at least not as
> default. Define new commands with names that show that something new
> is going on, e.g. \unimathbf, and offer an option to overload the
> standard \math command by the new commands.

That's a sensible suggestion. I'll see what I can do.

> The list of possible \math-fonts-commands is not closed. Every
> package or class can define its own variants as I did with the
> \mathchess example, or sansmath is doing it. You can't reimplement
> everyone and you can't really prevent people from redeclaring
> \mathbf later and it will be confusing to have commands with similar
> names like \mathbf, \mathcal but very different behaviour.

I'm not sure how (a) the behavior is very different, nor (b) how
having a different \mathbf affects the ability for another package to
create a new math variation. But Unicode-math is still fairly limited
in terms of creating new math alphabets itself.

Actually, I sort of lied above. Packages that detect the math variant
by analyzing \fam don't work with u-m. It's on my todo list to add
conditionals for explicitly testing for such things so package authors
can add Unicode-math compatibility.

W

Will Robertson

unread,
Oct 14, 2010, 10:44:08 AM10/14/10
to
On Oct 14, 11:55 pm, Will Robertson <wsp...@gmail.com> wrote:
> On Oct 14, 11:16 pm, Ulrike Fischer <ne...@nililand.de> wrote:
>
>
>
> > If this means that \mathbf{A} in unicode math is (or will)
> > implemented so that it doesn't insert an A (U 41) of a specific font
> > but switch to another glyph or to a glyph variant in the current
> > (unicode) math font: I think you shouldn't do this - at least not as
> > default. Define new commands with names that show that something new
> > is going on, e.g. \unimathbf, and offer an option to overload the
> > standard \math command by the new commands.
>
> That's a sensible suggestion. I'll see what I can do.

Actually, now that I think about this a little more, I don't think
it's possible. \mathbf et al work classically by using a variable math
class for alphabetic letters and switching fam1, but that's not
possible with Unicode-math because even the regular math italic chars
are encoded in plane 1 Unicode slots. So even plain old letters can't
have the variable math class — they must have an explicit math code
mapping from ASCII. Hence switching fams no longer works for \mathbf
and others.

I'm not in front of my machine right now so take the above with a
grain of salt but that's the impression I have at the moment. Not sure
if it makes sense?

Best regards,
Will

Ulrike Fischer

unread,
Oct 14, 2010, 10:45:00 AM10/14/10
to
Am Thu, 14 Oct 2010 06:55:17 -0700 (PDT) schrieb Will Robertson:

>> The list of possible \math-fonts-commands is not closed. Every
>> package or class can define its own variants as I did with the
>> \mathchess example, or sansmath is doing it. You can't reimplement
>> everyone and you can't really prevent people from redeclaring
>> \mathbf later and it will be confusing to have commands with similar
>> names like \mathbf, \mathcal but very different behaviour.
>
> I'm not sure how (a) the behavior is very different,

Well I would call it a different behaviour if one command switchs to
a specific (perhaps quite different) new font to typeset its
argument and the other uses a feature specific to some open type
fonts to choose a glyph or a glyph variant in the current font.

> nor (b) how having a different \mathbf affects the ability for
> another package to create a new math variation.

It won't. But it will get confusing. Assume that \mathbf uses a
unicode method, while \mathit switches to {OT1}{cmr}{m}{it}. What
will be the result of \mathbf{\mathit{A}} and \mathit{\mathbf{A}}?


--
Ulrike Fischer

Ulrike Fischer

unread,
Oct 14, 2010, 11:18:17 AM10/14/10
to
Am Thu, 14 Oct 2010 07:44:08 -0700 (PDT) schrieb Will Robertson:


>>> If this means that \mathbf{A} in unicode math is (or will)
>>> implemented so that it doesn't insert an A (U 41) of a specific font
>>> but switch to another glyph or to a glyph variant in the current
>>> (unicode) math font: I think you shouldn't do this - at least not as
>>> default. Define new commands with names that show that something new
>>> is going on, e.g. \unimathbf, and offer an option to overload the
>>> standard \math command by the new commands.
>>
>> That's a sensible suggestion. I'll see what I can do.
>
> Actually, now that I think about this a little more, I don't think
> it's possible. \mathbf et al work classically by using a variable math
> class for alphabetic letters and switching fam1, but that's not
> possible with Unicode-math because even the regular math italic chars
> are encoded in plane 1 Unicode slots. So even plain old letters can't

> have the variable math class 嚙碼 they must have an explicit math code


> mapping from ASCII. Hence switching fams no longer works for \mathbf
> and others.
>
> I'm not in front of my machine right now so take the above with a
> grain of salt but that's the impression I have at the moment. Not sure
> if it makes sense?

Only partly. I never actually looked in the details of math font
families and math classes etc. But I can see that using \setmathfont
breaks local \math-commands:

\documentclass[12pt,a4paper]{article}


\usepackage[LSF,T1]{fontenc}
\DeclareMathAlphabet{\mathchess}{LSF}{skaknew}{m}{n}

\usepackage{unicode-math}

\setmathfont{Asana-Math.otf}

\begin{document}
$abc \mathbf{abc} \mathchess{K}$

Will Robertson

unread,
Oct 14, 2010, 11:12:49 PM10/14/10
to
On Oct 15, 1:18 am, Ulrike Fischer <ne...@nililand.de> wrote:
>
> Only partly. I never actually looked in the details of math font
> families and math classes etc. But I can see that using \setmathfont
> breaks local \math-commands:

Indeed, thanks for the example. I might be able to patch
\DeclareMathAlphabet to locally reset the mathcodes of the letters in
subsequently defined alphabets. Or otherwise come up with some other
system for selecting a new font. I've added this to the unicode-math
issue tracker.

Cheers,
Will

Philipp Stephani

unread,
Oct 15, 2010, 5:37:54 AM10/15/10
to
Ulrike Fischer <ne...@nililand.de> writes:

> Am Thu, 14 Oct 2010 05:13:56 -0700 (PDT) schrieb Will Robertson:
>
>> So what happens if someone puts a sans serif unicode math char into
>> \mathbf{} ? How is that different to writing \mathbf{\mathsf{A}} ?
>
> Well assuming that say mathbf points to the font FontA, and \mathsf
> to FontB I would expect the first to give me the unicode math char
> described by the argument from FontA and the second the glyph from
> fontB

In OTF Math, there are no different fonts for different styles, but
different Unicode characters. E.g. \mathbf{A} could give U+1D468
(mathematical bold italic capital A), while \mathsf{A} might produce
U+1D608 (mathematical sans-serif italic capital A). So the old
font-changing commands are really mappings between characters in
Unicode Math.

> The list of possible \math-fonts-commands is not closed.

It is closed in the sense that exactly those characters defined by
Unicode are possible. For example, a hypothetical \mathfrakit command
is impossible because there are no italic Fraktur characters in Unicode.

> Every package or class can define its own variants as I did with the
> \mathchess example, or sansmath is doing it. You can't reimplement
> everyone and you can't really prevent people from redeclaring \mathbf
> later and it will be confusing to have commands with similar names
> like \mathbf, \mathcal but very different behaviour.

I see no other chance than to take care for all of these packages
manually. OTF Math is very different from legacy math. Even right now
unicode-math contains fixes for several packages, and many more are
broken if OTF Math is in use (e.g., almost all packages that use
\fontdimens). Defining a new command \mathchess is no problem, but any
other package that redefines some alphabet defined by unicode-math must
be rewritten or patched.

--
Change “LookInSig” to “tcalveu” to answer by mail.

Philipp Stephani

unread,
Oct 15, 2010, 5:47:02 AM10/15/10
to
Ulrike Fischer <ne...@nililand.de> writes:

> Am Thu, 14 Oct 2010 06:55:17 -0700 (PDT) schrieb Will Robertson:
>
>>> The list of possible \math-fonts-commands is not closed. Every
>>> package or class can define its own variants as I did with the
>>> \mathchess example, or sansmath is doing it. You can't reimplement
>>> everyone and you can't really prevent people from redeclaring
>>> \mathbf later and it will be confusing to have commands with similar
>>> names like \mathbf, \mathcal but very different behaviour.
>>
>> I'm not sure how (a) the behavior is very different,
>
> Well I would call it a different behaviour if one command switchs to
> a specific (perhaps quite different) new font to typeset its
> argument and the other uses a feature specific to some open type
> fonts to choose a glyph or a glyph variant in the current font.

It's quite different from the technical point of view, but not too
different from the user's point of view: \mathbf{A} produces a bold A
with or without unicode-math.

>
>> nor (b) how having a different \mathbf affects the ability for
>> another package to create a new math variation.
>
> It won't. But it will get confusing. Assume that \mathbf uses a
> unicode method, while \mathit switches to {OT1}{cmr}{m}{it}. What
> will be the result of \mathbf{\mathit{A}} and \mathit{\mathbf{A}}?

Maybe we should introduce the term "undefined behavior" for such things ;-)

Guenter Milde

unread,
Oct 16, 2010, 6:19:28 PM10/16/10
to
On 2010-10-14, Will Robertson wrote:

> So what happens if someone puts a sans serif unicode math char into
> \mathbf{} ? How is that different to writing \mathbf{\mathsf{A}} ?

IMO, the LMCR (LaTeX Math Char Representation) for "a sans serif Unicode
math char" should be \mathsf{<the char>}, so in both cases the output
should be a regular (non bold), sans-serif, upright "A" like in
"traditional" TeX).

(The question remains, whether in a sans-serif Unicode font e.g.
1D400 MATHEMATICAL BOLD CAPITAL A is "bold sans-serif A" or
"bold serif A".)

> Unicode-math doesn't use the standard way to change math fonts because
> math alphabetic glyphs have their own code points. So \mathbf and all
> others are completely reimplemented.

The mathematical alphanumeric characters block is mainly intended for
math software that has no way to represent font switches. Math
typesetting systems (TeX, MathML) now have two ways to represent these
characters: Unicode-math-char or font-specification+Unicode-base-char.
Also on the output side, there is the choice between the glyphs in the
mathematical alphanumeric characters block or base letter glyphs from a
specific font variant.

The following non-combining math families should suffice to map the
complete set of the mathematical alphanumeric characters:

Style LaTeX macro
upright serif \mathrm
bold \mathbf
italic \mathit
bold italic \mathbfit
script \mathscr (or \mathcal)
bold script \mathbfscr
fraktur \mathfrak
double-struck \mathbb
bold fraktur \mathbffrak
sans \mathsf
sans bold \mathsfbf
sans italic \mathsfit
sans bold italic \mathsfbfit
monospace \mathtt

* Like in the Unicode names, the LaTeX macro should only specify font
features that deviate from "regular, upright, serif".

* The specified style should be valid for Latin letters, Greek letters,
and Digits, regardless of the "math style" (ISO, TeX, upright) and
"math version" (bold, sans, monospace), i.e. \mathbf{\lambda} is always
1D6CC MATHEMATICAL BOLD SMALL LAMDA.

A second class of macros applies the "orthogonal" font features and
honours the "math style" setting (e.g. TeX, ISO, literal, upright):

\mathnormal regular, serif, digits upright, letters italic (with ISO style)
\mathbold bold, serif, ...
\mathsans regular, sans serif, ...
...

This could be used for math in e.g. bold section headings or sans-serif
figure captions to set it matching to the current text font (i.e. similar
to selecting a math version).

Günter

0 new messages