How can I add bulleted list in Matlab annotation textbox

5 visualizaciones (últimos 30 días)
Clayton Valentine
Clayton Valentine el 5 de Dic. de 2013
Comentada: Nina el 18 de Jul. de 2025
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:

Respuestas (1)

Nina
Nina el 14 de Jul. de 2025
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 comentarios
Stephen23
Stephen23 el 16 de Jul. de 2025
Editada: Stephen23 el 16 de Jul. de 2025
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 el 18 de Jul. de 2025
ah yes! that's much better, thanks!

Iniciar sesión para comentar.

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by