1
$\begingroup$

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

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Thank you, creating a MakeBoxes version of the inner Cell does the generalization to any inline math expression inside a text cell. $\endgroup$
    – user13892
    Commented Sep 22, 2019 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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