# How to use double quotation marks (") in usage messages?

I have the following code:

Remove[f];
f::usage = "f[\"message\"] prints the message";
f[message_] := Print[message];


The usage message works except the quotation marks which are not shown in the information popup.

As an alternative one could use \\[OpenCurlyDoubleQuote] and \\[CloseCurlyDoubleQuote] but it is a bit long to write:

Remove[f];
f::usage = "f[\\[OpenCurlyDoubleQuote]message\\[CloseCurlyDoubleQuote]] prints the message";
f[message_] := Print[message];


With the resulting popup:

Do you know any way to make this shorter or get Mathematica to show the normal quotation marks?

• Your first example appears to work fine in my Mathematica 12.1 on MacOS 10.15.3. Mar 22 '20 at 17:54
• @CarlLange Good to know. I’ll try it in a few days. I’m still on Mathematica 11.3 Mar 22 '20 at 18:32

Here's a way around that, making use of the very-hard-to-work-with string-embedded syntax for boxes:

Remove[f]
f[a_] := 1;
f::usage = "\!$$f[\*StyleBox[\\\"message\\\", \"TI\", ShowStringCharacters->True]]$$ generates a plot of \!$$\*StyleBox[\"f\", \"TI\"]$$ as a function of \!$$\*StyleBox[\"x\", \"TI\"]$$ from \!$$\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"min\", \"TI\"]]$$ to \!$$\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"max\", \"TI\"]]$$.";


What did I do here? First I took the ::usage message for Plot, coped out the first line, and then made modifications of the argument structure by hand. This will look like:

The styling trick is that I took the first StyleBox in the message for Plot and added a ShowStringCharacters->True

One weird thing that seems to come from how Mathematica parses these templates, if you want to add spaces to the message you need to do them in a RowBox and change the formatting a bit, e.g.:

Remove[f]
f[a_] := 1;
f::usage = "\!$$f[\*StyleBox[RowBox[{\"\\\"this\", \" \", \"is\", \" \", \"a\", \" \", \"message\\\"\"}], \"TI\", ShowStringCharacters->True]]$$ generates a plot of \!$$\*StyleBox[\"f\", \"TI\"]$$ as a function of \!$$\*StyleBox[\"x\", \"TI\"]$$ from \!$$\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"min\", \"TI\"]]$$ to \!$$\*SubscriptBox[StyleBox[\"x\", \"TI\"], StyleBox[\"max\", \"TI\"]]$$.";

• Thank you for your answer! Is there a tutorial how to use these boxes in general? Please, can you explain what the usage string exactly means? Mar 23 '20 at 0:54
• The best tutorial is to look around at stuff on the site. In general most things that the FE renders, like Style are represented as a "box", e.g. StyleBox. The format \!$$\*<body>$$ means that whatever is inside <body> will be rendered as boxes, not as a string. That's about it. Mar 23 '20 at 0:58
• Ok thank you. The only thing which I could not find was "TI" in StringBox. How is it used/useful? Mar 23 '20 at 1:06
• Ah the "TI" is an italic text style that the FE uses all over the place, but that I wouldn't worry about. The only reason I left it in was to show that I copied this stuff directly from the usage message for Plot. You can get rid of it everywhere it occurs without worry. Mar 23 '20 at 1:07
• Thank you again. Note for others: You can reverse engineer the usage messages by printing e.g. File::usage and copy and paste it into a string literal ("") Mar 23 '20 at 1:22