29

I am trying to typeset a vector with i-hat and j-hat components:

\documentclass{article}

\usepackage{amsmath}
\usepackage{mathtools}

\newcommand{\ihat}{\mathbf {\hat \imath}}
\newcommand{\jhat}{\mathbf {\hat \jmath}}
\newcommand{\vect}[1]{\mathbf #1}

\begin{document}
    \begin{align}
        \vect{F} &= 3\ihat + 4\jhat
    \end{align}
\end{document}

However, \imath and \jmath will always be italicized, no matter what modifiers I apply \mathbf, \mathrm, etc.

How do I make \imath and \jmath bold and upright?

Kit
  • 16,430

5 Answers5

33

For bold and upright, you could use the regular text-version of \imath and \jmath, which are \i and \j:

\newcommand{\ihat}{\hat{\textbf{\i}}}
\newcommand{\jhat}{\hat{\textbf{\j}}}

bold & upright i & j in math

Additionally, if you want the \hat to be bold as well, then use \boldsymbol.

\newcommand{\ihat}{\boldsymbol{\hat{\textbf{\i}}}}
\newcommand{\jhat}{\boldsymbol{\hat{\textbf{\j}}}}

Now with bold \hat

Werner
  • 603,163
  • Both these work for me as you described when converting Markdown to PDF with Pandoc (LaTeX/math in Markdown marked off with $$). But it won’t convert to Word. Removing the \ before the i or j results in the conversion working, but the dots are back. Any ideas? Should I ask somewhere else? – lukejanicke Feb 20 '17 at 05:30
  • @lukejanicke: I don't know what might be happening converting to Word. Perhaps another math font is used that doesn't have that dotless symbol. Try adding \usepackage{dotlessi} to your preamble (as part of header-includes). – Werner Feb 20 '17 at 06:57
  • I'm currently drafting in Markdown with embedded LaTeX/math but if I have more similar issues I may consider starting to draft in full TeX/LaTeX and then I can try your suggestion. Thanks for the tip. – lukejanicke Feb 20 '17 at 20:39
18
\DeclareMathSymbol{\ii}{\mathalpha}{letters}{"10}
\DeclareMathSymbol{\jj}{\mathalpha}{letters}{"11}

\newcommand{\ihat}{\mathbf {\hat{\ii}}}
\newcommand{\jhat}{\mathbf {\hat{\jj}}}
\newcommand{\vect}{\mathbf}

The last line is a better definition of your \vect command.

egreg
  • 1,121,712
  • 1
    Thank you. Your answer worked where Werner's did not, for my document that uses non-CM text fonts (where \j was not defined). – Steven B. Segletes Jan 05 '16 at 17:15
  • \boldsymbol is better than \mathbf for vectors. – skvery Apr 15 '20 at 17:13
  • 1
    @skvery That's a personal style choice. The OP seems to prefer \mathbf. – egreg Apr 15 '20 at 17:17
  • @egreg Not really. The ISO standard specifies 'bold italic'. Can you maybe assist with my question using your answer. – skvery Apr 15 '20 at 17:41
  • @skvery The ISO standard is mandatory for some fields, mainly technical. Certainly not for pure mathematics. I have happily used upright bold for many years and the ISO police hasn't yet caught me. ;-) – egreg Apr 15 '20 at 19:36
  • @egreg my challenge: upright \jmath in MathJax, lol. – skvery Apr 15 '20 at 20:29
  • @skvery The main problem is that the people at Unicode didn't think to a bold dotless j. Why? Don't ask me. – egreg Apr 15 '20 at 20:33
3
\newcommand{\ihat}{\textbf{\^\i}}
\newcommand{\jhat}{\textbf{\^\j}}

This is a simplification of Werner's answer.

2

If you can use it, the unicode-math package declares the \mathbfup alphabet, or \symbfup. For single letters, the difference is not important. If you load one of the math fonts that comes in a bold version (As of 2019, XITS Math, Libertinus Math or Minion Math), \boldsymbol will still work.

Davislor
  • 44,045
0

You can define in your preamble a new command with an optional parameter, which would be the letter you want to hat. This could be something like

\newcommand{\uvec}[1]{\textbf{\^{#1}}}

where you must put the command in the form \uvec{\yourletter}. The "\" before the letter is necessary in order to avoid the i's and j's dots. For example, if you want to type the unit vector in x direction you must use \uvec{\i} or $\uvec{\i}$. This command works in both text and math mode and gives the same results. Also is for every letter, not only i or j.

  • 2
    Your suggestion doesn't work. Please test it again and show an example how to use your proposal. – Zarko Oct 28 '19 at 05:38
  • What is the \text command suppose to do here? (hint: not needed, might even be rather bad, chech what happens if the text context outside math is italic. If I'm not mistaken vecbf will then also be italic – daleif Feb 10 '20 at 07:59
  • You're right daleif, in this new update I simplified the command and expanded the explanation a little bit. – AxlPadilla May 10 '20 at 08:05