title: How to show Miller indexes in MATLAB?
body: <p>I'm using MATLAB to plot XRD analyses where Miller indexes are used to identify crystallographic plane directions. These indexes contain 3 or 4 numbers and negative value is shown with bar over this number.</p>
  
  <p>In LaTeX it can be written by <code>\([1\bar{1}1]\)</code> or <code>\([1\overline{1}1]\)</code> command.</p>
  
  <p>For labeling spectral lines of XRD standards I'm using this command: Note that negative values are not considered.</p>
  
  <pre><code>std_text_hkl(j)=text(theta{i}(j)-r,0.1,['[' hkl{j} ']'],... % position and label
         of j-th line of i-th standard; hkl{j} holds Miller index in string format
      'parent',ax_std(i),... % association with axes of i-th standard
      'rotation',90,...
      'fontsize',12,...
      'fontname',Font); % Font holds global font setup
  </code></pre>
  
  <p>How can I automate creating bar over negative number without using <code>'Interpreter','latex'</code> property since I would like to be able to change <code>'FontName'</code>property aswell. At leat I'd like to avoid different fonts in labels and ticks.</p>
  
  <p>EDIT:<br>
  Thanks to Magla's comment I got this idea:</p>
  
  <ul>
  <li>Store indexes as 3 column matrix</li>
  <li>separate label into 5 text fields</li>
  <li>if Miller index is negative draw line over it (top line of text frame)</li>
  </ul>
  
  <p>Actual piece of code:</p>
  
  <pre><code>rr=get(ax_std(i),'xlim'); % read x-axis limits of i-th standard
      r=(rr(2)-rr(1))/150; % x-offset of Miller indexes
      for j=1:size(dhkl,1)
        theta{i}(j)=asin(lambda/(2*dhkl(j,1)))*360/pi(); %calculating of lines
                     %positions (Bragg's law)
        line('parent',ax_std(i),...
              'xdata',[theta{i}(j) theta{i}(j)],...
              'ydata',[0 dhkl(j,2)],... % j-th line's reflection intensity
              'color',[colors(1+mod(i-1,size(colors,1)),1:3)],...
              'linewidth',3)
  
  %         Miller indexes
  
        if theta{i}(j)&gt;rr(1)&amp;&amp;theta{i}(j)&lt;rr(2) % test if line is inside axes
            std_text_lbrace(j)=text(theta{i}(j)-r,0.1,'[',...
              'parent',ax_std(i),...
              'verticalalignment','bottom',...
              'horizontalalignment','left',...
              'rotation',90,...
              'fontsize',12,...
              'fontname',Font);
          pos=get(std_text_lbrace(j),'position');
          ext=get(std_text_lbrace(j),'extent');
  
          std_text_h(j)=text(pos(1),pos(2)+ext(4)/1.5,int2str(abs(hkl(j,1))),...
              'parent',ax_std(i),...
              'verticalalignment','bottom',...
              'horizontalalignment','left',...
              'rotation',90,...
              'fontsize',12,...
              'fontname',Font); % write 1st Miller index
          pos=get(std_text_h(j),'position');
          ext=get(std_text_h(j),'extent')
          if hkl(j,1)&lt;0 % if negative, draw line over it
              wdth=get(ax0,'xlim');
              wdth=wdth(2)-wdth(1);
              set(std_text_h(j),'color','b','edgecolor','g')
              line('parent',ax_std(i),...
                  'xdata',[pos(1)-wdth/280*ext(3),pos(1)-wdth/280*ext(3)],...
                  'ydata',[pos(2),pos(2)+ext(4)/wdth*100],...
                  'color','r')
          end
        end
  </code></pre>
  
  <p>I can't fit the line length. For single digit it's too long, for two digits it fits and for more (theoretically) it's way too short. What am I doing wrong? How does MATLAB measure <code>'extent'</code> property of rotated text?</p>