# Tag Info

3

In V10 there is a new function StringTemplate that allows us to build custom formatting functions in a new way. Here is how it can applied to the OP's problem. fmt[args__] := Style[ StringTemplate[ "The value for 1 is 2 and the value for 3 is 4.", CombinerFunction -> Row ][args], "SR"] cpForm = ...

8

Looks like StringForm can achieve this: Cp = 1.5; deltastar = 0.123; Then: StringForm["The value for 1 is 2 and the value for 3 is 4.", HoldForm @ Subscript[C, p], Cp, HoldForm @ Superscript[\[Delta], "*"], deltastar]

7

It sounds like you're merely looking for Row: Cp = 1.5; deltastar = 0.123; Row[{ "The value for ", HoldForm[Subscript[C, p]], " is ", Cp, " and the value for ", HoldForm[Superscript[\[Delta], "*"]], " is ", deltastar, "." }] If this does not work for you please clearly state how it fails so that those issues can be directly addressed.

2

a = 1.5; b = 0.123; Grid[{{"The value for", RawBoxes[SubscriptBox["c", "p"]], "is", a, "and the value for", RawBoxes[SuperscriptBox["\[Delta]", "*"]], "is", b}}]

8

For Simplify there is the option ExcludedForms: expr = Sqrt[x^4] Log[x^2] + Log[x^4]; Simplify[expr, Assumptions -> {x > 0}, ExcludedForms -> {_Log}] (* x^2 Log[x^2] + Log[x^4] *) For Refine, you can wrap the heads to be excluded with Hold: Refine[expr /. Log -> Hold[Log], x > 0] // ReleaseHold (* x^2 Log[x^2] + Log[x^4] *) or use ...

5

With V10 we can write expr = Sqrt[x^4] Log[x^2] + Log[x^4] /. x_Log :> Inactivate[x]; Refine[expr, x > 0] // Activate EDIT Thanks to Chip Hurst's comment the above should, of course, be written as expr = Inactivate[Sqrt[x^4] Log[x^2] + Log[x^4], Log] One of the advantages of Inactivate is that we can selectively Activate: expr = ...

Top 50 recent answers are included