How do I turn off the LaTeX interpreter per line in my title within MATLAB?
조회 수: 20 (최근 30일)
이전 댓글 표시
Hi all,
I'm looking to have, within a title, two lines: the top one a LaTeX formated text (including subscript and a \Delta symbol), and the lower line with some text that I want to disable the formatting as it would look messy - e.g. my sample name is '14_6_520', but at the moment this would subscript the 6 and 5, as shown in the image below:

I understand that to put two lines in a plot title, it requires the following code after plot:
title({'First line';'Second line'})
The top title (this is the one I want with the formatting)
Plotting = '\Delta{H_{Irr-Uir}} vs Disp'
The lower title (this is the one I don't want to have formatted - here I would enter 14_6_520):
ID = string(inputdlg('Enter the name to ID this data with:')); %this is where, in the GUI, I'd enter the text 14_6_520
Putting these together in to a plot title with two lines would look like this:
title({(Plotting);(ID)});
but I'd like 'ID' with 'interpreter' set to 'none' to tell it I don't want the lower line to be formatted, which I thought would be achieved with this code:
title({(Plotting);(ID,'Interpreter','none')});
However this does not work. Is there a way to choose interpreter on/off (by line) within the title? Many thanks!
댓글 수: 0
답변 (1개)
Star Strider
2025년 7월 17일
편집: Star Strider
2025년 7월 17일
Probably the easiest way to do what you want would be to 'escape' the underscore lines using backslashes (\) --
figure
title(["$\Delta{H_{Irr-Uir}} vs Disp$" "$14_66_20$"], Interpreter='LaTeX') % Original
figure
title(["$\Delta{H_{Irr-Uir}} vs Disp$" "$14\_66\_20$"], Interpreter='LaTeX') % Underscores 'Escaped'
EDIT --
If the lines are entered with the underscores, use the strrep function to add the backslashes automatically --
numstr = '14_66_20'
numstresc = strrep(numstr, '_','\_')
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

