Writing a small epsilon in xlabel with color

Hey, I wanted to write a red small epsilon in my label
\color{red} \epsilon
was my first try, but is was the epsilon version i didnt like, i wanted the epsilon you get with
\varepsilon
Problem is, using \varepsilon the command \color doenst work. It doenst work with Latex interpreter, it doenst work without. It doenst work using $ $ like in:
\color{red} $\varepsilon$
... I tried all combinations and arrangements of $ and {} and \ with and without latex interpreter. I am unable to get a red small epsilon that looks like \varepsilon
Same goes for every other letter variant that is acces with \var command. It doenst work with other latex commands together, eventhough both commands alone work.
Can somebody please tell me how to get this working?
Mny thanks in advance

 採用された回答

dpb
dpb 2021 年 2 月 17 日

0 投票

W/o taking time to try to figure out specific LaTeX syntax inside MATLAB that's always a pain since know nuthink' about LaTeX otherwise,
hLg=legend('$\varepsilon_{21}$','interpreter','latex','textcolor','r');
works.

4 件のコメント

Marc Laub
Marc Laub 2021 年 2 月 17 日
Oh, I gorgot to mention that I need to different colors in the label, because the represent two different x axis. thts why I tried it with \color since 'textcolor' colors the whole text in the same color. But I need a red small varepsilon, a black slash followed by a blue small varphi.
dpb
dpb 2021 年 2 月 17 日
編集済み: dpb 2021 年 2 月 17 日
AFAICT probably is not possible, or at least if is, will be exceedingly deep hack. The basic distribution of LaTeX it seems doesn't include color and it is undocumented how to or even if it is possible to add packages to the MATLAB implementation. This has been subject of numerous prior Q? here with no conclusive affirmative answer; it seems that TMW has even gone backwards with about R2017 in removing some prior high-level files that allowed at least some customization and making those compiled instead.
I think you're simply out of luck on this wish via legend; one could, theoretically at least, write the same string with text and build the string in pieces, each of which is in the one color controlled by the textcolor parameter.
Marc Laub
Marc Laub 2021 年 2 月 17 日
Well i just wondered why it works perfectly with a line like
xlabel('\color{red} \epsilon')
but not with
xlabel('\color{red} \varepsilon')
I thought I am doing a mistake. Because the fact that the second version is not working implicates that the varepsilon is different implemented compared to epsilon, in terms how it can be handled (ie changing color). And that didnt make much sence to me why it should be.
dpb
dpb 2021 年 2 月 17 日
編集済み: dpb 2021 年 2 月 17 日
Well, the first works because default interpreter is 'TeX', not 'LaTeX'
>> figure
>> hLbl=xlabel('\color{red}\epsilon'); % works correctly
>> hLbl.Interpreter
ans =
'tex'
>>
>> hLbl=xlabel('$\varepsilon$','Interpreter','LaTeX'); % also works
>> delete(hLbl)
>> hLbl=xlabel('$\color{red}\varepsilon$','Interpreter','LaTeX'); % dies...
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax:
$\color{red}\varepsilon$
>>
The '\varepsilon' name is only valid under LaTeX, but the '\color' is TeX; need the '\usepackage{xcolor}' directive to use '\textcolor{color}{text}] with LaTeX, but there's no way that is known to add packages to the TMW implementation of LaTeX they have bundled with MATLAB.
Sorry state of affairs, but "that's just the way it is..."
I should add it ot my list of peeves I just posted as nits of MATLAB graphics that have bugged me for years excepting since I never knew/used LaTeX anyways, I always just ignored it and lived with what could do with TeX.

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020b

質問済み:

2021 年 2 月 17 日

編集済み:

dpb
2021 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by