Undesired parenthesis

Hello,

Please, take a look at following command:

Print[Framed["v =" NumberForm[Quantity[10.38, ("Meters")/("Seconds")], 2]]]

The output shows an undesired pair of parenthesis wrapping the right hand side of the equation. Does anyone knows how to get rid of them?

Anderson

Framed[
Text[Row[{“v = " , NumberForm[10.38, {4, 2}], " meters/second”}]]]

Thanks for replying, but the argument of NumberForm function cannot be changed.

Use the following instead:

Print[Framed[
  Row[{"v = ", 
    NumberForm[Quantity[10.38, ("Meters")/("Seconds")], 2]}]]]

The issue you were having was because "v=" NumberForm[...] means Times["v=",NumberForm[...]] and so the syntax form of the underlying quantity was taking over, because a string times a quantity doesn’t evaluate. Another example of this would be:

"v=" RawBoxes@InterpretationBox[10, 10, SyntaxForm -> Mod]

You don’t have to change the argument to NumberForm (did you try that)? Also Text is not needed though to my eye it is useful for formatting. The point of the response by @S.M.Blinder is that using Row is the correct way to go about this. The original code involves an implicit multiplication, and that causes the parens to be added.

For completeness, this could be done as:

Framed[Text[
  Row[{"v = ", 
    NumberForm[Quantity[10.38, ("Meters")/("Seconds")], 2]}]]]

Thanks. Your solution is almost perfect, except by the lost of the output format.

Perfect. Thanks a lot.

Did you miss the part “Also Text is not needed though to my eye it is useful for formatting”? It’s there for a reason..

Thanks a lot. Nice solution. The use of Text can be very useful sometimes.

If you are fastidious about the proper math formating (fonts and spacings), try this:

Print[Framed[
DisplayForm@
FormBox[RowBox[{“v”, “=”,
NumberForm[Quantity[10.38, (“Meters”)/(“Seconds”)], 2]}],
TraditionalForm]]]

I found out about FormBox by hitting the menu Cell > Show Expression.

This was really something! Thanks.