# Why do quote marks appear in output when saved with Save Selection As?

Update #2: This behavior has been confirm across platforms and in multiple versions. Therefore:

1. Is this a bug or a feature?

2. Can I disable this "feature" so that copying a selection of Cell contents works the same as copying the entire Cell?

Update: As Simon Woods astutely observed this problem only occurs when you select the cell contents rather than the entire cell via the bracket. Those two tested this and reported, please check again selecting only the contents and see if the behavior appears.

In version 10 quote marks (i.e. ShowStringCharacters) appear in output when it is saved as an image using Save Selection As...:

CharacterRange["a", "z"]


Appearance in the Notebook:

{a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z}

When saved as a PNG:

These quote marks do not appear in export from version 7, at least as I had it configured.

### Can I keep them from appearing?

-
I do not have MMA 10 installed yet... but I would like to know whether you have tried to Save Selection As... of ToExpression[CharacterRange["a", "z"]] ? – Boson Jul 21 '14 at 8:59
@Boson I haven't tried that, but that's not really what this question is about. Your code would produce Symbols rather than Strings. – Mr.Wizard Jul 21 '14 at 9:03
Am not seeing this on OS X – Mike Honeychurch Jul 21 '14 at 9:35
Strange. I get the quotes if I select the cell contents but not if I select the cell bracket. – Simon Woods Jul 21 '14 at 11:00
I'm on Windows 8.1 and my behavior is exactly as @SimonWoods reports. – RunnyKine Jul 21 '14 at 15:32

The quotes appear because the InputForm does not show them, while the OutputForm does.

Programmatically, you can explicitly call OutputForm to avoid this:

Export["quotes.png", OutputForm[CharacterRange["a", "z"]]]


You can also go into Format > Option inspector… and look for ShowStringCharacters and using Save selection as…:

-
Carlo, would you please describe exactly what you changed in the Option Inspector? I cannot seem to find the right setting for this. – Mr.Wizard Jul 21 '14 at 9:05
@Mr.Wizard Funny, I can't reproduce the behavior you described under Linux. I think the option mentioned by Carlo is under FormattingOptions>ExpressionFormatting>DisplayOptions. For me it does not change the behavior of the string export, however. – sebhofer Jul 21 '14 at 9:18
As a matter of fact I've changed the option back, and I still can't see the quotes, but I'm on MacOs X in this case this might be a bug specific to Linux. – Carlo Jul 21 '14 at 9:46
@sebhofer I'm on Windows so if this is not happening in either OSX or Linux I think it is a bug. – Mr.Wizard Jul 21 '14 at 9:50

1. Is this a bug or a feature?

My opinion is that it is not a bug. Different selections yield different inputs, so different outputs are at least possible. On the other hand, I'm not sure I would call it a feature. It strikes me that users will wonder why they cannot easily get an image of what they see.

"Save Selection As..." seems to consistently show the results of NotebookRead[]. There are (at least) three forms of output from NotebookRead[], a box expression, a complete Cell or a list of cells, or a String. Each type is packaged into a Notebook that is then exported.

Examples of the three forms are shown below. The first is the selection of the contents of the output cell of CharacterRange["a", "c"]. The second is the selection of the whole output cell. The third is the selection of the number 123 in an input cell.

Note that a box expression is put in a cell with no style. A complete Cell is passed as is. And note that a String, such as 123, is automatically formatted as "Text".

In this regard, @Carlo has it right, that when only the contents are selected, we lose the information that the style is "Output".

It is not clear to me why, assuming it is intentional, saving a selection from the contents of the cell does not automatically inherit the cell style of the enclosing cell in the notebook expression that is exported. There could be issues if the selection was inside a inline cell I suppose. For instance sometimes Mathematca interprets actions, such as when an input or output cell is pasted inside an input cell. The expression is pasted, not the cell, whereas pasting a text cell in an input cell yields an inline cell.

2. Workaround?

I don't have a general solution. One might add something to KeyEventTranslations.tr or to MenuSetup.tr to select the cell. If nb is the notebook with the selection to be saved, the following

SelectionMove[nb, All, Cell];
FrontEndTokenExecute[nb, "SelectionSaveSpecial"]


Other programmatic approaches seem possible, such as styling the selection with the cell's style. I could not discover a way so that the menu command would do this.

-

With V10 on OS X, I get

Might be a platform issue.

-

I'm on 10.0 for Mac OS X x86 (64-bit) (June 29, 2014) and and have the following observed:

• highlighting the Output-Cell and using the Command "Save Selection As" leads to the following result;

• highlighting the Output and using the Command "Save Selection As" leads to the observed result;

Wile

CellPrint[ExpressionCell[CharacterRange["a", "z"], "Output", ShowStringCharacters -> True]]


outputs

{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}

does

CellPrint[ExpressionCell[CharacterRange["a", "z"], "Output", ShowStringCharacters -> False]]


what one shall expect:

{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}

at least on the Monitor ... Standing above can be applied accordingly for "Save Selection As"

-
This also happens in V9 ...but not in V8. – Mike Honeychurch Jul 21 '14 at 22:29