How can I add bulleted list in Matlab annotation textbox
4 ビュー (過去 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!

