0

When I was working on a note for linear algebra, I noticed that I used \textbf{v} a lot, so I put

\newcommand{\vecv}{\textbf{v}}

at the top of the document.

But I noticed that when using it in paragraph, \vecv does not produce the correct spacing

bold v that does not space right

But using \textbf{v} works just fine

bold v that space just fine

Now why is that?

DaVarPhi
  • 199
  • 2
    LaTeX commands that doesn't accept arguments (like the one you've defined) eats the following space. Try \vecv{} instead or {\vecv} – Mane32 Feb 11 '24 at 04:46
  • So there's no way to just do it like that without the braces? – DaVarPhi Feb 11 '24 at 04:50
  • 3
    @DaVarPhi see the xspace package, although it has some caveats. – yannisl Feb 11 '24 at 05:22
  • 2
    Off-topic: Assuming that \vecv is supposed to represent a math-y object, the macro definition \newcommand{\vecv}{\textbf{v}} is wrong. Better would be \newcommand{\vecv}{\ensuremath{\mathbf{v}}}, where \ensuremath is a macro provided by the amsmath package. – Mico Feb 11 '24 at 05:44
  • If something has math meaning, put it into math mode ($... $, this gives the doc a better structure) – daleif Feb 11 '24 at 09:36
  • 1
    @Mico \ensuremath is actually from latex – David Carlisle Feb 11 '24 at 09:36
  • @DavidCarlisle - Thanks for correcting my mistake. – Mico Feb 11 '24 at 09:48
  • @DaVarPhi in practice this is rarely a problem because the space isn't needed in math mode and in text it is better to use $\vecv$ so again there is no problem to solve. Rather than define lots of such commands I would define \vec to be \mathbf and use \vec{v} so it is usable with all letters and again has no problem with spaces. – David Carlisle Feb 11 '24 at 11:49

0 Answers0