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

Michaël Cadilhac michael at cadilhac.name
Tue Oct 30 15:39:30 CET 2012

On Tue, Oct 30, 2012 at 10:13 AM, Herbert Schulz <herbs at wideopenwest.com> wrote:
> 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.
> Howdy,
> \vec{v}_1 ?


Thanks, but of course, I'd like to avoid going through hundreds of pages (ok,
a script would be easy to write, but still...).  Also, I'd like to keep the
semantics "\vec{T} is for a vector T", whether T=v or T=v_1.



More information about the XeTeX mailing list