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

Tobias Schoel liesdiedatei at googlemail.com
Wed Oct 31 07:19:14 CET 2012


I'm not quite sure, if I have understood the OP correctly. But if he 
wants just the first letter to be bold, than the following seems to 
works just ok:

\renewcommand{\vec}[1]{\mathbf #1}

As LaTeX only reads the next “thing” after a command as the argument, if 
not grouped by {}, then only the first letter of the argument is passed 
to \mathbf.

If more than one letter needs to be bold, than you can put that part 
into a command (but Ross' reply would be preferable in all cases):

So try this out:

\documentclass{minimal}
\renewcommand{\vec}[1]{\mathbf #1}
\newcommand{\hallo}{hallo}
\begin{document}
\[\vec{x_1} \qquad \vec{\hallo_1} \qquad \vec{x^1} \qquad \vec{\hallo^1}\]
\end{document}

ciao

Tobias


On 31.10.2012 01:16, Zdenek Wagner wrote:
> 2012/10/30 Michaël Cadilhac <michael at cadilhac.name>:
>> On Tue, Oct 30, 2012 at 10:53 AM, Zdenek Wagner <zdenek.wagner at gmail.com> wrote:
>>> 2012/10/30 Michaël Cadilhac <michael at cadilhac.name>:
>>>> Hi there folks,
>>
>>> How about the following solution? I am writing it directly to the mail
>>> without testing, I hope I won't make any error.
>>>
>>> \def\vec#1{\do at vec#1_\do at vec}
>>> \def\do at vec#1_#2\do at vec{\ifcat$#2$\mathbf{#1}\else\vec at subscript#1_#2\vec at subscript\fi}
>>> \def\vec at subscript#1_#2_\vec at subscript{\mathbf{#1}_{#2}}
>>
>> Zdeněk,
>>
>> Thanks for your input!  However, I also have vectors such as \vec{x^i_j} (or
>> \vec{x_j^i}), and your solution does not seem to have a simple extension to
>> those cases.  The original hack I had had the advantage that no syntactic
>> manipulation had to be made on the argument, avoiding for sure those
>> problems.  If we have to do this syntactically, I'll think about it some
>> more.
>>
> If the vector is always one letter with optional
> subscripts/superscript, a simpler solution can work:
>
> \def\vec#1{\do at vec#1\do at vec}
> \def\do at vec#1#2\do at vec{\ifcat$#2$\mathbf{#1}\else\mathbf{#1}#2\fi}
>
> I am not sure whether math atoms will be properly recognised if the
> second macro is defined just as
>
> \def\do at vec#1#2\do at vec{\mathbf{#1}\ifcat$#2$\else#2\fi}
>
>> Thanks again!
>>
>> M.
>>
>>
>>
>> --------------------------------------------------
>> Subscriptions, Archive, and List information, etc.:
>>    http://tug.org/mailman/listinfo/xetex
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mull.pdf
Type: application/pdf
Size: 2418 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20121031/ccb2d35f/attachment.pdf>


More information about the XeTeX mailing list