LaTex Font has changed since update

68 views (last 30 days)
Tias Schink
Tias Schink on 6 Mar 2024
Commented: Marin Grubisic about 7 hours ago
I want my font on my figues and tables to match the rest of what i am writing, so I ussually use the LaTex font in matlab when making figues.
In the start of the script I would write:
set(groot,'defaultAxesTickLabelInterpreter','latex')
set(groot,'defaulttextinterpreter','latex')
set(groot,'defaultLegendInterpreter','latex')
However, since I hav updated my MatLab to R2023b, the font has changed.
I have attached eksample of how it looked before and after the update.
Granted symbols like μ and sub- and superscrpts still work as it ussually did.

Answers (1)

Sudarsanan A K
Sudarsanan A K on 14 Mar 2024
Hello Tias,
I assume that you are working in a MATLAB Live Script. To fully appreciate the updated font formats, including LaTeX-rendered text in MATLAB figures created within a Live Script, please follow these steps to view the changes in detail:
  1. Execute your Live Script to generate the figure.
  2. Find the Embedded Figure within the Live Script editor.
  3. Click on Open in figure window at the right-top corner of the embedded figure to view it in a separate window for a clearer visualization of the font changes.
Here is an example code that demonstrates setting font sizes and using in figure labels:
% Set default interpreters to 'latex' for consistent font styling
set(groot, 'defaultAxesTickLabelInterpreter', 'latex');
set(groot, 'defaultTextInterpreter', 'latex');
set(groot, 'defaultLegendInterpreter', 'latex');
% Optionally, set a consistent font style, e.g., 'Times New Roman'
set(groot, 'defaultAxesFontName', 'Times New Roman');
set(groot, 'defaultTextFontName', 'Times New Roman');
% Generate sample data
x = linspace(0, 2*pi, 100);
y1 = sin(x);
y2 = cos(x);
% Plot the data with customized line widths
plot(x, y1, '-r', 'LineWidth', 2);
hold on;
plot(x, y2, '-b', 'LineWidth', 2);
hold off;
% Set labels and title with LaTeX formatting and customized font sizes
xlabel('$x$ (radians)', 'FontSize', 18);
ylabel('$y$', 'FontSize', 18);
title('Plot of $\sin(x)$ and $\cos(x)$', 'FontSize', 20);
% Add a legend with a customized font size
legend('$\sin(x)$', '$\cos(x)$', 'FontSize', 16);
After running this script in a MATLAB Live Script, open the figure in a separate window through the Open in figure window option for the best visualization of your -formatted labels and titles. This allows you to inspect the precision of the font rendering and adjustments made.
I hope this helps!
  3 Comments
Victor Vescu
Victor Vescu on 13 Oct 2025 at 21:36

Did you find a way to change it back?

Marin Grubisic
Marin Grubisic 10 minutes ago
That's right, this LaTeX rendering change thing is just awful and not consistent, it's just that all previous codes don't produce the same figures. MATLAB support, please guide us how to fix this and revert it back to old behavior?

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!