I'm trying to use the siunitx
package to format a number which is a vector (using \hat{x}
to represent a vector in the x direction). Using \hat{x}
leads to complaints about invalid tokens.
After seeing this question, I tried including
\sisetup{input-symbols=\hatx\haty}
\protected\def\hatx{\ensuremath{\hat{x}}}
\protected\def\haty{\ensuremath{\hat{y}}}
to my preamble. Then, I get siunitx error: "misplaced-sign-token" Misplaced sign token '+'.
For completeness, here's what I am trying now:
\documentclass{article}
\usepackage{siunitx}
\sisetup{input-symbols=\hatx\haty}
\protected\def\hatx{\ensuremath{\hat{x}}}
\protected\def\haty{\ensuremath{\hat{y}}}
\begin{document}
\begin{equation}
\vec{F} = \SI{-3.24e-20\hatx + 4.56e-18\haty}{\newton}
\end{equation}
\end{document}
Any ideas how I can get this kind of thing to work properly?
Best Answer
One way to do this is to simply use:
Code: