I'm using the LaTeX interpreter to have access to special math symbols
(e.g. \sqrt) in my labels. Since for all the other text Helvetica is
used, I'd like to use that font for the LaTeX text as well. Does anyone
know if that's possible? The following line uses Computer Modern Sans
Serif (cmss) on my system (I attached a complete example at the
bottom):
xlabel('\textsf{This is my label}', 'Interpreter', 'latex');
I also tried something like
xlabel('{\fontfamily{phv}\selectfont This is my label}', 'Interpreter',
'latex');
which didn't work.
Any ideas?
BTW, is there a list of supported LaTeX commands?
Thanks for your help!
Cheers,
Martin
------- example.m ----
x=0:0.1:3;
y=x.^2;
plot(x,y);
xlabel('\textsf{This is my x-label}', 'Interpreter', 'latex');
ylabel('This is my y-label');
text(1.15,0.3,'This is more text');
Hi Martin,
The easiest way to do this is to set the font for the current Matlab
session to Helvetica for all axes and text items, e.g, in Matlab:
fontname = 'Helvetica';
set(0,'defaultaxesfontname',fontname);
set(0,'defaulttextfontname',fontname);
The same routine can also be used to increase the font size:
fontsize = 12;
set(0,'defaultaxesfontsize',fontsize);
set(0,'defaulttextfontsize',fontsize);
A complete list of all LateX characters in Matlab is found at:
<http://www.mathworks.com/access/helpdesk/help/techdoc/ref/text_props.html#String>
With kind regards,
Rachel.
I am having the same problem as Martin, but I don't think that Rachel's post really provides a solution to the problem. As far as I can tell, setting the default font to Helvetica does not influence the font used by the 'latex' interpreter. Also, the list of LaTeX characters given at the link above only seems to include those characters recognized by the 'tex' interpreter. I have had some success with commands like:
text('Interpreter','latex', ...
'String', '{\bfseries\itshape\sffamily This is bold italic sans-serif}', ...
'Position', [0.5 0.5])
In practice, however, this sequence only really recognizes the last command, which was \sffamily, yielding a non-italic serif font. Otherwise, the text would come out in italics as a result of the \itshape command. Beyond all of that, I have found no way to get a Helvetica font to work with the 'latex' interpreter. Does anyone know if this is possible in Matlab? Thank you for your help,
- Brian
[snip]
> I am having the same problem as Martin, but I don't think that Rachel's post
> really provides a solution to the problem. As far as I can tell, setting the
> default font to Helvetica does not influence the font used by the 'latex'
> interpreter.
Correct.
> Also, the list of LaTeX characters given at the link above only
> seems to include those characters recognized by the 'tex' interpreter.
Also correct.
> I have had some success with commands like:
>
> text('Interpreter','latex', ...
> 'String', '{\bfseries\itshape\sffamily This is bold italic
> sans-serif}', ...
> 'Position', [0.5 0.5])
>
> In practice, however, this sequence only really recognizes the last command,
> which was \sffamily, yielding a non-italic serif font. Otherwise, the text
> would come out in italics as a result of the \itshape command. Beyond all of
> that, I have found no way to get a Helvetica font to work with the 'latex'
> interpreter. Does anyone know if this is possible in Matlab? Thank you for
> your help,
>
> - Brian
It is possible to use Helvetica in LaTeX, but not in MATLAB. The place
in a .tex file where you would specify it seems to be hard coded into
MATLAB and I haven't found any way to access it, though I have tried.
So your best bet is probably to do what you have already done. I prefer
the \textsf, \textit and \textbf commands, but they do the same thing.
The reason you can't get slanted, bold text is that typographically it's
not really a good thing to do and so no one built a slanted, bold
version of the sans serif font.
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
Once these are installed, setting the axes 'FontName' property to 'CMU Serif Roman' will use the CM unicode roman font to render all the text in the axes. Including a line set(0,'DefaultAxesFontName','CMU Serif Roman') in your startup.m file will set this as the default for all the figures you create.
-Lee
Doug Schwarz <s...@sig.for.address.edu> wrote in message <see-C78708.1...@news.frontiernet.net>...
I think the problem of defining a specific font such as helvetica within the latex interpreter is related to the non-existance of its font definition file (.fd) within the matlab distribution. In fact if you do the following
\fontfamily{cmr}\fontseries{b}\selectfont test $\sqrt{z}$
\fontfamily{cmtt}\fontseries{n}\selectfont test
(Note that this wouldn't work: \fontfamily{cmtt}\selectfont test )
you can in fact use different font families. However defining the "phv" family (Adobe Helvetica) results in the default fonttype "cmr" because it can't find the ot1phv.fd file. I tried using the file provided from my Miktex installation, but then I couldn't see the text anymore, probably because of an error. I suspect that the file I used is from a different version/distribution. Therefore, I guess the task at hand is actually finding a font definition file for helvetica that works with the latex version used by matlab.
Cheers
Juan Pontes
Doug Schwarz <s...@sig.for.address.edu> wrote in message <see-C78708.1...@news.frontiernet.net>...