Changes

Jump to navigation Jump to search
2,258 bytes added ,  23:09, 5 January 2009
Old definitions
I am moving the old definitions here. <code>boldsymbol</code> is now defined in core.

== Wrapping in a \hbox ==

If the solution presented in that MyWay does not suit your needs, you can always use a \hbox wrapper, by defining something like this:
<texcode>
\definetypeface [boldmath] [mm] [boldmath] [latin-modern] [default]
\setupformulae[method=bold]
\unprotect
\def\boldsymbol@normal#1{\hbox{\formula[boldmath]{#1}}}
\def\boldsymbol@inline{\boldsymbol@normal}
\def\boldsymbol@script#1{\hbox{\formula[boldmath,script]{#1}}}
\def\boldsymbol@scriptscript#1{\hbox{\formula[boldmath,scriptscript]{#1}}}
\def\boldsymbol#1{%
\mathchoice
{\boldsymbol@normal{#1}}%
{\boldsymbol@normal{#1}}%
{\boldsymbol@script{#1}}%
{\boldsymbol@scriptscript{#1}}}
\protect
</texcode>

Then you can get bold vectors:
<texcode>
\define\grad{\boldsymbol{\nabla}}
%\define\vec{\boldsymbol} % Raise a warning because \vec
\def\vec{\boldsymbol} % is already defined in ConTeXt.
\define[1]\unitvec{{\hat{\vec{#1}}}}
</texcode>

and formulas like this typeset perfectly:

<texcode>
\formula{\grad \eta = e^{\vec k \cdot \vec x} \unitvec{n}}
</texcode>

== An Alternate Definition ==
An alternate way to define <cmd>boldsymbol</cmd> is

<context source="yes">
\definetypeface [boldmath] [mm] [boldmath] [latin-modern] [modern] [encoding=texnansi]


\unprotect
\def\boldsymbol#1%
{\preparebinrel{#1}%
\currentbinrel
{\mathchoice
{\hbox{\switchtoformulabodyfont [boldmath]$\m@th#1$}}
{\hbox{\switchtoformulabodyfont [boldmath]$\m@th#1$}}
{\hbox{\switchtoformulabodyfont [boldmath,script]$\m@th#1$}}
{\hbox{\switchtoformulabodyfont[boldmath,scriptscript]$\m@th#1$}}}}
\protect

% The previous example again
\def\grad{\boldsymbol{\mathop{\nabla}}}
% The correct way to define this is
% \def\grad{\mathop{\boldsymbol{\nabla}}}
% The former is used just to show that \boldsymbol gives the correct
% spacing for mathop
\def\vec{\boldsymbol}
\def\unitvec#1{{\hat{\vec{#1}}}}

$\grad \eta = e^{\vec k \cdot \vec x} \unitvec{n}$
</context>

The <cmd>preparebinrel</cmd> and <cmd>currentbinrel</cmd> ensure that the correct spacing is used around the symbol.
This is slightly more efficient than the first version.

Navigation menu