How to set the font settings in .pdf, publish via MATLAB and LATEX

前端 未结 1 1241
借酒劲吻你
借酒劲吻你 2021-01-06 19:34

While trying to publish a .pdf file for .m MATLAB code, equations (written in latex) are not properly rendered in appropriate (smooth) font, instead fonts looks scattered.

相关标签:
1条回答
  • 2021-01-06 19:52

    I was having the same problem, with equation rendering quality being inadequate.

    This is my procedure for fixing this in MATLAB R2013b.

    1) In the MATLAB command prompt, enter:

        edit publish
    

    This should pop up the editor for you to edit 'publish.m'. Beware, the file may be read only. Under Linux, I use an external editor as superuser to edit it.

    2) Go to line 811. You should see this:

        temptext = text('Parent',tempaxes,'Position',[.5 .5], ...
        'HorizontalAlignment','center','FontSize',22, ...
        'Interpreter','latex');
    

    Change the value of 'Fontsize' to something larger; I used 30.

    3) Go to line 747. You should see this:

        swapTexForImg(dom,equationNode,outputDir,fullFilename,equationText,newSize(2),newSize(1))
    

    Change that to

        swapTexForImg(dom,equationNode,outputDir,fullFilename,equationText,newSize(2)/scale,newSize(1)/scale)
    

    where scale is the scale factor of your liking. Might have to play with it a bit until you get it right; I used 2.

    4) Save the file. Also keep a backup of the original.

    5) In the MATLAB command prompt, enter:

    rehash toolboxcache
    

    followed by:

    clear functions
    

    6) Run publish again.

    This should do the job for the PDF. I haven't tried it for HTML, but it should also work. In case of HTMl, don't forget to delete the images created previously.

    0 讨论(0)
提交回复
热议问题