Search code examples
fontslatexmatlab-figuretitle

How to set TImes New Roman in matlab title by latex


I want to change this font to Times New Roman but it doesn't work.

Even set(gca, 'fontname','times new roman') doesn't work either.

title(' $ \sqrt{\textit{\textbf{b}}^2+\textit{\textbf{c}}^2}$','interpreter','latex','fontsize',10,'fontname','Times New Roman')

figure1

The other way I tried is

title('\surd{\itb}^{2}+{\itc}^{2}','fontsize',10,'fontname','Times New Roman')

figure2

Although it could be Times New Roman font, what I want is \sqrt symbol. (It can't work if just type \sqrt without LaTeX.)


Solution

  • There is a reason why you can't find a solution. Simply put a good solution for this does not really exist unless you write your own complicated script on how matlab applies and interpretes fonts.

    Now onto what you can do though. You can make your letters appear in New Roman, however they can not be italic if you want them to be roman.

    Run this piece of code to have a little overview of what is possible:

    figure 
    text(0.5, 0.6, '\textsf{sans serif}','interpreter','latex','fontsize',14) %set text to sans-serif
    text(0.5, 0.5, '\textrm{roman}','interpreter','latex','fontsize',14) %set text to roman
    text(0.5, 0.4, '$$math\,\,mode\,\,roman$$','interpreter','latex','fontsize',14) % Latex roman for mathematical equations
    text(0.5, 0.3, '$$\textrm{roman}, math$$','interpreter','latex','fontsize',14) % A combination of roman and math roman
    
    text(0.1, 0.5, '$$\sqrt{\textbf{\textit{\textrm{b}}}^2}$$','interpreter','latex','fontsize',16) %letter b in italic and bold, the italic part "undoes" the roman font
    text(0.25, 0.5, '$$\sqrt{\textbf{\textrm{b}}^2}$$','interpreter','latex','fontsize',16) %Letter b bold in roman
    text(0.17, 0.35, '$$\sqrt{\textbf{\textrm{b}}^\textbf{2}}$$','interpreter','latex','fontsize',16) %letter b and superscript 2 in bold, b is in roman