How to type a particular kind of unit vector?
You have to use \i
and \j
, which means you need to switch to text mode. However, there is a problem that text fonts in math mode inherit the attributes of the context, so, for example, $\textbf{\i}$
would give a bold italic dotless i in a theorem statement.
\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\newcommand{\uveci}{{\bm{\hat{\textnormal{\bfseries\i}}}}}
\newcommand{\uvecj}{{\bm{\hat{\textnormal{\bfseries\j}}}}}
\DeclareRobustCommand{\uvec}[1]{{%
\ifcsname uvec#1\endcsname
\csname uvec#1\endcsname
\else
\bm{\hat{\mathbf{#1}}}%
\fi
}}
\begin{document}
$\uveci\ne\hat{\imath}_{\uvec{i}}+\uvec{j}+\uvec{k}$
\end{document}
You can type both \uveci
and \uvec{i}
for uniformity, the same for a ājā.
You can't use the times
package for this; first of all because it's obsolete, but even its substitute, that is mathptmx
, doesn't provide a dotless j. You can use newtxtext
and newtxmath
:
\documentclass{article}
\usepackage{newtxtext,newtxmath}
\usepackage{amsmath}
\usepackage{bm}
\newcommand{\uveci}{{\bm{\hat{\textnormal{\bfseries\i}}}}}
\newcommand{\uvecj}{{\bm{\hat{\textnormal{\bfseries\j}}}}}
\DeclareRobustCommand{\uvec}[1]{{%
\ifcsname uvec#1\endcsname
\csname uvec#1\endcsname
\else
\bm{\hat{\mathbf{#1}}}%
\fi
}}
\begin{document}
Some text for showing that Times is being used.
$\uveci\ne\hat{\imath}_{\uvec{i}}+\uvec{j}+\uvec{k}$
\end{document}
With newTX you also have the possibility of getting upright lowercase Greek letters. Here's how to do it; I also added the possibility of typing \uvec{\alpha}
. Please, be aware of the fact that the argument of \uvec
must be a single Latin character (not \i
or \j
, which are unnecessary and illegal for the macro) or a single Greek symbol.
\documentclass{article}
\usepackage{newtxtext}
\usepackage{newtxmath}
\usepackage{amsmath}
\usepackage{bm}
\newcommand{\uveci}{{\bm{\hat{\textnormal{\bfseries\i}}}}}
\newcommand{\uvecj}{{\bm{\hat{\textnormal{\bfseries\j}}}}}
\DeclareRobustCommand{\uvec}[1]{{%
\ifcat\relax\noexpand#1%
% it should be a Greek letter
\bm{\hat{#1}}%
\else
\ifcsname uvec#1\endcsname
\csname uvec#1\endcsname
\else
\bm{\hat{\mathbf{#1}}}%
\fi
\fi
}}
% for upright lowercase Greek; newtxmath hasn't an option for this
\let\alpha\alphaup
\let\beta\betaup
\let\gamma\gammaup
\let\delta\deltaup
\let\epsilon\epsilonup
\let\zeta\zetaup
\let\eta\etaup
\let\theta\thetaup
\let\iota\iotaup
\let\kappa\kappaup
\let\lambda\lambdaup
\let\mu\muup
\let\nu\nuup
\let\xi\xiup
\let\pi\piup
\let\rho\rhoup
\let\sigma\sigmaup
\let\tau\tauup
\let\upsilon\upsilonup
\let\phi\phiup
\let\chi\chiup
\let\psi\psiup
\let\omega\omegaup
\let\varepsilon\varepsilonup
\let\vartheta\varthetaup
\let\varpi\varpiup
\let\varrho\varrhoup
\let\varsigma\varsigmaup
\let\varphi\varphiup
%%
\begin{document}
Some text for showing that Times is being used.
$\uveci\ne\hat{\imath}_{\uvec{i}}+\uvec{j}+\uvec{k}$
$\uvec{\alpha}+\uvec{\Gamma}+A$
\end{document}
Note
The Times font is by no means necessary and the code works as well with the standard fonts.
\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\newcommand{\uveci}{{\bm{\hat{\textnormal{\bfseries\i}}}}}
\newcommand{\uvecj}{{\bm{\hat{\textnormal{\bfseries\j}}}}}
\DeclareRobustCommand{\uvec}[1]{{%
\ifcat\relax\noexpand#1%
% it should be a Greek letter
\bm{\hat{#1}}%
\else
\ifcsname uvec#1\endcsname
\csname uvec#1\endcsname
\else
\bm{\hat{\mathbf{#1}}}%
\fi
\fi
}}
\begin{document}
$\uveci\ne\hat{\imath}_{\uvec{i}}+\uvec{j}+\uvec{k}$
$\uvec{\xi}+\uvec{\Gamma}+A$
\end{document}
\documentclass{article}
\usepackage{bm}
\newcommand{\uvec}[1]{\boldsymbol{\hat{\textbf{#1}}}}
\begin{document}
$\uvec{\i} \uvec{\j} \uvec{k}$
\end{document}