10

When I am typing a laboratory for physics, I tried using \overline inside SI from the siunitx package, like so:

\begin{align}
\begin{split}
s &= \frac{d}{t}\\
&= \frac{\SI{1.15}{m}}{\SI{1.43}{s}}\\
&= \SI{0.\overline{804195}}{m/s}
\end{split}
\end{align}

But it seems that it does not work when you have \overline inside SI, does anyone know how to fix this?

migrated from stackoverflow.com Feb 8 '13 at 10:05

This question came from our site for professional and enthusiast programmers.

  • Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Feb 8 '13 at 15:09
12

You can also set the number parsing off temporarily.

\documentclass{article}
\usepackage{amsmath,siunitx}

\begin{document}
\begin{align}
\begin{split}
s &= \frac{d}{t}\\
&= \frac{\SI{1.15}{m}}{\SI{1.43}{s}}\\
&= \SI[parse-numbers=false]{0.\overline{804195}}{m/s}
\end{split}
\end{align}
\end{document}

enter image description here

  • For a more "canonical" usage of \SI, you may want to write \frac{\SI{1.15}{\meter}}{\SI{1.43}{\second}} and \SI[parse-numbers=false,per-mode=symbol]{0.\overline{804195}}{\meter\per\second}. I.e., let siunitx do the mapping from \meter and \second to the letters m and s. – Mico Jun 9 '16 at 9:12
  • 1
    @Mico True but note that the literal mode of siunitx is also canonical as opposed to interpreted mode. The units here don't matter much as overline is the emphasis. – percusse Jun 9 '16 at 10:06
2

This does sort-of defeat the purpose of using siunitx, but it's possible with some box manipulation:

enter image description here

\documentclass{article}
\usepackage{siunitx,amsmath}% http://ctan.org/pkg/{siunitx,amsmath}
\begin{document}
\begin{align*}
    s &= \frac{d}{t} \\
     &= \frac{\SI{1.15}{m}}{\SI{1.43}{s}} \\
     &= \rlap{$\phantom{0.}\overline{\phantom{804\,195}}$}\SI{0.804195}{m/s}
\end{align*}
\end{document}

I've pre-set an invisible 0.804\,195 with a visible \overline (only over the necessary part) using a right overlap (a zero-width, left-aligned box). After this, \SI sets things as usual, this time "underneath" the \overline so it looks appropriate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.