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

Remove quotes from Cell Expression

196 views
Skip to first unread message

robert prince-wright

unread,
May 6, 2009, 5:25:50 AM5/6/09
to

Can someone show me how to write the list m1 to a notebook without the quotes showing?

m1 = {{"a",b},{c,d}};
nb = CreateDocument[];
NotebookWrite[nb, Cell[ToBoxes@Grid[m1],"Text"]]

The expression below gives the right result so there is something missing in my limited understanding of Cell expressions.

Grid@m1


Thanks
Robert


dbr...@gmail.com

unread,
May 7, 2009, 6:31:42 AM5/7/09
to
If you are wanting to suppress the showing of explicit quotation marks
use the option

ShowStringCharacters->False

as an option to the Cell expression.

--David

On May 6, 5:25 am, robert prince-wright <robertprincewri...@yahoo.com>
wrote:
> Can someone show me how to write the list m1 to a notebook without the qu=


otes showing?
>
> m1 = {{"a",b},{c,d}};
> nb = CreateDocument[];
> NotebookWrite[nb, Cell[ToBoxes@Grid[m1],"Text"]]
>

> The expression below gives the right result so there is something missing=

Albert Retey

unread,
May 7, 2009, 6:32:14 AM5/7/09
to

That has nothing to do with the convertion to boxes but is controlled by
Cell properties. There are two ways to achieve what you want:

1) use cells of style "Output", which will by default not show the
string characters (which is why you don't see them with Grid@m1):

NotebookWrite[nb, Cell[BoxData[ToBoxes@Grid[m1]], "Output"]]


2) stay with the "Text" style cells, but change the settings for
ShowStringCharacters:

NotebookWrite[nb,
Cell[BoxData[ToBoxes@Grid[m1]], "Text",
ShowStringCharacters -> False]]

Note that I have wrapped the box expression with BoxData, which was
necessary in my version to avoid an error indication for the created cell...

hth,

albert

John Fultz

unread,
May 7, 2009, 6:36:11 AM5/7/09
to
On Wed, 6 May 2009 05:26:11 -0400 (EDT), robert prince-wright wrote:
>
>
> Can someone show me how to write the list m1 to a notebook without the
> quotes showing?
>
> m1 = {{"a",b},{c,d}};
> nb = CreateDocument[];
> NotebookWrite[nb, Cell[ToBoxes@Grid[m1],"Text"]]
>
> The expression below gives the right result so there is something missing
> in my limited understanding of Cell expressions.
>
> Grid@m1
>
>
> Thanks
> Robert

Actually, Grid@m1 *does* create something with quotes. They're just hidden by
virtue of the fact that the "Output" style has ShowStringCharacters->False set.
To see this, evaluate Grid@m1, then click in the cell and type a character.
This auto-converts the cell into an Input cell, and the quotes will pop back
into existence.

If this kind of solution is satisfactory to you, then the only thing you have to
change is...

NotebookWrite[nb, Cell[ToBoxes@Grid[m1],"Text", ShowStringCharacters->False]]

However, if there are quotes you did want to see, and they don't show up inside
of a string (e.g. "a quote -> \" <-"), then this will cause problems.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.


David Bailey

unread,
May 8, 2009, 12:09:35 AM5/8/09
to
If you unformat the two cells (click in the cell and use the menu item
Cell>Show Expression), you will see that your first cell is of style
"Text", while the second is of style "Output" - that is why they look
different. One way to make a text cell with strings displayed without
quotes is like this:

m1 = {{"a", b}, {c, d}};


nb = CreateDocument[];
NotebookWrite[nb,

Cell[ToBoxes@Grid[m1], "Text", ShowStringCharacters -> False]]

Alternatively, you can specify "Output" style rather than "Text" style
for your cell.

Unformatting existing cells and copy/pasting the expression revealed, is
a great way to create new cell expressions in your code.

David Bailey
http://www.dbaileyconsultancy.co.uk

Alexei Boulbitch

unread,
May 8, 2009, 12:10:41 AM5/8/09
to
Yes, Robert,

a function like the following:

In[21]:= f[x_String] := ToExpression[x];
f[x_] := x;
Map[f, {{"a", b}, {c, d}}]

can do the job for you.
Alexei

Can someone show me how to write the list m1 to a notebook without the quotes showing?

m1 = {{"a",b},{c,d}};
nb = CreateDocument[];
NotebookWrite[nb, Cell[ToBoxes@Grid[m1],"Text"]]

The expression below gives the right result so there is something missing in my limited understanding of Cell expressions.

Grid@m1


Thanks
Robert

--
Alexei Boulbitch, Dr., habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax: +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.

0 new messages