# Fixing different display colors within string

My question below is my attempt to reduce a problem I am having to the simplest possible version that will show the error I am trying to fix. I recognize that the coding looks tortured, and I will provide at the end an explanation for why I am doing it this way, but hopefully we can just focus on the particular behavior in my abstracted example.

(copyable version below)

CellPrint @ ExpressionCell[
"\!$$\*SubscriptBox[\(H$$, $$2$$]\)O (H)",
"Input",
ShowStringCharacters->False
]


Why is the "O (g)" black and the rest of the string grey? And how do I change it so that it all displays as black?

Background: This is a follow-up to this thread. I am using the strings as a way to define palette-selectable labels that preserve non-Mathematica-standard notation that I can then use with the Notation package to associate this alternate notation (both input and output) with more standard symbols that can be used internally. I need the label to be in a string so that the notational form is maintained without parsing once it is interpreted by a ParsedBoxWrapper@TemplateBox, and I use a custom style to suppress the display of those quotation marks.

Edit: I originally had this including "\""<>string<>"\"", but have since discovered that the extra quotes aren't necessary to make the problem happen.

Short answer: You need to turn off auto styles:

CellPrint @ ExpressionCell[
"\!$$\*SubscriptBox[\(H$$, $$2$$]\)O (H)",
"Input",
ShowStringCharacters->False,
ShowAutoStyles->False
]


The issue is that your string, inside of an "Input" cell is not interpreted as a string, it is interpreted as an expression, and so the default syntax coloring happens.

• Magnificent! Thank you! It seems that this fix does not correct a related problem that I assumed would be automatically fixed when the coloration-problem was corrected. I will update my question with an example of that issue. – Kevin Ausman Apr 12 '19 at 19:44
• Actually, I will add my new question as a separate question rather than editing this one, since it looks like it is unrelated. Thank you. – Kevin Ausman Apr 12 '19 at 19:51
• I guess the bigger question might be whether or not there is a way to force a string in an input cell to be interpreted as a string rather than interpreted as an expression, because that might separately solve both this question and the other one that I recently added. – Kevin Ausman Apr 12 '19 at 20:01