0
|
8143 Views
|
10 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# Undesired parenthesis

Posted 10 years ago
 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 Attachments:
10 Replies
Sort By:
Posted 10 years ago
 This was really something! Thanks.
Posted 10 years ago
 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.
Posted 10 years ago
 Thanks a lot. Nice solution. The use of Text can be very useful sometimes.
Posted 10 years ago
 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..
Posted 10 years ago
 Perfect. Thanks a lot.
Posted 10 years ago
 Thanks. Your solution is almost perfect, except by the lost of the output format.
Posted 10 years ago
 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]}]]] 
Posted 10 years ago
 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] 
Posted 10 years ago
 Thanks for replying, but the argument of NumberForm function cannot be changed.
Posted 10 years ago
 Framed[ Text[Row[{"v = " , NumberForm[10.38, {4, 2}], " meters/second"}]]] 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.