7

One would define \mathbf as say:

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

I was wondering, then with that, how \mathbf would be defined? (what is its meaning?).

  • 3
    You should try \def\pshow#1{{\let\protect\show #1}} \pshow\mathbf, as suggested by The definitions of LaTeX commands. – Werner Jun 25 '12 at 18:07
  • Sorry to bother you; in this question http://tex.stackexchange.com/a/71393/3954 I proposed the use of the floatrow package, but then the OP mentioned an incompatibility with your bidi package. Is there a workaround to make the floatrow package cooperate with bidi? – Gonzalo Medina Sep 13 '12 at 15:28
  • Regarding the issue I mentioned in my previous comment, I found a workaround and included it in my answer (link in previous comment). Anyways, if you could take a look, that would be ideal. – Gonzalo Medina Sep 14 '12 at 02:00

2 Answers2

6

Run the following through LaTeX

\makeatletter
\show\mathbf
\expandafter\show\csname mathbf \endcsname
\show\select@group
\expandafter\show\csname M@OT1\endcsname
\show\default@M

You'll get

> \mathbf=macro:
->\protect \mathbf  .

> \mathbf =macro:
->\select@group \mathbf  \M@OT1 \OT1/cmr/bx/n .

> \select@group=macro:
#1#2#3#4->\ifx \math@bgroup \bgroup \else \relax \expandafter \@firstofone \fi 
{\ifmmode \ifnum \csname c@mv@\math@version \endcsname <\sixt@@n \begingroup \e
scapechar \m@ne \getanddefine@fonts {\csname c@mv@\math@version \endcsname }#3\
globaldefs \@ne \math@fonts \endgroup \init@restore@version \xdef #1{\noexpand 
\use@mathgroup \noexpand #2{\number \csname c@mv@\math@version \endcsname }}\gl
obal \advance \csname c@mv@\math@version \endcsname \@ne \else \let #1\relax \@
latex@error {Too many math alphabets used in version \math@version }\@eha \fi \
else \expandafter \non@alpherr \fi #1{#4}}.

> \M@OT1=macro:
->\default@M .

> \default@M=macro:
->.

It's quite frightening, but not too much.

The bulk of course is \select@group, which must check whether the corresponding mathgroup (math family in TeXbook terminology) has already been allocated. Then essentially it opens a group, sets the mathgroup and typesets the argument, unless the command has been given outside of math mode.

egreg
  • 1,121,712
5

Rather than looking straight at the code with \meaning, \show, \tracingall or the like it might be interesting to read the main articles on NFSS (the then New Font Selection Scheme). They are a bit aged now (1989 :-) ) so they predate LaTeX2e and even TeX3, but I think they will give you some ideas, especially the first one, on the underlying concepts. Be aware though that these papers describe the initial version of NFSS. For LaTeX2e some interfaces got changed and we further optimized the code for speed and compactness.

NFSS base macros in Tugboat 1989

NFSS user interface in Tugboat 1990

The current code (and its documentation) can be found as part of the LaTeX distribution, look for files called ltfsssomething.dtx and typeset them. They are fairly well documented (give or take) but the documentation mainly concerns the micro level not the big picture.

  • Thanks. Could you please have a look at this question of mine too: http://tex.stackexchange.com/questions/61212/redefining-mathbf-without-using-a-new-math-alphabet – Vafa Khalighi Jun 26 '12 at 04:20