Question

I'm preparing a simple Matlab figure for a presentation. As such, I need the font size of the legend to be large. This is causing some issues with typesetting of subscripts as seen below.

Bad typesetting in subscripts

I have issue with the large space between E and M and the subscripts zeros. I've overcome this in the past by saving the image and working with it in GIMP afterwards; however, I have several of these images and would like to do this in a more automated fashion.

Is there anyway to get better typesetting out of Matlab? Particularly, can I force less whitespace before the subscripts?

Thanks.

Was it helpful?

Solution

I actually cannot reproduce the problem. Here is code that I would use to create that legend:

figure;
plot(randn(10,4))
h = legend(...
    'Approximate Model solution M_0 = 1e5', ...
    'Full Model solution M_0 = 1e5', ...
    'Approximate Model solution E_0 = 1e5', ...
    'Full Model solution E_0 = 1e5');

For me, it renders without the extra spacing you show in your picture.


If you really need to make fine adjustments to the spacing, you can try using Latex to add some negative horizontal space, like so:

For a title:

title('abc\hspace{-1pt}efg','interpreter','latex')

For a legend:

warning off MATLAB:tex              %Disable a warning cause by the next line ... 
h = legend('abc\hspace{-1pt}efg');  %... there may be a cleaner way 
set(h,'interpreter','latex');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top