[Tex/LaTex] Font size and font type

fontsfontsize

I'm writing a LaTeX document with \documentclass[pdftex,11pt,openright,headsepline]{book}.

I'm now creating plots in Matlab and I want to have the axis and title of these plots to have the same font size and font as the text.

What font size and font type do I have to choose?

Best Answer

You need to make the interpreter of the text as 'latex':

xlabel('\textbf{Example $a^2$}','Interpreter','latex'); % for x axis's text
ylabel('\textbf{Example $b^2$}','Interpreter','latex'); % for y axis's text
title('Example','Interpreter','latex'); % for title's text
h=legend('show'); % for legend's text, assuming you have given the strings for legend already in the plot command
set(h,'Interpreter','latex');

to your code for plotting. This will make the interpreter for the text you write in the axes and the legend appear formatted with latex not tex (which is default). So, you get the latex type text on the axes too. You can write anything you want the way you write in latex (like $a^2$, etc.). If you further want to change the font in the latex interpreter, you can add:

\fontfamily{cmtt}\fontseries{b}\selectfont test

and you can change the font to cmtt family, for example.

Hope it helps!

Edit:

In fact you can add:

set(0,'DefaultTextInterpreter','latex');

and set the default interpreter for all strings in matlab as latex. Look here for more on defaults:

http://in.mathworks.com/help/matlab/creating_plots/default-property-values.html#f7-18841

Edit 2:

I just realized you wanted to change the font size too. Here, add something like this in the arguments:

xlabel('\textbf{Example $a^2$}','Interpreter','latex','fontsize',14); % I've set the size as 14 here, you can set whatever you want.

This way you can add this extra term to the arguments wherever you want to change the font's size.