Latex fonts in matlab

后端 未结 7 955
执念已碎
执念已碎 2020-12-24 08:19

Is it possible to convert the font of a matlab plot to be the same of latex fonts. For example I can modify the font of a plot by:

x = -pi:.1:pi;
y = sin(x);         


        
7条回答
  •  暖寄归人
    2020-12-24 08:51

    I'd recommend setting the default interpreter to LaTex at the beginning of your script/function:

    set(0,'defaulttextinterpreter','latex')
    

    You can also download a version of Computer Modern (The LaTeX Font Family) and install it to your machine. Techniques may vary if you're running windows or mac, for Mac you'll need to download the OTF version and add it into the FontBook (Cmd-Space: FontBook)

    Next, restart Matlab

    Finally, you can use the LaTeX Font in Matlab:

       set(0,'DefaultTextFontname', 'CMU Serif')
       set(0,'DefaultAxesFontName', 'CMU Serif')
    

    This is a nice work-around for having constant fonts in your tick-labels, although it has some trouble exporting in some formats.

提交回复
热议问题