# Define a command for vectors, boldface letters, but not numbers

The purpose for this would be to leave scripts out of the equation. For example,

\renewcommand{\vec}[1]{\ensuremath{\mathbf{#1}}}
...
\vec{x_0}


would print the 0 as boldface, too. I know I can probably write

\renewcommand{\vec}[2][]{\ensuremath{\mathbf{#2}_{#1}}}
...
\vec[0]{x}


But that would mean I have to reformat my whole paper, which defeats the basic purpose of defining a command.

Edit: It would be awesome to keep all scripts as original, but leave all others as-is. This would be preferable.

-
but, if you don't want the 0 to be bold, wouldn't it be enough to write \vec{x}_0? Edit: While that might also mean, you have to go through your paper again, in my honest opinion \vec{x}_0 is the semantically correct way to write what you mean, i.e. that you have several vectors x0, x1,... – Ronny May 17 '13 at 12:02
@Ronny True enough. I could rewrite the paper (about 70 kB), but it would be an awesome journey into TeX if I could see how it's done. – Hameer Abbasi May 17 '13 at 12:09
I don't understand your issue. What do you want to achieve? – Marco Daniel May 17 '13 at 12:34
@MarcoDaniel I think you can now look over the answers. I want to define a command that either 1) Boldfaces everything but scripts, or 2) Boldfaces letters, but not numbers. – Hameer Abbasi May 17 '13 at 12:53

You have made an error in typing vectors after redefining \vec. The subscript mustn't go in the argument.

However, if your vectors are all of the form \vec{<single letter><optional subscript>}, that is, either \vec{v} or \vec{v_{0}}, you can solve the problem by a double command:

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


I recommend not using \ensuremath, because vectors are undoubtedly math to me. If you have many \vec outside math mode, then do

\renewcommand{\vec}[1]{\ensuremath{\innervec#1}}
\newcommand{\innervec}[1]{\mathbf{#1}}


but, for the future, restrain from using \ensuremath for this kind of things. You appear to have saved some keystrokes when typing

the vector \vec{v} is non zero


but actually you're losing information. And, anyway, you have to type

with $\vec{v}\ne\vec{0}$.

-

I agree with @egreg that you shouldn't really use this markup, but anyway:

\documentclass{article}

\renewcommand{\vec}[1]{{\mathbf{\xdef\zz{\textfont1 \the\textfont\the\fam}}\mathpalette\myvec{#1}}}
\def\myvec#1#2{\hbox{$#1\zz#2$}}
\begin{document}

$v_0+a+1$

$\mathbf{v_0}+a + 1$

$\vec{v_0}+ a + 1$

\end{document}

-
People seem to produce images so easily from TeX. Is there a way to do this within TeX SE or something? – Hameer Abbasi May 17 '13 at 12:50
@HameerAbbasi No I just take a screenshot of the pdf preview and crop it in a bitmap editor and save as png – David Carlisle May 17 '13 at 12:53