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.

 채택된 답변

Sudarsanan A K
Sudarsanan A K 2024년 3월 14일

0 개 추천

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!

댓글 수: 7

Bruce Rodenborn
Bruce Rodenborn 2025년 10월 3일
This does not help. Mathworks has changed the LaTeX fonts between 2024 and 2025 as shown in the two images. The first image is the identical .FIG file opened in 2024B and the second is the .FIG file opened in 2025B. The new fonts are worse and not consistent with standard LaTeX CMR and CMMI fonts. They are unattractive and have changed for no reason. Along with a variety of other changes made in 2025, why were they made? Equally important, how can I switch them back?
Victor Vescu
Victor Vescu 2025년 10월 13일

Did you find a way to change it back?

Marin Grubisic
Marin Grubisic 2025년 11월 5일
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?
Victor Vescu
Victor Vescu 2025년 11월 13일
편집: Victor Vescu 2025년 11월 13일
I agree with Martin, this font change is horrible and has completely broken my ability to copy paste MATLAB figures with LaTeX text into vector graphics editing software, as the font is never consistent anymore.
Bruce Rodenborn
Bruce Rodenborn 2025년 11월 19일
My experience is that if I export the image as PDF, then the fonts (embedded in the PDF, I believe) are the proper CMR and CMMI LaTeX fonts. Thus, when I view the PDF outside of MATLAB, it looks how I want it to display, but the MATLAB figure display is different. My workaround on the MACOS is to open the PDF using Preview, which updates whenever the PDF updates. I make changes in MATLAB and have the code export as a PDF to see the final result. I can then open the PDF to post-process if necessary. However, that change in behavior and finding workarounds is not an improvement, and it remains unclear to me why the change to something was not broken into something that is with no other UI improvements was made.
Simone Fiori
Simone Fiori 2025년 12월 26일
Completely agree with Victor Vescu
Nick
Nick 2026년 3월 17일
I am also having issues with this. I normally save figures as pdf's so I did not notice it at first but some figures I have to save as png and this is where I notice the different fonts. For example, in the matlab figure windows and in png figures, calligraphic S (\mathcal{S}) displays as 𝒮 instead of how it would look in standard latex documents using amssymb, like in the second row of the picture below. Has there since been a work around to keep fonts consistent and preferrably of the standard latex fonts?

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

추가 답변 (1개)

Sergiu
Sergiu 2025년 11월 19일

1 개 추천

Hello,
If this is still of interest, I have managed to find a workaround for getting the old LaTeX interpreter font back - I am using MATLAB R2025b. Even though the visualisation of the figures shows the LaTeX font as TNR, if you try to copy the figure as a vector graphic or if you export it as a vector graphic file (SVG, EPS and so on), the font in the copied/rendered image will be the CMU Serif used in the default old LaTeX interpreter.

댓글 수: 1

Marin
Marin 2025년 11월 19일
This is very useful, although I didn't expect that it is a kind of "requirement" to save/export graphics in vector formats in order for proper LaTeX rendering to be visible. Thank you very much for this comment!

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

카테고리

도움말 센터File Exchange에서 Axes Appearance에 대해 자세히 알아보기

제품

릴리스

R2023b

질문:

2024년 3월 6일

댓글:

2026년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by