Effacer les filtres
Effacer les filtres

How to generate plot titles with the latex interpreter and larger font sizes?

293 vues (au cours des 30 derniers jours)
Rebecca Tyson
Rebecca Tyson le 12 Déc 2018
Commenté : Rebecca Tyson le 10 Sep 2019
I am trying to generate plot titles that include mathematical terms (generated with LaTeX) but also larger font sizes (so that they don't become impossibly tiny when shrunk by the publisher). I seem to be able to get one or the other, but not both. With the following code
plot(x, y, 'k', 'LineWidth', 2)
title('\fontsize{10} *{\cal{R}}(t)* Model 2', 'interpreter', 'latex')
(note, please mentally replace the * symbols with $ symbols - I had to make the change to shut off the text interpreter in this question window!) I obtain plots with the correct fontsize, but uninterpreted text (i.e. {\cal{R}}(t) - and the \fontsize command! - appear typed-out in the title). If, instead, I use the code
plot(x, y, 'k', 'LineWidth', 2)
title('*{\cal{R}}(t)* Model 2', 'interpreter', 'latex')
the LaTeX interpreter works fine, but of course the font is too small. I also tried a fix that I found among Matlab answers:
plot(x, y, 'k', 'LineWidth', 2)
hT = title('*{\cal{R}}(t)* Model 2', 'interpreter', 'latex')
set(hT, 'FontSize', 10)
but that produced the same result as the previous text (properly interpreted title, but with the smaller font size). I tried resetting the figure settings to default values using reset(figname), but that didn't help either. I would be grateful for any help on this question!

Réponses (2)

madhan ravi
madhan ravi le 12 Déc 2018
Modifié(e) : madhan ravi le 12 Déc 2018
Use handles and assign the size directly:
plot(x,y, 'k', 'LineWidth', 2)
h=title('*{\cal{R}}(t)* Model 2', 'interpreter', 'latex');
h.FontSize=20;
  4 commentaires
Rebecca Tyson
Rebecca Tyson le 12 Déc 2018
Did you replace the asterisks with dollar signs? They're supposed to be dollar signs, but to turn off the MATLAB question window text interpreter I had to use asterisks.
madhan ravi
madhan ravi le 12 Déc 2018
Modifié(e) : madhan ravi le 12 Déc 2018
I just did the following and it works:
plot(1:10, 'k', 'LineWidth', 2)
h=title('${\cal{R}}(t)$ Model 2', 'interpreter', 'latex');
h.FontSize=50;

Connectez-vous pour commenter.


Rebecca Tyson
Rebecca Tyson le 13 Déc 2018
I believe you! It doesn't work on my computer though - weird. :(
  2 commentaires
BNB
BNB le 10 Sep 2019
I guess it will be too late now, but I wanted to add that I was thinking to have the same problem. Until I understood that the size of the text interpreted by the latex interpreter is a lot smaller than normal text size. Thus, you may think it is not working, but in fact, you only have to increase the font size value by a larger number. You can try some very different numbers like 1 and 100 to see if this is the case.
(I am using MATLAB R2018a)
Rebecca Tyson
Rebecca Tyson le 10 Sep 2019
Thank you very much! I will more than likely be wanting to use the LaTeX interpreter again in the future, so your answer is not too late!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Time Series Objects dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by