I am trying to add some text to a figure using the textbox annotation and the latex option. Typically the newline command in latex is either:
\\ or
\newline
But when I use these commands they are not interpreted.
Example:
figure
annotation('textbox',[.5,.5,.3,.3],'String'...
,'$$I\ would\ like\ a\ new\ line\ here\ \\ \frac{\sigma}{\sqrt{n}} $$','interpreter','latex')
alternatively you could try the other command:
figure
annotation('textbox',[.5,.5,.3,.3],'String'...
,'$$I\ would\ like\ a\ new\ line\ here\ \newline \frac{\sigma}{\sqrt{n}} $$','interpreter','latex')
Neither of these inserts a line break. Does anyone know how to solve this?
Thanks in advance!
Corinne
I was struggling to do the same thing so I added a text box to a figure like this:
text(1,1,'Monday Tuesday')
and manually added the carriage return before Tuesday. Then by right-clicking on the textbox and selecting 'Show M-Code' I found that the way to do it is this:
text(1,1,['Monday' char(10) 'Tuesday'])
Thanks guys,
Both of the suggestions worked. Just to sum up for anyone else who reads this. I found you can use them with commands like 'title' too. The following all work:
title({'I would like a new line here', '$$\frac{\sigma}{\sqrt{n}}$$'},'interpreter','latex')
title(['$$I\ would\ like\ a\ new\ line\ here$$', char(10), '$$\frac{\sigma}{\sqrt{n}} $$'],'interpreter','latex')
title({'$$I\ would\ like\ a\ new\ line\ here$$', char(10), '$$\frac{\sigma}{\sqrt{n}} $$'},'interpreter','latex')
title({'$$I\ would\ like\ a\ new\ line\ here$$', '$$\frac{\sigma}{\sqrt{n}} $$'},'interpreter','latex')
Example 1, 2, and 4 produce the same thing,
3 adds more space between lines.