[XeTeX] On an ugly hack to mathbf only in the local style.

Herbert Schulz herbs at wideopenwest.com
Tue Oct 30 15:13:42 CET 2012

On Oct 30, 2012, at 1:21 AM, Michaël Cadilhac <michael at cadilhac.name> wrote:

> Hi there folks,
> I have gotten used to write vectors in my documents as $\vec{v}$.
> $\vec$, basically, is a mathbf.  Naturally, if I have vectors v_1,
> v_2, v_3, I'd like to write \vec{v_1}, \vec{v_2}, \vec{v_3}.  But
> here, I want to mathbf only the `v`.  Thus I used this ugly hack,
> contributed by fine people at StackExchange, which (1) saves the font
> in which a mathbf text would be displayed and (2) changes to mathbf
> ONLY the font of the current style:
> \def\vec#1{%
>  %% Gather all the fonts -- text, script, script script --.
>  \setbox0\hbox{$\mathbf{\xdef\vec at ts{\the\textfont\fam}%
>                         \xdef\vec at ss{\the\scriptfont\fam}%
>                         \xdef\vec at sss{\the\scriptscriptfont\fam}}$}%
>  \def\vec at font##1##2{##1 0=##2 ##1 1=##2}%
>  %% Return in the right style, apply the bf font ONLY for the local style.
>  \mathchoice{\hbox{$\displaystyle\vec at font{\textfont}{\vec at ts} #1$}}%
>        {\hbox{$\textstyle\vec at font{\textfont}{\vec at ts} #1$}}%
>        {\hbox{$\scriptstyle\vec at font{\scriptfont}{\vec at ss} #1$}}%
>        {\hbox{$\scriptscriptstyle\vec at font{\scriptscriptfont}{\vec at sss} #1$}}}%
> I do admit I have only the slightest clue of how this precisely works;
> especially, I'm not sure why I added \vec at font to set so many font
> families.  However, it did work, and I went with it.
> Then I switched to XeTeX --- I wanted to use the XITS fonts.  And as
> any ugly hack, mine wasn't supposed to be supported any longer; can't
> blame anyone but myself here.
> Thus I'm searching for some help to find a clean^H^H^H^H^Hworking
> solution for this problem.  Any help?
> Thanks a lot in advance!
> M.


\vec{v}_1 ?

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)

More information about the XeTeX mailing list