Using fonts from the fourier LaTeX package in Matlab plots
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm using the `fourier` package to make my LaTeX documents look pretty, but they would be even prettier if I could mimic the same font in legends, axis labels etc. in my Matlab plots.
I know there are ways to find-and-replace texts in eps graphics within TeX, but that would require me to specify all the labels in the .tex file as well, which I'd like to avoid if I can.
It's mostly just simple letters - no complicated math markup or anything - so just rendering alphabetical characters in the correct font would be sufficient.
I have tried for example
l = legend(planetNames); % PlanetNames is a cell array with strings
set(l, 'FontName', 'utopia'); % Tried Utopia as well with same result
but instead of the Utopia font, I get some ugly, monospaced placeholder font. How do I make this work?
I'm running Ubuntu 11.10, Matlab 7.12.0 (R2011a) and TeX Live 2009. I'm using export_fig to save the plots to files, so if that can help it is already available.
Please also see the same question on http://tex.stackexchange.com/q/51216/223 and http://math.stackexchange.com/q/129399/161 - both of those sites deemed this question off-topic and recommended I ask here instead.
1 Kommentar
Daniel Shub
am 9 Apr. 2012
Sorry to be following you ...
To help in the debugging: Can you use the Utopia font in other applications (e.g., gedit)? Can you use it in the MATLAB command window? Can you use other fonts in your MATLAB figures?
Antworten (1)
Daniel Shub
am 9 Apr. 2012
Hopefully Oliver will chime in, but I think that the way that font replacement works in export_fig does not require you to have the font installed on your system. I believe export_fig edits the eps file directly replacing the MATLAB defined font names with the desired font names. Since this is essentially just plain text replacement, it does not require the font be installed (or even the font name being a valid font name). So even if you cannot get the font to display on screen in MATLAB, there is a chance it could work.
At some point in the processing, however, export_fig might call ghostscript to embed the fonts. To use this functionality you would need the font installed and available to ghostscript.
2 Kommentare
Oliver Woodford
am 9 Apr. 2012
Daniel is entirely correct.
The print2eps function in my export_fig package will indeed simply replace the font names in the eps file, so the font need not exist. Note that since MATLAB initially saves the EPS with the wrong fonts, the placement of text can be wrong.
However, if you export to EPS or PDF using export_fig (rather than print2eps), then it will create a PDF with embedded fonts, which does require the fonts to be installed locally.
Cristiano Malossi
am 15 Apr. 2012
Hello,
I have the same problem: I need to generate EPS figures in matlab using latex utopia font for x-y label and legends. However, I am still not able to do that.
I am using this script as example:
--------------------
clc
clear all
close all
figure(1)
set(1,'PaperPositionMode','auto')
set(1,'Color','w');
plot([0 1], [0 1 ]);
set(xlabel('I would like utopia font here'),'Interpreter','latex','FontSize',30, 'FontName', 'utopia')
set(ylabel('I would like utopia font here'),'Interpreter','latex','FontSize',30, 'FontName', 'utopia')
box on
% I tried with this:
print2eps('testfig.eps');
% and also with this:
export_fig('testfig.eps', '-a1', '-eps');
--------------------
but apparently nothing changes with respect to the case where I don't specify the font. In practice, both approaches generate the EPS figure with the default font.
Could you tell me what am I doing wrong, please?
Thanks!
Cristiano
PS: I am using Ubuntu 11.10 + Matlab 2012a. Should I use Windows?
Siehe auch
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!