Maybe this is something very simple to some of you. Anyway, I think this can be useful to many others like me.
I would like to build an output that involves strings, unevaluated expressions and evaluated expressions/values —something like this:
The value for $C_\mathrm{p}$ is $1.5$ and the value for $\delta^*$ is $0.123$.
where 1.5 and 0.123 are the result of evaluating respective expressions.
This is what I tried:
Cp = 1.5; deltastar = 0.123;
HoldForm["The value for " HoldForm[Subscript[C, p]] " is " Evaluate[
Cp] " and the value for " HoldForm[
Superscript[\[Delta], "*"]] " is " Evaluate[deltastar] "."]
With this result:
The outer HoldForm
is necessary to maintain the order of the pieces, that are actually considered by Mathematica as being multiplied. For instance, this piece of code:
Cp = 1.5; deltastar = 0.123;
"The value for " HoldForm[Subscript[C, p]] " is " Evaluate[
Cp] " and the value for " HoldForm[
Superscript[\[Delta], "*"]] " is " Evaluate[deltastar] "."
yields to this output:
Using ToString
is not an option when there are superscripts and subscripts, as it is the case (I mean, the raw string output is awful). And because of that, I can't use string concatenation 😕, which would be the most natural approach to me.
There should be an easy way to do this in Mathematica, shouldn't there?
As I said, I guess there actually is a simple solution for this —that is, properly building an output text or message that involves strings, unevaluated expressions and evaluated expressions. Could you help me, please?