1

I can create a text cell with text like this:

CellPrint@Cell[
    "this is a function call: f[x,y]",
    "Text"
]

This produces:

this is a function call: f[x,y]

But I want f[x,y] to be in inline math form within the text cell, like below:

enter image description here

user13892
  • 9,375
  • 1
  • 13
  • 41

1 Answers1

2

Why not create the output you want in a text cell using ctrl+9, and then use the menu command Cell | Show Expression to see what it looks like? When I do this, I see:

Cell[
    TextData[{
        "This is a function call ",
        Cell[
            BoxData[FormBox[RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], TraditionalForm]],
            FormatType->"TraditionalForm"
        ],
    ":"
    }],
    "Text",
    CellChangeTimes->{{3.7781587877405243`*^9, 3.778158805740602*^9}}
]

and if you CellPrint the above you get the desired output.

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • Thank you, creating a MakeBoxes version of the inner Cell does the generalization to any inline math expression inside a text cell. – user13892 Sep 22 '19 at 19:51