Lately I’m writing a lot of papers in 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 and an arrow vector
.
% 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 .
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 .
Now if anyone ever asks you to change how your vectors look in a paper, you can smile at them :D.
I tried this, but mine appears as only bold, instead of bold and italic
Hi walala, I just updated this post to include a fully working example in LaTeX. Could you try that?
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.