Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I made the comment on <a href="http://undocumentedmatlab.com/blog/matlab-latex-interface/#comment-209656" rel="nofollow noreferrer">Undocumented Matlab</a> that you refer to. Apparently, I grossly underestimated the difficulty of making the Matlab DVI viewer work with fonts. I have included a non-working solution in the hope that someone can understand the warning it generates. I also have a working solution that is a pretty big hack. I am using Matlab R2013a and TexLive 2013 on Linux. I am not sure what will happen on Mac or Windows.</p> <p><strong>Non working solution</strong></p> <p>My first approach was to overload the Matlab <code>tex.m</code> function so I can easily do things in LaTeX and only have to worry about the <code>dvi</code> file</p> <pre><code>function [dviout,errout,auxout] = tex(varargin) fid = fopen('matlab.dvi'); dviout = fread(fid, 'uint8'); dviout = uint8(dviout); fclose(fid); errout = []; auxout = []; end </code></pre> <p>I then created <code>matlab.dvi</code> by processing</p> <pre><code>\documentclass{article} \setlength\topmargin{-0.5in} \setlength\oddsidemargin{0in} \DeclareFontFamily{T1}{myfont}{} \DeclareFontShape{T1}{myfont}{m}{n}{&lt;-&gt; [1.2] AuriocusKalligraphicus}{} \begin{document}% \setbox0=\hbox{\usefont{T1}{myfont}{m}{n}Some text with a distinct font $\alpha$}% \copy0\special{bounds: \the\wd0 \the\ht0 \the\dp0}% \end{document}% </code></pre> <p>I then copied the TexLive font to Matlab</p> <pre><code># cp $TEXLIVEROOT/texmf-dist/fonts/type1/public/aurical/AuriocusKalligraphicus.pfb $MATLABROOT/sys/fonts/AuriocusKalligraphicus.pfb </code></pre> <p>I get the "expected" warnings from </p> <pre><code>&gt;&gt; text(0.0, 0.5, 'DOES NOT MATTER', 'Interpreter', 'LaTeX', 'FontSize', 20) Warning: Font AuriocusKalligraphicus10 is not supported. Warning: Font AuriocusKalligraphicus10 is not supported. </code></pre> <p>If I try and export the figure (with the missing fonts) to a <code>pdf</code> file via <code>alt+f</code> <code>alt+r</code> I get a whole bunch of warnings including the potentially useful</p> <blockquote> <p>Warning: Missing /usr/local/matlab/R2013a/sys/fonts/type1/cm/mwa_auriocuskalligraphicus10.pfb</p> </blockquote> <p><strong>Working hack solutiuon</strong></p> <p>After becoming feed up with not knowing what to call the <code>pfb</code> files, I decided to overwrite one that already works (cmr10).</p> <p>At the CLI</p> <pre><code># cp $MATLABROOT/sys/fonts/mwa_cmr10.pfb $MATLABROOT/sys/fonts/mwa_cmr10.pfb.bak # cp $TEXLIVEROOT/texmf-dist/fonts/type1/public/aurical/AuriocusKalligraphicus.pfb $MATLABROOT/sys/fonts/mwa_cmr10.pfb </code></pre> <p>and at the Matlab prompt</p> <pre><code>&gt;&gt; text(0.0, 0.5, 'Some text with a distinct font $\alpha$', 'Interpreter', 'LaTeX', 'FontSize', 20) </code></pre> <p>gives me</p> <p><img src="https://i.stack.imgur.com/ZmJcp.png" alt="Matlab figure">.</p> <p>In order to export the figure to an <code>eps</code> with the fonts you need to replace all the instances of <code>/mwa_cmr10</code> with <code>/AuriocusKalligraphicus</code> in the <code>eps</code> file. Presumably this is because this solution is a hack. Ideally I should not only replace the <code>pfb</code> file, but also the <code>fd</code> and <code>tfm</code> files. There are probably enough <code>pfb</code> fonts available to allow you to create most figures.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload