@@ -781,7 +781,7 @@ sub addUnit {
781781 $constants -> add(
782782 $name => {
783783 value => context::Units::Unit-> new($name => $unit ),
784- TeX => " \\ text{$name }" ,
784+ TeX => " \\ text{" . pretty( $name ) . " }" ,
785785 isUnit => 1,
786786 isConstant => 1
787787 }
@@ -795,6 +795,27 @@ sub addUnit {
795795 return $self ;
796796}
797797
798+ sub pretty {
799+ my $name = shift ;
800+ my %prettyName = (
801+ angstrom => " \x{00C5} " ,
802+ deg => " \x{00B0} " ,
803+ degC => " \x{2103} " ,
804+ degF => " \x{00B0} F" ,
805+ degK => " \x{212A} " ,
806+ ohm => " \x{2126} " ,
807+ kohm => " k\x{2126} " ,
808+ Mohm => " M\x{2126} " ,
809+ uC => " \x{00B5} C" ,
810+ uF => " \x{00B5} F" ,
811+ um => " \x{00B5} m" ,
812+ uN => " \x{00B5} N" ,
813+ us => " \x{00B5} s" ,
814+ uSv => " \x{00B5} Sv" ,
815+ );
816+ return defined $prettyName {$name } ? $prettyName {$name } : $name ;
817+ }
818+
798819#
799820# Adds all the aliases for a given named unit or unit definition
800821#
@@ -1315,7 +1336,7 @@ sub cmp_postprocess {
13151336#
13161337sub string {
13171338 my ($self , $equation , $open , $close , $precedence ) = @_ ;
1318- my $string = $self -> stringFor(' nunits' , ' dunits' , $self -> {order });
1339+ my $string = context::Units::Context::pretty( $self -> stringFor(' nunits' , ' dunits' , $self -> {order }) );
13191340 $string = ' (' . $string . ' )' if $string =~ m ![ /] ! && defined ($precedence ) && $precedence > 2.9;
13201341 return $string ;
13211342}
@@ -1502,7 +1523,7 @@ sub quantity {
15021523sub string {
15031524 my ($self , $equation , $open , $close , $precedence ) = @_ ;
15041525 my $unit = $self -> unit;
1505- my $u = $unit -> stringFor(' nunits' , ' dunits' , $unit -> {order }, 0, 1);
1526+ my $u = context::Units::Context::pretty( $unit -> stringFor(' nunits' , ' dunits' , $unit -> {order }, 0, 1) );
15061527 my $string = $self -> number-> string;
15071528 $string .= substr ($u , 0, 1) eq ' /' ? $u : " $u " ;
15081529 $string = ' (' . $string . ' )' if defined ($precedence ) && $precedence > 1;
0 commit comments