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:
Install new latex fonts

Subject: Install new latex fonts

From: R Wat

Date: 23 Nov, 2010 22:33:03

Message: 1 of 3

Whenever you use the latex interpreter in Matlab, it uses the Computer Modern font family regardless of what you set as the text box's font. I have rather strict guidelines on the fonts that I need to use in my figures (along with complex equations that the Tex interpreter can't handle), so I was wondering, does anyone know of a way to install new latex fonts for the Matlab latex interpreter?

So I've peaked around the files in the Matlab distribution, and all of the files for the latex interpreter can be found in the folders (for Matlab 2009b on Mac OS X)

/sys/tex
/sys/fonts

If you look in the "fonts" folder, there are the folders "ttf" and "type1" which hold the .ttf, .pfb and .pfm files for the computer modern font. If you then look into the "tex" folder, you find the folder "tfm" which holds all of the .tfm files for computer modern fonts and the folder "latex/base" which holds the .fd files for computer modern fonts. So, all of the files that Matlab uses when type setting latex are there, but in a slightly more chaotic structure than if you were to look into your latex distribution files. I've tried adding the font family phv (which is the Helvetica font family) into the current data tree, but haven't had any luck.

I have briefly looked into using LaPrint to skirt around this problem, but I would definitely prefer to install the fonts and just use Matlab's latex interpreter.

Has anyone else looked into this?

Thanks!

Subject: Install new latex fonts

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 25 Nov, 2010 09:58:08

Message: 2 of 3

R Wat <rhino7890@aol.com> wrote:
> Whenever you use the latex interpreter in Matlab, it uses the Computer
> Modern font family regardless of what you set as the text box's font. I
> have rather strict guidelines on the fonts that I need to use in my figures
> (along with complex equations that the Tex interpreter can't handle), so I
> was wondering, does anyone know of a way to install new latex fonts for
> the Matlab latex interpreter?
>

Use the psfrag package for LaTeX. It lets you replace text strings from
your .eps figures with arbitrary LaTeX text. The following is from a post
I made to CSSM a few years ago:


Use psfrag to replace plain text with whatever LaTeX you would like. A
most excellent package. I typically put in a bunch of placeholders like
x1 x2 x3 x4 y1 y2 y2 t1 t2 etc, and then have psfrag search for these and
replace them with some LaTeX of my choosing. Some advantages:

Fonts will be LaTeX fonts (of your choosing).
Fonts will scale with the picture, or not, as you choose.
The text is typeset by LaTeX, rather than MATLAB pretending to be LaTeX.

Disadvantage:

Bitmap rendered images (e.g. with transparency) don't have PostScript text
in them, so psfrag can't do the search and replace. There is not much to
be done about this, short of having The MathWorks modify their print
routines to use bitmaps for the plot, but proper text for the labels and
text.

--
Dr Tristram J. Scott
Energy Consultant

Subject: Install new latex fonts

From: R Wat

Date: 1 Dec, 2010 22:31:06

Message: 3 of 3

tristram.scott@ntlworld.com (Tristram Scott) wrote in message
> Use the psfrag package for LaTeX. It lets you replace text strings from
> your .eps figures with arbitrary LaTeX text. The following is from a post
> I made to CSSM a few years ago:
>
>
> Use psfrag to replace plain text with whatever LaTeX you would like. A
> most excellent package. I typically put in a bunch of placeholders like
> x1 x2 x3 x4 y1 y2 y2 t1 t2 etc, and then have psfrag search for these and
> replace them with some LaTeX of my choosing. Some advantages:
>
> Fonts will be LaTeX fonts (of your choosing).
> Fonts will scale with the picture, or not, as you choose.
> The text is typeset by LaTeX, rather than MATLAB pretending to be LaTeX.
>
> Disadvantage:
>
> Bitmap rendered images (e.g. with transparency) don't have PostScript text
> in them, so psfrag can't do the search and replace. There is not much to
> be done about this, short of having The MathWorks modify their print
> routines to use bitmaps for the plot, but proper text for the labels and
> text.
>
> --
> Dr Tristram J. Scott
> Energy Consultant

That is what I was thinking of doing, but it takes a little bit more processing than I was hoping for (as I would like to use the plots outside of latex also). Thanks for the help!

If anyone comes up with anything else, then let me know!

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