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?).
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?).
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.
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.
\def\pshow#1{{\let\protect\show #1}} \pshow\mathbf, as suggested by The definitions of LaTeX commands. – Werner Jun 25 '12 at 18:07bidipackage. Is there a workaround to make thefloatrowpackage cooperate withbidi? – Gonzalo Medina Sep 13 '12 at 15:28