6
$\begingroup$

I want to output this:

enter image description here

If I input it like that, the output removes the parentheses, leaving just:

enter image description here

What I tried:

"("<>ToString[TraditionalForm[15/2]]<>")" 

But then the parentheses come out too small:

enter image description here

How can I retain proper size parentheses in the output?

$\endgroup$
5
  • $\begingroup$ Before you get many different solutions, you should perhaps specify more clearly what is your actual use case of this. Do you want to be able to copy&paste the output? Do you actually want to use this for more complicated expressions, or do you really want just one fraction in the output? $\endgroup$ Commented Feb 12, 2024 at 7:37
  • 1
    $\begingroup$ List of unicode brackets. $\endgroup$ Commented Feb 12, 2024 at 8:03
  • $\begingroup$ @Domen I need to convert it to a string and place in the overscript at a vertex in a graph. I accepted yours, it just repeats exactly the way it is in the input. $\endgroup$ Commented Feb 12, 2024 at 12:03
  • $\begingroup$ @Syed Well thanks, but I cannot say I figure out how to use it straight away $\endgroup$ Commented Feb 12, 2024 at 12:03
  • 1
    $\begingroup$ It is for reference in case someone decides to use it. $\endgroup$ Commented Feb 12, 2024 at 12:07

3 Answers 3

5
$\begingroup$

Here is a simple solution with boxes.

DisplayForm[RowBox[{"(", ToBoxes[15/2], ")"}]] 
$\endgroup$
6
$\begingroup$

Since this is just for display purpose, why not simply use MaTeX?

e = 15/2; g = MaTeX["\\left(" <> ToString[TeXForm[e]] <> "\\right)", Magnification -> 2]; g 

Mathematica graphics

I am sure this can be also done uses "boxes" and such also. But I am not good with Boxes formatting.

$\endgroup$
6
$\begingroup$

One way would be:

ToString@TraditionalForm@MatrixForm[{15/2}] 

that gives:

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.