LaTeX – bold vectors and arrow vectors

Lately I’m writing a lot of papers in \LaTeX and every once and a while something comes up that drives me crazy trying to figure out.

Here’s how to easily switch between a bold vector \boldsymbol{x}  and an arrow vector \vec{x}  .

 
% Minimal latex example:
% Shows how to switch between bold and arrow vectors.
 
% Specifies the type of document you have.
\documentclass{article}
 
% Used for the boldsymbol.
\usepackage{amsmath}
 
% Comment this out to represent vectors with an arrow on top.
% Uncomment this to represent vectors as bold symbols.
\renewcommand{\vec}[1]{\boldsymbol{#1}}
 
% Start of the document.
\begin{document}
 
% Your content.
My lovely vector: $\vec{x}$
 
% End of the document.
\end{document}

And that’s it! By commenting and un-commenting the \renewcommand{\vec}[1]{\boldsymbol{#1}} line, you can toggle between representing vectors with an arrow on top or bold.

This solution was modified based on fbianco’s comment in the comment section. Thanks fbianco!

I’ve left my original text below, but it’s no longer recommended.


January 3, 2017. This text below was my earlier approach. I recommend you use the above

I got this idea from D.H here and I thought it was worth expanding a bit more.

First, make sure you include,

\usepackage{amsmath} % used for boldsymbol.

at the top of your .tex file. Then add these two lines somewhere underneath.

\newcommand{\vect}[1]{\boldsymbol{#1}} % Uncomment for BOLD vectors.
%\newcommand{\vect}[1]{\vec{#1}} % Uncomment for ARROW vectors.

Now when you are writing your vectors, instead of using \vec{}, you use \vect{}. This allows you to easily toggle between the two different modes.

\usepackage{amsmath} % used for boldsymbol.
\newcommand{\vect}[1]{\boldsymbol{#1}} % Uncomment for BOLD vectors.
%\newcommand{\vect}[1]{\vec{#1}} % Uncomment for ARROW vectors.
 
% Some other text here...
 
My lovely bold vector $\vect{x}$.

This will display the boldface vectors \boldsymbol{x}.

Whereas, this,

\usepackage{amsmath} % used for boldsymbol.
%\newcommand{\vect}[1]{\boldsymbol{#1}} % Uncomment for BOLD vectors.
\newcommand{\vect}[1]{\vec{#1}} % Uncomment for ARROW vectors.
 
% Some other text here...
 
My lovely arrow vector $\vect{x}$.

Will produce an arrow vector \vec{x}.

Now if anyone ever asks you to change how your vectors look in a paper, you can smile at them :D.

3 thoughts on “LaTeX – bold vectors and arrow vectors”

  1. The easiest is to use renewcommand this will change existing arrow vector by bold vector :

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

    By the way, thanks for the boldsymbol tricks.

Questions/comments? If you just want to say thanks, consider sharing this article or following me on Twitter!