0

I am using:

\usepackage{unicode-math}
\setmainfont{Latin Modern Math}
\setmainfont{Latin Modern Roman}

to help typeset mathematical notation with XeLaTeX. I used the following to change typesetting vectors with an arrow above to bold face:

\AtBeginDocument{\renewcommand{\vec}[1]{\symbfit{#1}}}

However, if I have an arrow above a number, that number will not get bolded. Instead, the arrow above the number will just disappear and only the number itself remains. How do I fix this?

4
  • Do you want the arrow to be bold as well? Or just the number?
    – Marijn
    Commented Apr 1, 2021 at 9:25
  • Just the number. The goal is to change all arrows to italic bold to indicate vectors.
    – user238811
    Commented Apr 1, 2021 at 9:31
  • I don't think Latin Modern Math has bold+italic for numbers, note that \symbf{\vec{3}} works (bold only) but \symbfit{\vec{3}} does not work (the number is upright and not bold). You could try another font.
    – Marijn
    Commented Apr 1, 2021 at 9:36
  • Actually I wouldn't mind if the numbers are not italic bold. However, I wish to italic bold alphabets. Is there a way to redefine commands such that the alphabets are italic bold while the numbers are bold upright?
    – user238811
    Commented Apr 1, 2021 at 9:40

1 Answer 1

0

You can define a command that tests if the argument is an integer. If this is the case then you can print a bold symbol (using \symbf) with a vector arrow, and if it is false then you can print a bold+italic symbol (using \symbfit) with a vector arrow. The integer test \IfInteger is provided by the xstring package.

MWE:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{xstring}
\setmathfont{Latin Modern Math}
\newcommand{\vecbfit}[1]{%
\IfInteger{#1}{%
\symbf{\vec{#1}}}{% true
\symbfit{\vec{#1}}}% false
}
\begin{document}
$\vecbfit{3} \vecbfit{A}$
\end{document}

Result:

enter image description here

You must log in to answer this question.