필터 지우기
필터 지우기

Plot title: set font size with LaTeX interpreter

조회 수: 65 (최근 30일)
Andrey Kazak
Andrey Kazak 2015년 10월 28일
Greetings, dear community!
I use LaTeX interpreter for generating a plot title:
title('Interesing Plot','Interpreter','latex')
Now I want is to be underlined:
title('\underline{Interesing Plot}','Interpreter','latex')
And finally I want to set font size either explicitly or using LaTeX syntax:
  • \Huge
  • \huge
  • \LARGE
  • \Large
  • \large

답변 (2개)

Martin
Martin 2018년 4월 13일
By default, text objects in MATLAB® support a subset of TeX markup. For a list of supported TeX markup, see the text Interpreter property description.
It sould be: (underling not possible)
title('\fontsize{19} Interesing Plot')
Or you can do:
hT = title('Interesing Plot')
set(hT, 'FontSize', 19)
I hope you did already find a solution :), but for others reading this question.... I post an answer.
Martin
  댓글 수: 2
Ondrej Zika
Ondrej Zika 2019년 9월 6일
편집: Ondrej Zika 2019년 9월 6일
Hi,
I find that latex formatting in title simply doesn't work. While for axes or legend I can format the text as you indicated, for title nothing works.
i) When the content is simply text it works fine, selecting default font size
t=title('Interesing Plot')
ii) When I add fontsize
t=title(['\fontsize{19} Interesting Plot']
iii) Any subsequent manipulations have no effect, e.g.
set(t, 'FontSize', 16);
I am on Ubuntu 18.04, Matlab2019a.
Thanks for any tips.
Ondrej
Martin
Martin 2019년 9월 9일
Hello Ondrej,
Please try tex interpreter in stead of latex:
figure
plot(rand(10,10))
title('\fontsize{19} Interesing Plot', 'Interpreter','tex')
Martin

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


Mariusz Matusiak
Mariusz Matusiak 13분 전
Hi All,
I've seen this thread is a bit old but I decided to share my observations as they might turn out helpful for someone else in future. When it comes to the latex and tex interpreters, the MATLAB documentation (https://www.mathworks.com/help/matlab/ref/title.html?s_tid=doc_ta#btpi3rq-1_sep_shared-Interpreter) might feel a bit chaotic and misleading, mixing different ways.
1. To change the font size (tested with MATLAB R2024a):
a) for the latex interpreter use the regular Name-Value parameter specifiers e.g.
title('Nice plot!', 'FontSize', 14, 'Interpreter', 'latex') % 'latex' way
b) for the tex interpreter add \fontsize{..}, e.g.
title('\fontsize{14} Nice plot!', 'Interpreter', 'tex') % 'tex' way
2. To bold:
a) for the latex interpreter the FontWeight parameter is not supported hence add the latex command \textbf{..} e.g.
title('\textbf{Nice plot!}', 'FontSize', 14, 'Interpreter', 'latex') % 'latex' way
b) for the tex interpreter add \bf e.g.
title('\bf \fontsize{14} Nice plot!', 'Interpreter', 'tex') % 'tex' way
BR,
Mariusz

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by