필터 지우기
필터 지우기

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

조회 수: 293 (최근 30일)
Rebecca Tyson
Rebecca Tyson 2018년 12월 12일
댓글: Rebecca Tyson 2019년 9월 10일
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!

답변 (2개)

madhan ravi
madhan ravi 2018년 12월 12일
편집: madhan ravi 2018년 12월 12일
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
Rebecca Tyson
Rebecca Tyson 2018년 12월 12일
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 2018년 12월 12일
편집: madhan ravi 2018년 12월 12일
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;

댓글을 달려면 로그인하십시오.


Rebecca Tyson
Rebecca Tyson 2018년 12월 13일
I believe you! It doesn't work on my computer though - weird. :(
  댓글 수: 2
BNB
BNB 2019년 9월 10일
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 2019년 9월 10일
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by