Fonts with latex interpreter and no interpreter look different
327 ビュー (過去 30 日間)
古いコメントを表示
When I use the latex interpreter to make a title with, for example $\frac{1}{2}$, the font for the title looks different to the font for the axes tick labels. How can I make the axis tick labels and title have the same looking font? For example:
plot(1,1) title('Title with latex character $\frac{1}{2}$',... 'interpreter','latex','FontName','Times New Roman') set(gca,'FontName','Times New Roman')
This is a problem because now the title (that must be latex interpreted to get the $\frac{1}{2}$) looks different to the axes. As far as I'm aware, one cannot set the interpreter for the axes to be 'latex'.
Thanks, Mark
0 件のコメント
採用された回答
Matt Tearle
2011 年 3 月 23 日
You can use the 'latex' interpreter option on the axis labels:
xlabel('hello world','interpreter','latex')
Do you mean the actual tick labels?
EDIT to add:
OK, try this:
set(gca,'FontName','cmr12')
This uses the LaTeX font. It should exist on your system, if LaTeX typesetting is working. I don't know if there's a high-level version of the name. ("Computer Modern Roman" doesn't work for me.)
If you go to C:\Program Files\MATLAB\R2011a\sys\fonts\ttf\cm (or wherever your MATLAB install lives) you can see the available TeX fonts.
5 件のコメント
Yongqi Shi
2024 年 1 月 21 日
Thanks a lot Matt! You solution save a lot of my time!
In the folder you wrote, there're lots of fonts belonging to "Computer Modern" family, which are default fonts that Latex uses.
If one wants to change the font to be the Latex math font, it is called "mwa_cmmi10". cmmi means computer modern math italic, then you can directly get the Latex math font, and you don't need to use the nassty "Latex" interpreter command. You can also use "mwa_cmmi10" and "Helvetica" even within one label!
Really excellent!
Yongqi Shi
2024 年 1 月 21 日
For example, try the following:
xlabel('\fontname{mwa_cmmi10}xyz \fontname{Helvetica}Helvetica').
Really magic!
その他の回答 (2 件)
Oleg Komarov
2011 年 3 月 23 日
Des using Tex (default) help?
title('2 1.8 1.6 Title with latex character \pi')
ABRAHAM TRIGO MANZANO
2024 年 3 月 18 日
Hi there!
Try to write \rm after the first $$, followed by the rest of the text. I give you an example:
Ejey = '$$\rm\dot{m}$$/ kg s$$^{-1}$$';
ylabel(Ejey2,'Interpreter','latex')
I know it´s an old post, but there isn´t information about it, and that code worked for me.
I hope it helped!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Labels and Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!