Best Unit Vectors in LaTeX for TeX.SE Interaction

Click For Summary
SUMMARY

The discussion on TeX.SE centers around a code snippet provided by user egreg for creating unit vectors in LaTeX using the packages newtxtext, newtxmath, and amsmath. The code defines commands for upright Greek letters and unit vectors, allowing for the use of \uvec{i}, \uvec{\rho}, and \uvec{\varphi}. It is noted that the code is incompatible with the times package and that the resulting unit vectors are visually satisfactory, although some journals may require the traditional \hat{i} notation.

PREREQUISITES
  • Familiarity with LaTeX typesetting
  • Understanding of the newtxtext and newtxmath packages
  • Knowledge of the amsmath package
  • Basic concepts of vector notation in mathematics
NEXT STEPS
  • Explore advanced features of the newtxmath package
  • Learn about compatibility issues between LaTeX packages
  • Research the use of custom commands in LaTeX
  • Investigate journal requirements for mathematical notation in LaTeX
USEFUL FOR

Mathematicians, physicists, and LaTeX users who require precise formatting of unit vectors and Greek letters in their documents.

Ackbach
Gold Member
MHB
Messages
4,148
Reaction score
94
During an interaction on TeX.SE, egreg there posted some truly awesome code for doing unit vectors in $\LaTeX$:

Code:
\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

Comments:

1. This code is not compatible with the times package.

2. Usage: \uvec{i} or \uvec{\rho} or \uvec{\varphi}.

3. The Greek unit vectors are upright.

4. For \uvec{i} and \uvec{j}, this code will leave off the dots, letting the hat take their place. I think the result is highly satisfactory.
 
Physics news on Phys.org
Some journals may not accept anything but ##\hat{i}##. But thanks for sharing, anyway.
 
  • Like
Likes   Reactions: Ackbach

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
17K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K