how to change latex default font in figure?
70 views (last 30 days)
Show older comments
set(STA1,'A_Label','String','$(i+n)-C_{10}$','Interpreter','latex','FontSize',18,'FontWeight','bold')
When I use latex interpreter ,it can‘t use Times new roman style。how to solve this problem?
(在使用Latex编译器画图时,发现只能使用默认字体,不能更改为新罗马字体,如何解决?)
1 Comment
Dyuman Joshi
on 15 Jan 2024
As far as I know, you can not set/change fonts for any text with Latex as the Text interpreter in MATLAB.
That functionality is not supported in MATLAB yet.
Accepted Answer
Hassaan
on 15 Jan 2024
Install and Configure LaTeX:
- Ensure that you have LaTeX installed on your system, as MATLAB relies on LaTeX for rendering text with the LaTeX interpreter.
Specify the Font in LaTeX:
- Inside your LaTeX expression in MATLAB, you can specify the font you want to use by adding a LaTeX command like \usepackage{newtxtext}. For Times New Roman, you can use the newtxtext package.
- Here's an example of how to use Times New Roman in your LaTeX expression:
set(STA1, 'A_Label', 'String', '$\usepackage{newtxtext}$(i+n)-C_{10}$', 'Interpreter', 'latex', 'FontSize', 18, 'FontWeight', 'bold')
Make Sure LaTeX Can Find the Font:
- Ensure that LaTeX can find the font package you specified. If you've installed LaTeX packages recently, it might require updating LaTeX's font database. You can typically do this by running texhash or mktexlsr in your LaTeX distribution.
Recompile the Plot:
- After making the changes, recompile your plot, and it should now use the Times New Roman font for the specified text.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.
5 Comments
warnerchang
on 13 Jul 2024
I am wondering whether this method is applicable in Matlab2018Rb?
I found it could not be translated:
"字符串标量或字符向量必须具备有效的解释器语法:
$\usepackage{newtxtext}$H_{z}$"
Walter Roberson
on 13 Jul 2024
\usepackage is not a supported latex feature, except possibly for the report generator (and just maybe for certain operations related to uifigures)
xlabel('$\usepackage{newtxtext}$(i+n)-C_{10}$', 'Interpreter', 'latex', 'FontSize', 18, 'FontWeight', 'bold')
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!