Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am attempting to do a seemingly-simple task: label ordered pairs in a Plot that display with parentheses that grow to match the expression within. I've trawled the documentation and searched the posted questions here to no luck.

The problem is that parentheses are internally special, so they are very difficult to force into a displayed expression. I can use something similar to Graphics[Text[f[0,1/2]]] and the resulting output form has correctly-sized parenthesis, albeit with the pesky f.

I can use any bracketing operator to achieve the same result, e.g. Graphics[Text[\[LeftAngleBracket]0,1/2\[RightAngleBracket]]], but no luck with parentheses. Am I missing something incredibly simple?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Perhaps what you're looking for is this:

Graphics[Text[""[0, 1/2]]]

or also

Graphics[Text["\[InvisibleSpace]"[0, 1/2]]]

However, the "more correct" way is this:

Graphics[Text[
  TraditionalForm[
   "\!\(\*FormBox[\(TraditionalForm\`\((0, \*FractionBox[\(1\), \
\(2\)])\)\),
TraditionalForm]\)"]]]

Edit

Regarding how to enter the low-level formatting constructs of the previous example by hand, I would usually type them in a TraditionalForm math environment (e.g., a DisplayedEquation and then copy and paste into a String within a FormBox, as I showed in the movie in the answer lined here. To decipher the resulting String expressions, it helps to look at the documentation on String representation of Boxes.

But if you prefer to create such expressions by hand in a source-oriented (as opposed to interactive editing) way, you would be better off doing it this way:

Graphics[Text[
  DisplayForm[RowBox[{"(", 0, ",", FractionBox["1", "2"], ")"}]]]]

Here I didn't have to specify TraditionalForm explicitly because it is the default in Graphics. If you plan to use this in a different context where that's not the default format, you can wrap the expression like this:

Graphics[Text[
  DisplayForm[
   FormBox[RowBox[{"(", 0, ",", FractionBox["1", "2"], ")"}], 
    TraditionalForm]
   ]]]

This shows the same low-level constructs that are used above, without wrapping them in a String. They get converted to the desired output by DisplayForm.

share|improve this answer
    
To see how one can enter FormBox expressions relatively easily, have a look at the movie in this answer. –  Jens Jul 21 '13 at 23:22
    
Great answer and helpful link. Can you elaborate a little on your code? It looks like a ! or Run[] but it is obviously not running an OS command but a string of internal commands. I can reduce your code to Graphics[Text[TraditionalForm["\*FormBox[TraditionalForm\((0, \*FractionBox[1, 2])\), TraditionalForm]"]]] without breaking it. I'm having problems finding what the seemingly-important \* is doing here. –  Westley T. Jul 22 '13 at 1:22
    
A good reference for this is the documentation on String representation of Boxes. The specific string in my answer was actually created along the lines of what I showed in the linked movie, not constructed by hand. –  Jens Jul 22 '13 at 15:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.