Clear Filters
Clear Filters

The default interpreter for the 'title' command is 'tex'. How can the default be changed to 'latex'?

129 views (last 30 days)
There are factory settings for other interpreters, that can be accessed by typing
get(root,'factory')
I have written a script to change all the 'interpreters' to 'latex', my preference. However, I do not see a factory setting for the
title
command. I wish to avoid having to type
title('\(\varepsilon\)','interpreter','latex')
every time. Can someone help? Thank you.

Accepted Answer

Walter Roberson
Walter Roberson on 21 Apr 2018
ax = gca;
ax.Title.String = '';
ax.Title.Interpreter = 'latex';
set(groot,'DefaultAxesTitle', ax.Title);

This is a complete title() object that gets set.

Each time you create a new axes, it will set the axes Title object to the object that was created. This will set the Parent of the Title object to be the appropriate axes, which will stop it from displaying where it was and start displaying it in the new axes. Any change in the new axes (such as to the string) will affect the properties for all of the other axes it is set to, because all of those axes will have handles to the same Title object. delete() of any one of the references will delete it for all of the references.

You will probably find this highly unsatisfactory... but you asked ;-)

There does not appear to be any way to set just the Interpreter property by the groot/default mechanism. This is unfortunate.

  2 Comments
Fred
Fred on 22 Apr 2018
I will sadly accept your answer, with the hope that the powers that be will consider a better solution in the future.
Fabrizio Schiano
Fabrizio Schiano on 25 Aug 2020
Edited: Fabrizio Schiano on 25 Aug 2020
Is this still the case? I would like to set one interpreter for all the titles in my matlab plots.

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 25 Aug 2020
There is no way to change the default Interpreter just for axes titles. Axes titles are not their own type of object, they are text objects. Because of that you could change the default properties for all text objects in the figure and that would affect the axes titles, but it would also affect all text objects in the figure. This includes the title, axes labels, and explicitly created text objects.
f = figure;
set(f, 'DefaultTextColor', 'r')
plot(1:10)
title('Sample title');
xlabel('Sample xlabel');
text(3, 7, 'abracadabra');
If you want to control the properties just of all axes titles, you could write your own wrapper function around title that sets your desired properties.
function t = mytitle(varargin)
t = title(varargin{:});
t.Color = 'r';
end
Now a slight modification of the example above:
f = figure;
plot(1:10)
mytitle('Sample title');
xlabel('Sample xlabel');
text(3, 7, 'abracadabra');
The title is red, but the axes label and the text object are not.

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!