Skip to content

Commit 701e494

Browse files
committed
in Units context, don't use a number-unit separator for certain units
1 parent 41ec626 commit 701e494

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

macros/contexts/contextUnits.pl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,11 +1525,17 @@ sub string {
15251525
my $unit = $self->unit;
15261526
my $u = context::Units::Context::pretty($unit->stringFor('nunits', 'dunits', $unit->{order}, 0, 1));
15271527
my $string = $self->number->string;
1528-
$string .= substr($u, 0, 1) eq '/' ? $u : " $u";
1528+
$string .= substr($u, 0, 1) eq '/' || noSeparator($u) ? $u : " $u";
15291529
$string = '(' . $string . ')' if defined($precedence) && $precedence > 1;
15301530
return $string;
15311531
}
15321532

1533+
sub noSeparator {
1534+
my $u = shift;
1535+
return 1 if ($u =~ /^(\x{00B0}|\x{2103}|\x{00B0}F)$/);
1536+
return 0;
1537+
}
1538+
15331539
#
15341540
# Get the TeX version of the Number with Units
15351541
#
@@ -1541,7 +1547,7 @@ sub TeX {
15411547
if (substr($u, 0, 1) eq '/') {
15421548
$tex = "\\frac{$tex}{" . $unit->raiseUnit(-1, 1)->with(negativePowers => {})->TeX . '}';
15431549
} else {
1544-
$tex .= '\\,' . $unit->TeX;
1550+
$tex .= (noSeparator($unit) ? '' : '\\,') . $unit->TeX;
15451551
}
15461552
$tex = '(' . $tex . ')' if defined($precedence) && $precedence > 1;
15471553
return $tex;

0 commit comments

Comments
 (0)