How to generate plot titles with the latex interpreter and larger font sizes?
조회 수: 282 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (2개)
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
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
2018년 12월 13일
댓글 수: 2
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)
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!