<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Matlab-Latex interface	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/matlab-latex-interface/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/matlab-latex-interface?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=matlab-latex-interface</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Tue, 28 Jul 2015 09:15:28 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: mugurg		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-353941</link>

		<dc:creator><![CDATA[mugurg]]></dc:creator>
		<pubDate>Tue, 28 Jul 2015 09:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-353941</guid>

					<description><![CDATA[If you want to use LaTeX interpreter of MATLAB, create .eps figures, and get the desired font (like Helvetica) instead of Computer Modern fonts, I think I&#039;ve finally found a solution. I actually saw it here: http://stackoverflow.com/questions/11212172/latex-fonts-in-matlab But I needed to scroll down a little bit and read the answers which did not get any upvote.

Anyways, the trick is to open the resulting .eps file with a text editor and replace cm fonts with Helvetica or whatever you want. For example, change the following lines:
&lt;pre lang=&#039;postscript&#039;&gt;
%%IncludeResource: font mwa_cmr10
/mwa_cmr10 /WindowsLatin1Encoding 120 FMSR
&lt;/pre&gt;

with the following:
&lt;pre lang=&#039;postscript&#039;&gt;
%%IncludeResource: font Helvetica
/Helvetica /WindowsLatin1Encoding 120 FMSR
&lt;/pre&gt;

I hope this helps to whomever googles this problem.]]></description>
			<content:encoded><![CDATA[<p>If you want to use LaTeX interpreter of MATLAB, create .eps figures, and get the desired font (like Helvetica) instead of Computer Modern fonts, I think I&#8217;ve finally found a solution. I actually saw it here: <a href="http://stackoverflow.com/questions/11212172/latex-fonts-in-matlab" rel="nofollow ugc">http://stackoverflow.com/questions/11212172/latex-fonts-in-matlab</a> But I needed to scroll down a little bit and read the answers which did not get any upvote.</p>
<p>Anyways, the trick is to open the resulting .eps file with a text editor and replace cm fonts with Helvetica or whatever you want. For example, change the following lines:</p>
<pre lang='postscript'>
%%IncludeResource: font mwa_cmr10
/mwa_cmr10 /WindowsLatin1Encoding 120 FMSR
</pre>
<p>with the following:</p>
<pre lang='postscript'>
%%IncludeResource: font Helvetica
/Helvetica /WindowsLatin1Encoding 120 FMSR
</pre>
<p>I hope this helps to whomever googles this problem.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: How to make fonts available to the LaTeX interpreter in Matlab R2013a? &#124; Technology &#38; Programming Answers		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-291756</link>

		<dc:creator><![CDATA[How to make fonts available to the LaTeX interpreter in Matlab R2013a? &#124; Technology &#38; Programming Answers]]></dc:creator>
		<pubDate>Sun, 03 Nov 2013 11:32:29 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-291756</guid>

					<description><![CDATA[[...] Making additional fonts usable therefore consists of two parts: Making it available for the LaTeX interpreter, and making it available for the rendering function. The first part can be tackled by manipulating tex.m, such that it generates the dvi through an independent regular installation of LaTeX, and installing the font to this LaTeX in the usual way (e.g. font packages). See undocumentedmatlab. [...]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] Making additional fonts usable therefore consists of two parts: Making it available for the LaTeX interpreter, and making it available for the rendering function. The first part can be tackled by manipulating tex.m, such that it generates the dvi through an independent regular installation of LaTeX, and installing the font to this LaTeX in the usual way (e.g. font packages). See undocumentedmatlab. [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-284625</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 16 Oct 2013 20:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-284625</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-284610&quot;&gt;Carsten&lt;/a&gt;.

Have you tried the official route? What does MathWorks tech support have to say about this?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-284610">Carsten</a>.</p>
<p>Have you tried the official route? What does MathWorks tech support have to say about this?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Carsten		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-284610</link>

		<dc:creator><![CDATA[Carsten]]></dc:creator>
		<pubDate>Wed, 16 Oct 2013 19:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-284610</guid>

					<description><![CDATA[Hello,

thanks for this post and the interesting additional information in the comments. However, after some testing and poking around, I don&#039;t believe that tex.m is the relevant point to solve this problem. (For reference: I use R1013a on 64-bit Linux.) True that you can hack tex.m to make Matlab use another (La)TeX engine. But that&#039;s only part of the deal, because the latex run doesn&#039;t really render the font, it only produces the dvi file, which just contains positioning information.

When I run tex(&#039;$\sf x = 5$&#039;,&#039;verbose&#039;,2), it reports no errors but a number of successes, including finding cmss10.tfm. That is the file that latex uses in order to typeset cmss10; it contains the font metrics, but not the font glyphs needed for rendering.

When I put a debugging breakpoint at the end of tex.m, and then run xlabel(&#039;$\sf x = 5$&#039;, &#039;Interpreter&#039;, &#039;latex&#039;), I don&#039;t get an error message until the breakpoint, either. At this point, the rendering to the figure window hasn&#039;t happened yet. If I let Matlab continue from the breakpoint, the figure window is updated and the familiar message &quot;Warning: Font cmss10 is not supported&quot; appears.

&lt;i&gt;The problem does not lie in the built-in latex not being able to process the string into dvi, it lies in Matlab not being able to render the dvi.&lt;/i&gt; I suspect that in order to render, Matlab would need a file like mwa_cmss10.ttf in sys/fonts/ttf/cm for screen display and a file like mwa_cmss10.pfb in sys/fonts/type1/cm for eps output.

A current installation of TeXlive does not contain cmss10 anymore. Computer Modern has been replaced by Latin Modern, available as an OpenType file in texmf/fonts/opentype/public/lm/lmsans10-regular.otf; and I can&#039;t find a pfb version on my system.

Instead, I tried to copy cmss10.ttf from an installation of matplotlib to sys/fonts/ttf/cm/mwa_cmss10.ttf, but with no effect. I guess there is some kind of font registration in which the file has to be listed to be available. For the pfb-files there is sys/fonts/fonts.scale, fonts.dir, and encodings.dir, but I couldn&#039;t find anything for ttf files.

I also tried to install cmss10.ttf as a system font. It does show up in Matlab&#039;s font selection dialogue as &quot;cmss10&quot;, but if used the rendering is wrong, and it doesn&#039;t keep &#039;Interpreter&#039; = &#039;latex&#039; from complaining.

&lt;i&gt;Any more ideas, anyone?&lt;/i&gt; I&#039;d really like to be able using latex sans serif again.]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>thanks for this post and the interesting additional information in the comments. However, after some testing and poking around, I don&#8217;t believe that tex.m is the relevant point to solve this problem. (For reference: I use R1013a on 64-bit Linux.) True that you can hack tex.m to make Matlab use another (La)TeX engine. But that&#8217;s only part of the deal, because the latex run doesn&#8217;t really render the font, it only produces the dvi file, which just contains positioning information.</p>
<p>When I run tex(&#8216;$\sf x = 5$&#8217;,&#8217;verbose&#8217;,2), it reports no errors but a number of successes, including finding cmss10.tfm. That is the file that latex uses in order to typeset cmss10; it contains the font metrics, but not the font glyphs needed for rendering.</p>
<p>When I put a debugging breakpoint at the end of tex.m, and then run xlabel(&#8216;$\sf x = 5$&#8217;, &#8216;Interpreter&#8217;, &#8216;latex&#8217;), I don&#8217;t get an error message until the breakpoint, either. At this point, the rendering to the figure window hasn&#8217;t happened yet. If I let Matlab continue from the breakpoint, the figure window is updated and the familiar message &#8220;Warning: Font cmss10 is not supported&#8221; appears.</p>
<p><i>The problem does not lie in the built-in latex not being able to process the string into dvi, it lies in Matlab not being able to render the dvi.</i> I suspect that in order to render, Matlab would need a file like mwa_cmss10.ttf in sys/fonts/ttf/cm for screen display and a file like mwa_cmss10.pfb in sys/fonts/type1/cm for eps output.</p>
<p>A current installation of TeXlive does not contain cmss10 anymore. Computer Modern has been replaced by Latin Modern, available as an OpenType file in texmf/fonts/opentype/public/lm/lmsans10-regular.otf; and I can&#8217;t find a pfb version on my system.</p>
<p>Instead, I tried to copy cmss10.ttf from an installation of matplotlib to sys/fonts/ttf/cm/mwa_cmss10.ttf, but with no effect. I guess there is some kind of font registration in which the file has to be listed to be available. For the pfb-files there is sys/fonts/fonts.scale, fonts.dir, and encodings.dir, but I couldn&#8217;t find anything for ttf files.</p>
<p>I also tried to install cmss10.ttf as a system font. It does show up in Matlab&#8217;s font selection dialogue as &#8220;cmss10&#8221;, but if used the rendering is wrong, and it doesn&#8217;t keep &#8216;Interpreter&#8217; = &#8216;latex&#8217; from complaining.</p>
<p><i>Any more ideas, anyone?</i> I&#8217;d really like to be able using latex sans serif again.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jan		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-217822</link>

		<dc:creator><![CDATA[Jan]]></dc:creator>
		<pubDate>Wed, 26 Jun 2013 12:05:14 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-217822</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-209731&quot;&gt;Ryan W.&lt;/a&gt;.

I despise the route that matlab has gone into regarding latex since version 2010. Thank you Dan, for the nice work-around. I&#039;m interested to what people have cooked up regadring more elaborate tex.m contraptions.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-209731">Ryan W.</a>.</p>
<p>I despise the route that matlab has gone into regarding latex since version 2010. Thank you Dan, for the nice work-around. I&#8217;m interested to what people have cooked up regadring more elaborate tex.m contraptions.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Brian		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-212684</link>

		<dc:creator><![CDATA[Brian]]></dc:creator>
		<pubDate>Fri, 14 Jun 2013 20:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-212684</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926&quot;&gt;Brian&lt;/a&gt;.

Thanks Lubos.  Matlab&#039;s text engine doesn&#039;t seem to support the soul package.  When I get some time, I will try to switch out matlab&#039;s tex engine and try the soul package.

Malcolm, yes, I can (and do) set the background color of the entire uicontrol.  But I failed mention earlier that the text box has lots of words in it (sometimes many lines of text).  My goal is to highlight only one of the words in yellow...aka showing the results from a text search.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926">Brian</a>.</p>
<p>Thanks Lubos.  Matlab&#8217;s text engine doesn&#8217;t seem to support the soul package.  When I get some time, I will try to switch out matlab&#8217;s tex engine and try the soul package.</p>
<p>Malcolm, yes, I can (and do) set the background color of the entire uicontrol.  But I failed mention earlier that the text box has lots of words in it (sometimes many lines of text).  My goal is to highlight only one of the words in yellow&#8230;aka showing the results from a text search.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ryan W.		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-212079</link>

		<dc:creator><![CDATA[Ryan W.]]></dc:creator>
		<pubDate>Thu, 13 Jun 2013 14:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-212079</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-209731&quot;&gt;Ryan W.&lt;/a&gt;.

That is a great idea. I&#039;m kind of embarrassed that I didn&#039;t think of this myself (I guess I got caught up with trying to tweak what Matlab already had there). I gave your sample code a try and it worked great (although it might still be a good idea to use Matlab&#039;s &lt;i&gt;mwarticle.cls&lt;/i&gt; file, or a variation of it, to get the text located in the proper location in the figure). I briefly gave XeLaTeX a try with hopes that I could use system fonts. As XeLaTeX produces an extended dvi file (xdv), I modified your overload function for &lt;i&gt;tex.m&lt;/i&gt; to be
&lt;pre lang=&quot;matlab&quot;&gt;
function[dviout,errout,auxout] = tex(varargin)
    fid = fopen(&#039;matlab.dvi&#039;);
    dviout = fread(fid, &#039;uint8&#039;);	
    dviout = uint8(dviout);	
    fclose(fid);	
    errout = [];	
    auxout = [];
end
&lt;/pre&gt; 

If I use the same &lt;i&gt;.tex&lt;/i&gt; file that you specify above, than everything works the same as with a &lt;i&gt;dvi&lt;/i&gt; produced with LaTeX. Unfortunately, when I compile the following code with XeLaTeX:

&lt;code&gt;\documentclass[11pt]{article}
\usepackage{fontspec}
\setmainfont{Helvetica}

\begin{document}
\setbox0=\hbox{$x = \alpha$}\copy0\special{bounds: \the\wd0 \the\ht0 \the\dp0} 
\end{document}
&lt;/code&gt;

in an attempted to use the standard Hevletica font, and feed the &lt;i&gt;xdv&lt;/i&gt; file into Matlab, Matlab doesn&#039;t like it and crashes. Any thoughts?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-209731">Ryan W.</a>.</p>
<p>That is a great idea. I&#8217;m kind of embarrassed that I didn&#8217;t think of this myself (I guess I got caught up with trying to tweak what Matlab already had there). I gave your sample code a try and it worked great (although it might still be a good idea to use Matlab&#8217;s <i>mwarticle.cls</i> file, or a variation of it, to get the text located in the proper location in the figure). I briefly gave XeLaTeX a try with hopes that I could use system fonts. As XeLaTeX produces an extended dvi file (xdv), I modified your overload function for <i>tex.m</i> to be</p>
<pre lang="matlab">
function[dviout,errout,auxout] = tex(varargin)
    fid = fopen('matlab.dvi');
    dviout = fread(fid, 'uint8');	
    dviout = uint8(dviout);	
    fclose(fid);	
    errout = [];	
    auxout = [];
end
</pre>
<p>If I use the same <i>.tex</i> file that you specify above, than everything works the same as with a <i>dvi</i> produced with LaTeX. Unfortunately, when I compile the following code with XeLaTeX:</p>
<p><code>\documentclass[11pt]{article}<br />
\usepackage{fontspec}<br />
\setmainfont{Helvetica}</p>
<p>\begin{document}<br />
\setbox0=\hbox{$x = \alpha$}\copy0\special{bounds: \the\wd0 \the\ht0 \the\dp0}<br />
\end{document}<br />
</code></p>
<p>in an attempted to use the standard Hevletica font, and feed the <i>xdv</i> file into Matlab, Matlab doesn&#8217;t like it and crashes. Any thoughts?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Malcolm Lidierth		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-211343</link>

		<dc:creator><![CDATA[Malcolm Lidierth]]></dc:creator>
		<pubDate>Tue, 11 Jun 2013 14:30:50 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-211343</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926&quot;&gt;Brian&lt;/a&gt;.

Can you not just set the BackgroundColor of the uicontrol?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926">Brian</a>.</p>
<p>Can you not just set the BackgroundColor of the uicontrol?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Lubos Smolik		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-211323</link>

		<dc:creator><![CDATA[Lubos Smolik]]></dc:creator>
		<pubDate>Tue, 11 Jun 2013 13:22:41 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-211323</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926&quot;&gt;Brian&lt;/a&gt;.

The easiest way to highlight some text is to use &lt;b&gt;soul&lt;/b&gt; package:

&lt;pre lang=&quot;matlab&quot;&gt;
\usepackage{soul}
\hl{Highlighted text.}
&lt;/pre&gt; 

It is recommended to employ also package &lt;b&gt;color&lt;/b&gt; in order to use color references.

But there is one thing: I&#039;m not sure how MATLAB will interpret &lt;i&gt;\usepackage&lt;/i&gt; command. Anyway, you can try it in proper (La)TeX editor and if you find it easy to use then switch to MATLAB and see what happen ;)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926">Brian</a>.</p>
<p>The easiest way to highlight some text is to use <b>soul</b> package:</p>
<pre lang="matlab">
\usepackage{soul}
\hl{Highlighted text.}
</pre>
<p>It is recommended to employ also package <b>color</b> in order to use color references.</p>
<p>But there is one thing: I&#8217;m not sure how MATLAB will interpret <i>\usepackage</i> command. Anyway, you can try it in proper (La)TeX editor and if you find it easy to use then switch to MATLAB and see what happen 😉</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Brian		</title>
		<link>https://undocumentedmatlab.com/articles/matlab-latex-interface#comment-210926</link>

		<dc:creator><![CDATA[Brian]]></dc:creator>
		<pubDate>Mon, 10 Jun 2013 15:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3835#comment-210926</guid>

					<description><![CDATA[This may be a slight tangent, but I was wondering how to set the background color of a single word in a text box in a figure.
(aka: highlight with big bold yellow :)

I&#039;ve been using tex to set the font color of individual words successfully,
but background color doesn&#039;t seem to be supported by Matlab&#039;s tex engine.
Perhaps overloading matlab&#039;s tex.m is the answer.
Though I assume I would have to get everyone else who uses my script to install the new LaTeX engine?
What would be the best LaTeX engine for changing background color?

My main restriction is that I&#039;m dealing with figures and text objects that already exist, so I can&#039;t simply use a different method (javacomponent) to create the text object.

Thanks,
Brian]]></description>
			<content:encoded><![CDATA[<p>This may be a slight tangent, but I was wondering how to set the background color of a single word in a text box in a figure.<br />
(aka: highlight with big bold yellow 🙂</p>
<p>I&#8217;ve been using tex to set the font color of individual words successfully,<br />
but background color doesn&#8217;t seem to be supported by Matlab&#8217;s tex engine.<br />
Perhaps overloading matlab&#8217;s tex.m is the answer.<br />
Though I assume I would have to get everyone else who uses my script to install the new LaTeX engine?<br />
What would be the best LaTeX engine for changing background color?</p>
<p>My main restriction is that I&#8217;m dealing with figures and text objects that already exist, so I can&#8217;t simply use a different method (javacomponent) to create the text object.</p>
<p>Thanks,<br />
Brian</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
