Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
latex interpreter for figure text

Subject: latex interpreter for figure text

From: Alan B

Date: 3 Feb, 2010 08:19:05

Message: 1 of 3

I'm getting some strange flaws when trying to display text with the latex interpreter on a figure. For example, using this command:

text(0,0,str,'interpreter','latex')
str='$\cos \left( a b \right)$' % this looks correct
str='$\cos \left( \frac{a}{b} \right)$' % left parenthesis is missing
str='$\cos ( \frac{a}{b} )$' % this looks correct, but parens do not scale properly
str='$-a$' % minus sign is missing

Am I missing something obvious? These are very simple examples and I can't imagine what I could change to fix them. This is in R2008a on Ubuntu 9.04.

Also, can I force the displayed latex to be anti-aliased? I recall anti-aliasing being enabled by default in Windows, is this an OS issue or can I control it?

Thanks

Subject: latex interpreter for figure text

From: Alan B

Date: 3 Feb, 2010 16:04:20

Message: 2 of 3

"Alan B" <monguin61REM@OVETHIS.yahoo.com> wrote in message <hkbbhp$al5$1@fred.mathworks.com>...
> I'm getting some strange flaws when trying to display text with the latex interpreter on a figure. For example, using this command:
>
> text(0,0,str,'interpreter','latex')
> str='$\cos \left( a b \right)$' % this looks correct
> str='$\cos \left( \frac{a}{b} \right)$' % left parenthesis is missing
> str='$\cos ( \frac{a}{b} )$' % this looks correct, but parens do not scale properly
> str='$-a$' % minus sign is missing
>
> Am I missing something obvious? These are very simple examples and I can't imagine what I could change to fix them. This is in R2008a on Ubuntu 9.04.
>
> Also, can I force the displayed latex to be anti-aliased? I recall anti-aliasing being enabled by default in Windows, is this an OS issue or can I control it?
>
> Thanks

I should have searched, I would've found this: http://www.mathworks.de/matlabcentral/newsreader/view_thread/258809 , which provides a working answer, $$ is needed in linux instead of $.

I am still hoping to find a way to enable anti-aliasing for figure text in linux. Does anyone know how to do this? I would settle for a workaround like drawing the text, saving to an image, reading the image, manually antialiasing.

Any help is appreciated

Subject: latex interpreter for figure text

From: Alan B

Date: 10 Feb, 2010 22:05:04

Message: 3 of 3

"Alan B" <monguin61REM@OVETHIS.yahoo.com> wrote in message <hkc6q4$sg8$1@fred.mathworks.com>...
> "Alan B" <monguin61REM@OVETHIS.yahoo.com> wrote in message <hkbbhp$al5$1@fred.mathworks.com>...
> > I'm getting some strange flaws when trying to display text with the latex interpreter on a figure. For example, using this command:
> >
> > text(0,0,str,'interpreter','latex')
> > str='$\cos \left( a b \right)$' % this looks correct
> > str='$\cos \left( \frac{a}{b} \right)$' % left parenthesis is missing
> > str='$\cos ( \frac{a}{b} )$' % this looks correct, but parens do not scale properly
> > str='$-a$' % minus sign is missing
> >
> > Am I missing something obvious? These are very simple examples and I can't imagine what I could change to fix them. This is in R2008a on Ubuntu 9.04.
> >
> > Also, can I force the displayed latex to be anti-aliased? I recall anti-aliasing being enabled by default in Windows, is this an OS issue or can I control it?
> >
> > Thanks
>
> I should have searched, I would've found this: http://www.mathworks.de/matlabcentral/newsreader/view_thread/258809 , which provides a working answer, $$ is needed in linux instead of $.
>
> I am still hoping to find a way to enable anti-aliasing for figure text in linux. Does anyone know how to do this? I would settle for a workaround like drawing the text, saving to an image, reading the image, manually antialiasing.
>
> Any help is appreciated

I've found another related problem, and I can't seem to find any reference to it online.
text(0,0,str,'interpreter','latex')
str='$$\left( a^a \right)$$' % this looks correct
str='$$\left( a^b \right)$$' % left parens missing
str='$$\left( b^a \right)$$' % left parens missing

After experimenting, I concluded that the left parenthesis disappears when it contains a character with a vertical extender in a superscript. However, I'm not sure what to make of the following:
str='$$\left( a_f^f \right)$$' % looks correct
str='$$\left( a^f \right)$$' % left parens missing
str='$$\left( a_f^b \right)$$' % left parens missing

I've found a couple of workarounds:
str='$$\left( {\over} a^b \right)$$' % looks correct
str='$$\left( a^{(b)} \right)$$' % looks correct

But I would prefer a real solution, or at least one that is able to produce the actual desired appearance, instead of adding spaces or extraneous parentheses. Has anyone ever experienced this problem before? Can anyone give me any hints about why this happens or how to fix it?

This happens in R2006b/RHEL5, and R2008a/Ubuntu 9.04, but NOT in 2007a/XP.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us