How can I add bulleted list in Matlab annotation textbox
조회 수: 6 (최근 30일)
이전 댓글 표시
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:
댓글 수: 0
답변 (1개)
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
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Numeric Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

