Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Can you change font size in LaTeX formatted comments?

1 vue (au cours des 30 derniers jours)
Veracohr
Veracohr le 17 Jan 2013
I've put a LaTeX-formatted comment in my code to produce a nice-looking formula when publishing, but it comes out in a small font size that is pretty blurry when saving to PDF. When I try to add a \fontsize command, I get "Warning: Unable to interpret LaTeX string", and the whole formula publishes as-written, not LaTeX-formatted.
Is there any way to change the size of a LaTeX-formatted comment?
This code works, but the formula displayed is too small:
$$x(t) = \sum_{k=0}^N \frac{8}{\pi^2}(-1)^k \frac{sin((2k+1)2\pi f_0 ...
t))}{(2k+1)^2}$$
%
This code doesn't work:
$$\fontsize{14}x(t) = \sum_{k=0}^N \frac{8}{\pi^2}(-1)^k \frac{sin((2k+1)...
2\pi f_0 t))}{(2k+1)^2}$$
%
  1 commentaire
Daniel Shub
Daniel Shub le 18 Jan 2013
It is clear from the answers (and your comment answer) that there is missing information. Please edit the question to contain exactly what you are doing, what you see, and what you expect/want to see.

Réponses (3)

José-Luis
José-Luis le 17 Jan 2013
text(0.1,0.5,...
'$x(t) = \sum_{k=0}^N \frac{8}{\pi^2}(-1)^k \frac{sin((2k+1) 2\pi f_0 t))}{(2k+1)^2}$',...
'Interpreter','latex',...
'FontSize',14);
text(0.1,0.3,...
'$x(t) = \sum_{k=0}^N \frac{8}{\pi^2}(-1)^k \frac{sin((2k+1) 2\pi f_0 t))}{(2k+1)^2}$',...
'Interpreter','latex',...
'FontSize',20);

Daniel Shub
Daniel Shub le 17 Jan 2013
There does not appear to be an easier way of doing it. Your approach of changing the font size within the math environment will not work. It simply is not valid LaTeX. I don't mean that \fontsize{14} is not valid, although it is not, I mean even simple things like \Large don't work inside a math environment. I know of no way of changing the font size from within the math environment. This means we need to change the font size outside the math environment. MATLAB allows this to a certain extent. As Jose-Luis says in his answer, if you change the font size in a figure, this changes the font size of the LaTeX output. The problem is that TMW have decided to hard code the font size into publish.m.
In my version (R2011a) line 747 of publish.m sets the font size
temptext = text('Parent',tempaxes,'Position',[.5 .5], ...
'HorizontalAlignment','center','FontSize',22, ...
'Interpreter','latex');
If you overload publish.m you can substitute any font size you want. You could probably get fancy and have it read it from a configuration file someplace. Note that publish tries to be smart and doesn't always regenerate the graphics, so make sure you delete all the temporary files before running.

Veracohr
Veracohr le 18 Jan 2013
The text command isn't what I'm looking for because I don't want the formula inside a figure, and I don't seem to have a publish.m file. At least, searching my hard drive doesn't find it.
Thanks anyway, I guess I'll leave it as is.
  1 commentaire
José-Luis
José-Luis le 18 Jan 2013
Where do you want the formula to appear?

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by