In previous versions of MATLAB, the command
set(0,'defaulttextInterpreter','latex') %latex axis labels
set the interpreter for the text command, the xlabel command, and so on, to Latex. This does not work in 2015a. Is there an alternative way to set the default interpreter to Latex for all graphics objects. Thank you.

 채택된 답변

Chibuzo Nnonyelu
Chibuzo Nnonyelu 2015년 5월 13일

23 개 추천

MATLAB changed some object properties name. For this issue, the following will work
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
I think Legend didn't change. You can still replace the 'groot' with '0' as usual. To be able to set other default object properties, check out
get(groot, 'factory'); % this shows all the factory values for all object properties. get(groot, 'default'); % fetches only default values you have altered.
So you can use the "get(groot, 'factory');" to see all possible object property and change their default values by removing the "factory" prefix and replace with "default". Of course you use the set() function to change and get() function to fetch. Let me if this helped.

댓글 수: 2

Fred
Fred 2015년 7월 25일
Yes, this seems to solve the problem. Thank you very much.
Vairavan AV
Vairavan AV 2017년 1월 6일
Yes, I could fix the problem! Thank you very much!
But, do we need to use set(groot, 'factory'), to set it back when we don't need this?

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

추가 답변 (4개)

Max Bartholdt
Max Bartholdt 2021년 10월 7일

6 개 추천

clear all
% This script changes all interpreters from tex to latex.
list_factory = fieldnames(get(groot,'factory'));
index_interpreter = find(contains(list_factory,'Interpreter'));
for i = 1:length(index_interpreter)
default_name = strrep(list_factory{index_interpreter(i)},'factory','default');
set(groot, default_name,'latex');
end
Ganesh Gaonkar
Ganesh Gaonkar 2015년 3월 16일

3 개 추천

I think the command should work even on R2015a. Looks like you have missed making 'text' as CamelCase. So ideally the command should be : set(0,'defaultTextInterpreter','latex');

댓글 수: 3

Fred
Fred 2015년 3월 16일
Unfortunately, the command that you suggested still does not work.
Ganesh Gaonkar
Ganesh Gaonkar 2015년 3월 16일
It seems to be working for me. What error you receive when you try to execute that command?
Here is some bare minimum code
close all
set(0,'defaultTextInterpreter','latex'); %trying to set the default
xlabel('$x$') %xlabel is $x$
figure; %try a new figure
xlabel('$x$','interpreter','latex') %now xlabel is x in math font

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

Cael Warner
Cael Warner 2017년 10월 13일

1 개 추천

Also, to go back to the default formatting, replace 'latex' with 'none'
beginner94
beginner94 2018년 10월 16일

0 개 추천

It does not work for me either and I need to define an overlined variable (in R2007b).
Thanks for help

댓글 수: 5

Steven Lord
Steven Lord 2018년 10월 16일
Search the documentation included in your installation (and not the online documentation, which is for a release more than ten years newer than the one you're using) for the three words "default property values" and follow the instructions on the first page in the search results.
beginner94
beginner94 2018년 10월 18일
I don't know how to define an overlined variable with latex (the syntax), even if I set the default interpreter to latex... I'm not looking for an overlined label. Is it actually possible to overline a variable?!
Steven Lord
Steven Lord 2018년 10월 18일
You mean you want to define a variable whose name is \bar{x}, using the LaTeX notation? No, that is not allowed. The rules for valid variable names are given in the documentation for the isvarname function:
  • A valid variable name must begin with a letter.
  • A valid variable name may has no more than namelengthmax characters.
  • A valid variable name may contain only letters, digits, and/or the underscore character _.
  • A valid variable name must not be a keyword (the iskeyword function gives you a list of the keywords.)
Use something similar or evocative of that name like xbar or barx as your variable name.
beginner94
beginner94 2018년 10월 18일
Exactly! Thank you!
Walter Roberson
Walter Roberson 2021년 2월 3일
These days see Live Editor https://www.mathworks.com/help/symbolic/add-suffixes-to-symbolic-results.html

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

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

질문:

2015년 3월 16일

댓글:

2022년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by