4
$\begingroup$

The picture I load is my target:

enter image description here

This is my code in mathematica

    StringTemplate["``Ratio is ``,``Ratio is ``,``Ratio is ``,"][
 Sequence @@ 
  Flatten@Transpose[{{Style["red", Red, Bold], 
      Style["green", Green, Bold], Style["blue", Blue, Bold]}, {0.1, 
      0.2, 0.3}}]]

But the result is

enter image description here

What's problem in my code?Can Anybody give some advice?

$\endgroup$
  • 2
    $\begingroup$ Try the option InsertionFunction -> (ToString[#, TraditionalForm] &) $\endgroup$ – Chip Hurst Dec 1 '15 at 18:03
  • 2
    $\begingroup$ If the expression need not be a string, you could use Row. $\endgroup$ – Chip Hurst Dec 1 '15 at 18:05
  • $\begingroup$ See here stackoverflow.com/questions/8956915/… $\endgroup$ – Quantum_Oli Dec 1 '15 at 18:37
  • $\begingroup$ @ChipHurst that should be an answer. Perhaps more compact if you use InsertionFunction -> (ToString[Style@@#, TraditionalForm] &), then you can omit the Style from each list item. $\endgroup$ – george2079 Dec 1 '15 at 20:05
  • $\begingroup$ @Chip Hurst Thanks very much. $\endgroup$ – yode Dec 2 '15 at 2:22
3
$\begingroup$
Row@MapThread[
  Row[{Style[#1, ToExpression@#1, Bold], " Ratio is ", #2, #3}] &,
  {{"Red", "Green", "Blue"}, {0.1, 0.2, 0.3}, {", ", ", ", ""}}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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