Can't change xlabel font because of diacritics (č, ř, š, ...)

조회 수: 7 (최근 30일)
Vilém Frynta
Vilém Frynta 2022년 12월 31일
댓글: Walter Roberson 2023년 1월 2일
My language uses letters that use diacritics (č, ř, ž, ... ).
I tried to change font in my Matlab script to Latin Modern Roman, and it gave a following error:
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax: čas (s)
> In defaulterrorcallback (line 12)
> In print (line 36)
The font was not applied. After I removed the č letter, everything went fine.
Any ideas?
The command I used was:
xlabel('čas (s)','Fontsize',fsz,'FontName','Latin Modern Roman')
Perhaps there is a different way.
Thanks.
  댓글 수: 6
Stephen23
Stephen23 2023년 1월 2일
편집: Stephen23 2023년 1월 2일
@Walter Roberson: I have never tried. What happens?
Walter Roberson
Walter Roberson 2023년 1월 2일
I just get interpreter error messages. As far as I can tell, there are a number of TeX constructs that do not work in MATLAB.
For example, several \begin constructs that I find in TeX-specific documentation do not work; the only one I can get to work is \begin{array} https://www.mathworks.com/matlabcentral/answers/280414-latex-in-live-scripts-using-matrix
but I haven't seen a way to build macros in 'tex' or 'latex' interpreters. And 'latex' \usepackage is certainly not usable...
tex and latex in MATLAB have always been badly restricted.

댓글을 달려면 로그인하십시오.

채택된 답변

Dave B
Dave B 2022년 12월 31일
The error you're seeing is because of the tex interpreter, although I don't reproduce it with the same characters. If you're not relying on the tex interpreter, you could try turning it off.
Note that in the example below I chose a font that I knew would be recognized in the browser, to check if the font is defined in your desktop version of MATLAB use the listfonts function.
xlabel('čas (s)','Fontsize',14,'FontName','Serif','Interpreter','none')
ylabel('čas (s)','Fontsize',14,'Interpreter','none')

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 12월 31일
이동: Walter Roberson 2022년 12월 31일
I wonder whether you have configured
set(0, 'DefaultTextInterpreter', 'latex')
latex Interpreter can only handle US-ASCII
  댓글 수: 1
Vilém Frynta
Vilém Frynta 2022년 12월 31일
yes, i think so. i wasn't fully aware of what it was doing. ÷)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by