"Labeled"},但希望 A 和 B 是不同的颜色,例如 Red 和 Blue。 我可以用 Sty-6ren">
gpt4 book ai didi

text - 数学 : how to have text in multiple colors?

转载 作者:行者123 更新时间:2023-12-05 01:24:01 25 4
gpt4 key购买 nike

我想要一个操纵控件,比如{{wAB, 1, "AB"}, 0, 1, Appearance -> "Labeled"},但希望 AB 是不同的颜色,例如 RedBlue
我可以用 Style["AB",Red] 更改整体颜色,但无法获得 AB在不同的颜色。任何帮助将不胜感激!

最佳答案

你的意思是这样的?

Manipulate[
wAB,
{{wAB,1,Row[{Style["A", Red], Style["B", Blue]}]},0,1,Appearance->"Labeled"}
]

enter image description here

如果您更喜欢单独定义装饰部分(这对于更大和更复杂的控件很有用)并稍后在控件中引用它(比如声明一个变量,但实际上它是一个宏)并重用它用于不同的控件,然后你可以使用 With,像这样

Manipulate[wAB,

Evaluate@With[

{myStyle = Row[{Style["A", Red], Style["B", Blue]}]},

{{wAB, 1, myStyle}, 0, 1, Appearance -> "Labeled"}

]
]

关于text - 数学 : how to have text in multiple colors?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8956915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com