Matlab label with different colors on the string using latex interpreter

45 ビュー (過去 30 日間)
Oyeniyi
Oyeniyi 2016 年 4 月 14 日
コメント済み: Chibuzo Nnonyelu 2018 年 12 月 18 日
How do I specify different font colors on the same string using the TEXT, TITLE, XLABEL, YLABEL, or ZLABEL commands etc., while using the LATEX interpreter. For example, the command below works well with the TEX interpreter, how do I get it (or something similar) to work with the LATEX interpreter.
\color{red}x \color{green}+ \color{blue}y

採用された回答

Daniel Lyddy
Daniel Lyddy 2017 年 9 月 18 日
Suppose you have a 3-vector called 'titleColor' that holds the RGB components of the color you want to assign to the title (which I will call 'titleString').
tStr = sprintf('\\color[rgb]{%f, %f, %f}%s', titleColor, titleString);
title(tStr);
I haven't tried this trick with labels yet, but I don't see why a similar approach would not work.
And yes, there are two backslashes before the color[rgb] in the code above. The sprintf command drops one of them.
  2 件のコメント
Sungwoo Park
Sungwoo Park 2018 年 3 月 19 日
Does this really work? Mine just showed '\color[rgb]{0.500000, 0.500000, 0.500000}Title'
Chibuzo Nnonyelu
Chibuzo Nnonyelu 2018 年 12 月 18 日
Yes, it does. But your interpreter has to be 'tex', not 'latex'.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by