Azzera filtri
Azzera filtri

Setting default Interpreter to Latex

722 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Chibuzo Nnonyelu
Chibuzo Nnonyelu il 13 Mag 2015
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 Commenti
Fred
Fred il 25 Lug 2015
Yes, this seems to solve the problem. Thank you very much.
Vairavan AV
Vairavan AV il 6 Gen 2017
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?

Accedi per commentare.

Più risposte (4)

Max Bartholdt
Max Bartholdt il 7 Ott 2021
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 il 16 Mar 2015
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 Commenti
Ganesh Gaonkar
Ganesh Gaonkar il 16 Mar 2015
It seems to be working for me. What error you receive when you try to execute that command?
Fred
Fred il 16 Mar 2015
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

Accedi per commentare.


Cael Warner
Cael Warner il 13 Ott 2017
Also, to go back to the default formatting, replace 'latex' with 'none'

beginner94
beginner94 il 16 Ott 2018
It does not work for me either and I need to define an overlined variable (in R2007b).
Thanks for help
  5 Commenti
beginner94
beginner94 il 18 Ott 2018
Exactly! Thank you!
Walter Roberson
Walter Roberson il 3 Feb 2021
These days see Live Editor https://www.mathworks.com/help/symbolic/add-suffixes-to-symbolic-results.html

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by