2
$\begingroup$

How to Print a text and a value with the same Style?, for example {Bold, Blue, 22}

a=4
Style["The number is ", a  , Blue, 22]

The output is text without the variable. With

a=4
Style["The number is " -> a  , Blue, 22]

obtain The number is -> 4.

What I would like to obtain is the same as with a Print but in blue and larger, and without enormous complications and functions.

With Manipulate I reach that with Dynamic[] for the variable.

Thank you.

$\endgroup$

closed as off-topic by m_goldberg, Carl Lange, MarcoB, Pinti, Henrik Schumacher Jun 1 at 22:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Carl Lange, MarcoB, Pinti, Henrik Schumacher
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Style["The number is " <> ToString@a, Blue, 22]?. $\endgroup$ – AccidentalFourierTransform May 25 at 17:08
  • 5
    $\begingroup$ Or Style[Row[{"The Number is ", a}], Blue, 22] $\endgroup$ – Rolf Mertig May 25 at 17:12
  • 1
    $\begingroup$ a = 4; Style[StringForm["The number is ``", a], Blue, 22] $\endgroup$ – Bob Hanlon May 25 at 19:19
  • $\begingroup$ a = 4; Row[Style[#, Blue, 22] & /@ {"The number is ", a}] $\endgroup$ – Somos May 25 at 21:58
  • $\begingroup$ What restrictions are you trying to impose with the reference to Print? If you just want a string displayed with style in a notebook, you can use Style with a StringTemplate. $\endgroup$ – Alan May 26 at 11:22
1
$\begingroup$
tmp = StringTemplate["The number is ``"];
Manipulate[Style[tmp@a, Blue, 22], {{a, 4}, 1, 10, 1}]
$\endgroup$

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