Question

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.

I did try to fix the problem by decreasing the font-size of the editor but that didn't work.

For example: the MATLAB code is:


%% (a) From above plot there are no signs of convergence of $\rho$

%%

% $x^2+e^{\pi i}$


then the .pdf file is not well written, in which equation's fonts are not smooth enough.

thanks for any suggestions.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top