2
$\begingroup$

There is something about strings which doesn't seem to be totally clear for me (for the moment):

When entering "a string", the output, formatted as "Output" gives this string without the quotes. But when changing the "Output" format to "Text" format (which looks better for text as the typewriter font for Output—for my uses at least), the quotes come back!

Why is that and how can I get non-typewriter fonts as output of evaluations, without the quotes coming back?

Thanks for all help, as always!

$\endgroup$

1 Answer 1

4
$\begingroup$

The first part of your question is answered with the option ShowStringCharacters.

Here with ShowStringCharacters -> True set on the output cell using the Option Inspector:

enter image description here

TraditionalForm does not display string characters by default:

enter image description here

If you want to control the printing of string characters for an entire Notebook you can edit the custom style sheet. If you give a more specific idea of the output that you want and when you want it I can provide more examples.

$\endgroup$
7
  • $\begingroup$ Thanks for your interesting comment! The problem is this: given "Compute " <> ToString[HoldForm[#1 (x - #2) = #3] & @@ Table[RandomInteger[{1, 10}], {3}]], I then use SelectionMove[EvaluationNotebook[], Previous, CellContents, 2]; SelectionEvaluate[EvaluationNotebook[]] in the next cell, as this is part of a bigger program. Now, this doesn't look "nice", at all, even when I add //TraditionalForm in the first cell. It's outputted in bold, and I'd love to have it as when you evaluate the first cell using shift-return. Is that possible? Thanks! $\endgroup$
    – Gabriel
    Commented Sep 11, 2013 at 15:08
  • $\begingroup$ @Gabriel Please tell me if this prints in the style that you want: ExpressionCell["Compute 8 (x - 6) = 7", "Input"] -- if that is correct we can work out the specifics of what you want to do, which I cannot yet understand from your description. $\endgroup$
    – Mr.Wizard
    Commented Sep 11, 2013 at 17:41
  • $\begingroup$ @Gabriel SelectionEvaluate[EvaluationNotebook[]] in your code does exactly what Shift+Return does. What behavior do you expect? $\endgroup$ Commented Sep 11, 2013 at 18:38
  • $\begingroup$ @Alexey: SelectionEvaluate[EvaluationNotebook[]] seems to behave differently when a CellContents is selected and when the cell in its entirety is selected. Is that normal? $\endgroup$
    – Gabriel
    Commented Sep 11, 2013 at 20:23
  • $\begingroup$ @Mr.Wizard: thanks for the suggestion, but using the code you provided prints the code in bold. I am searching for a Plain font, if possible. Is there any way of doing that? Thanks for all help! $\endgroup$
    – Gabriel
    Commented Sep 11, 2013 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.