Here is a piece of code that displays overlines on the top of negative digits. This solution does not use 'interpreter','latex'
so that one may choose different fonts. Note that the code uses a set of single textboxes, each one having a \n
or char(10)
to display on the top line the underscore (char(95)
, or ' '
for positive digits) and on the bottom line the associated number. One can choose to have two different textboxes to set a particular distance between the underscore and its number. This piece of code does not work for all the fonts though (I would say 90% of my system fonts works fine).
The following code
%Miller indices
miller_ind = [1 -1 -2 3 -3];
%font definition
c = listfonts;
ind_perm = randperm(length(c));
font_names = {'Arial','Times','Courier New',c{ind_perm}};
font_size = 16;
figure('Color','w','Position',[10 10 600 1000]);
py = 0.05;
for ind_font = 1:12
%font name
text(0.03,py,font_names{ind_font},'FontName',font_names{ind_font},'FontSize',font_size);
%plot miller textbox
px = 0.6;
for ii = 1:length(miller_ind)
if miller_ind(ii)<0
text(px,py,[char(95) char(10) num2str(-1*miller_ind(ii)) ],...
'FontName',font_names{ind_font},'FontSize',font_size,'interpreter','none');
else
text(px,py,[' ' char(10) num2str(miller_ind(ii)) ],...
'FontName',font_names{ind_font},'FontSize',font_size,'interpreter','none');
end
px = px + 0.03;
end
py = py + 0.09;
end
gives this result
EDIT
Thank to @Oleg Komarov for his comment. Picture is now directly saved as a .tiff
and not via .eps
.