# Using expressions in Text

I want to use Text to add some labels to a graph and was wondering if it is possible to use expressions inside Text? Here is a MWE of what I am trying.

field = 1.45;
Plot[x, {x, 1, 3}, Epilog -> {Style[Text["H = " field " T", {1.5, 2.5}], 12]}]


The problem is that this adds 1.45H=T to the plot and I want it to add H=1.45T. I have tried converting field to a string first and using that instead, but the output is the same.

field = 1.45;

Plot[x, {x, 1, 3},
Epilog -> {Style[Text["H = " <> ToString@field <> " T", {1.5, 2.5}], 12]}] • My pleasure, thanks for acceptance :) – eldo Oct 15 '14 at 16:17
• Or if you want TraditionalForm: Epilog -> {Style[Text[ToString@TraditionalForm[H == field*T], {1.5, 2.5}], 12]} – Bob Hanlon Oct 15 '14 at 16:53
• @kguler Thanks for letting me know, I have upvoted the answer. – Michael Oct 15 '14 at 18:35
• Thanks @Bob Hanlon for an alternative solution. Seeing multiple solutions is a nice way to learn something new about Mathematica – Michael Oct 15 '14 at 18:36

You could also use

field = 1.45;
Plot[x, {x, 1, 3}, Epilog -> Inset[Style[Row[{"H = ", field, " T"}], 12], {1.5, 2.5}]] • +1 because the Row-solution is superior in more complicated cases (Superscript etc.). – eldo Oct 15 '14 at 17:53