Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

new line using text annotations with latex option

570 views
Skip to first unread message

Corinne

unread,
Mar 12, 2009, 3:23:01 PM3/12/09
to
Hello all,

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

Ryan

unread,
Apr 17, 2009, 10:30:19 AM4/17/09
to
I'm not sure if it'll work with what you have but try char(10) instead of \n.

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'])

Shaun

unread,
Apr 17, 2009, 11:30:04 AM4/17/09
to
annotation('textbox',[.5,.5,.4,.3],'String'...
,{'I would like a new line here', '$$\frac{\sigma}{\sqrt{n}}$$'},'interpreter','latex')

Corinne

unread,
Apr 20, 2009, 4:46:02 PM4/20/09
to
"Shaun" <s...@s.com> wrote in message <gsa79s$4t8$1...@fred.mathworks.com>...

> annotation('textbox',[.5,.5,.4,.3],'String'...
> ,{'I would like a new line here', '$$\frac{\sigma}{\sqrt{n}}$$'},'interpreter','latex')

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.

0 new messages