Correctly order units in siunitx formatting

Close #441
This commit is contained in:
Hernan Grecco
2016-11-17 00:28:49 -03:00
parent 2fa76c2cfd
commit fdab9d96ef

View File

@@ -243,11 +243,14 @@ def siunitx_format_unit(units):
# limit float powers to 3 decimal places
return r'\tothe{{{:.3f}}}'.format(power).rstrip('0')
l = []
lpos = []
lneg = []
# loop through all units in the container
for unit, power in sorted(units._units.items()):
# remove unit prefix if it exists
# siunitx supports \prefix commands
l = lpos if power >= 0 else lneg
prefix = None
for p in registry._prefixes.values():
p = str(p)
@@ -262,7 +265,7 @@ def siunitx_format_unit(units):
l.append(r'\{0}'.format(unit))
l.append(r'{0}'.format(_tothe(abs(power))))
return ''.join(l)
return ''.join(lpos) + ''.join(lneg)
def remove_custom_flags(spec):