Can't change xlabel font because of diacritics (č, ř, š, ...)
Show older comments
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 Comments
Stephen23
on 31 Dec 2022
"any ideas"
The default interpreter is TeX:
TeX only accepts ASCII characters. As Dave B wrote, if you want to use other characters, set the interpreter to 'none'.
TeX only accepts ASCII characters
That turns out not to be the case
fsz = 20;
subplot(3,1,1)
xlabel('1: čas^2 (s)','Fontsize',fsz,'FontName','Latin Modern Roman', 'interpreter', 'none')
subplot(3,1,2)
xlabel('2: čas^2 (s)','Fontsize',fsz,'FontName','Latin Modern Roman', 'interpreter', 'tex')
subplot(3,1,3)
xlabel('3: čas^2 (s)','Fontsize',fsz,'FontName','Latin Modern Roman', 'interpreter', 'latex')
You can see that the warning message is only for the latex version, and you can see that the ^ has resulted in the proper superscript for the tex version, indicating that the text was interpreted as one might hope it would be.
"That turns out not to be the case"
As the author of TeX explains, the input text were originally specified as 7-bit, but TeX was modified in 1989 to accept 8-bit text (AFAIK a superset of ASCII): https://www.tug.org/TUGboat/tb10-3/tb25knut.pdf
This has not been changed since.
+'č' % not in ASCII, not in TeX
TMW may have implemented some flawed, undocumented TeX-like chimera, but it is certainly not TeX.
Walter Roberson
on 2 Jan 2023
Have you ever managed to get a /def to work in MATLAB? https://tex.stackexchange.com/questions/655/what-is-the-difference-between-def-and-newcommand
@Walter Roberson: I have never tried. What happens?
Walter Roberson
on 2 Jan 2023
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.
Accepted Answer
More Answers (1)
Walter Roberson
on 31 Dec 2022
Moved: Walter Roberson
on 31 Dec 2022
I wonder whether you have configured
set(0, 'DefaultTextInterpreter', 'latex')
latex Interpreter can only handle US-ASCII
1 Comment
Vilém Frynta
on 31 Dec 2022
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
