How can I add bulleted list in Matlab annotation textbox

조회 수: 6 (최근 30일)
Clayton Valentine
Clayton Valentine 2013년 12월 5일
댓글: Nina 2025년 7월 18일
I am trying to add a bulleted list in a Matlab annotation textbox. I've tried using LaTex commands but all I get is: Unable to interpret latex string, such as
str = '\begin{itemized} \item First Line \item Second Line \end{itemized}';
figure;
ha = annotation('textbox', [0.5 0.5 0.4 0.2], 'Interpreter', 'latex');
set(ha, 'String', str)
This is similar to the way you put a table in an annotated textbox:

답변 (1개)

Nina
Nina 2025년 7월 14일
You can create bulleted lists in a textbox annotation by setting the string to be a cell array:
plot(1,1)
an = annotation('textbox', [0.40 0.40 0.20 0.15]);
an.Interpreter = 'latex';
an.String = {
["$\bullet$ \ First item"]
["$\bullet$ \ Second item"]
["$\bullet$ \ Third item"]
};
  댓글 수: 2
Stephen23
Stephen23 2025년 7월 16일
편집: Stephen23 2025년 7월 16일
Note that square brackets around scalar strings are completely superfluous:
["$\bullet$ \ First item"]
^ ^ !!! These do absolutely nothing !!!
The MATLAB documentation recommends to avoid storing scalar strings in a cell array: "When you have multiple strings, store them in a string array, not a cell array. Create a string array using square brackets, not curly braces. String arrays are more efficient than cell arrays for storing and manipulating text."
One much better approach is to simply use a string array:
plot(1,1)
an = annotation('textbox', [0.40,0.40,0.20,0.15]);
an.Interpreter = 'latex';
an.String = [...
"$\bullet$ \ First item",...
"$\bullet$ \ Second item",...
"$\bullet$ \ Third item"];
or at the time this question was asked, by using a cell array of character vectors.
Nina
Nina 2025년 7월 18일
ah yes! that's much better, thanks!

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

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by