Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have a usage message containig two-dimensional stuff (subscripts or formulas) and I call the usage, then sometimes I get an improperly formatted output enclosed in "...". Linebreaks are gone, but interestingly some formulas survive. Another ?example outputs fine.

It's hard to give an example, because it happens randomly.
Is this a known issue and and if so, is there a fix?

This is the output, when evaluated the first (bad) and second time (ok):

images of output

And this is the original usage:

"FlaechenPlot[{\!\(\*SubscriptBox[\(f\), \(1\)]\), \!\(\*SubscriptBox[\(f\), \(2\)]\),...}, {x, \!\(\*SubscriptBox[\(x\), \(min\)]\), \!\(\*SubscriptBox[\(x\), \(max\)]\)}, {\!\(\*SubscriptBox[\(f\), \(min\)]\), \!\(\*SubscriptBox[\(f\), \(max\)]\)}] zeichnet die Funktionen \!\(\*SubscriptBox[\(f\), \(i\)]\) im Bereich zwischen \!\(\*SubscriptBox[\(x\), \(min\)]\) und \!\(\*SubscriptBox[\(x\), \(max\)]\) und f\[ADoubleDot]rbt den Bereich zwischen \!\(\*SubscriptBox[\(f\), \(min\)]\) und \!\(\*SubscriptBox[\(f\), \(max\)]\) gem\[ADoubleDot]\[SZ] der gew\[ADoubleDot]hlten Option Filling.
FlaechenPlot[f, {x, \!\(\*SubscriptBox[\(x\), \(min\)]\), \!\(\*SubscriptBox[\(x\), \(max\)]\)}, {\!\(\*SubscriptBox[\(f\), \(min\)]\), \!\(\*SubscriptBox[\(f\), \(max\)]\)}] zeichnet entprechend den Bereich zwischen f und der x\[Dash]Achse.
FlaechenPlot[{\!\(\*SubscriptBox[\(f\), \(1\)]\), \!\(\*SubscriptBox[\(f\), \(2\)]\),...}, {x, \!\(\*SubscriptBox[\(x\), \(min\)]\), \!\(\*SubscriptBox[\(x\), \(max\)]\)}] zeichnet und f\[ADoubleDot]rbt das Gebiet zwischen den Kurven im Bereich von \!\(\*SubscriptBox[\(x\), \(min\)]\) bis \!\(\*SubscriptBox[\(x\), \(max\)]\).
FlaechenPlot[f, {x, \!\(\*SubscriptBox[\(x\), \(min\)]\), \!\(\*SubscriptBox[\(x\), \(max\)]\)}] f\[ADoubleDot]rbt und zeichnet das Gebiet zwischen Kurve und x\[Dash]Achse im Bereich von \!\(\*SubscriptBox[\(x\), \(min\)]\) bis \!\(\*SubscriptBox[\(x\), \(max\)]\).
OPTIONEN sind alle Optionen von Plot. Die Plot\[Dash]Option Filling \[Rule] Axis ist default."
share|improve this question
I have seen this problem myself several times. I can confirm that this happens. – Szabolcs Apr 5 '12 at 19:27
I'm actually seeing a similar problem with Options and SyntaxInformation for a function I've defined in a custom package. When first loading a package, all the options and inputs work, but aren't highlighted properly. Loading the package twice fixes things... – tkott Apr 6 '12 at 16:34
Hmm, only happens to me when restarting frontend. If you restart the kernel, things are fine... – tkott Apr 6 '12 at 17:12
Trace@?example is fascinating. So is ctrl+shift+e: the difference is the addition of extra slashes `` for every one present. – tkott Apr 6 '12 at 17:27

I think I have found a solution to this issue, which has been a problem since at least Mathematica version 6 and continues through at least version 10.3. The problem occurs when a user-defined usage message has complex formatting, for example, subscripts, entered using 2D input.

Suppose we have a function with usage message defined as

Mathematica graphics

which also can be input as

f::usage = "\!\(\*SubscriptBox[\(test\), \(1\)]\)\n\!\(\*SubscriptBox[\(test\), \(2\)]\)"

If we evaluate ?f once, we get

Mathematica graphics

which is incorrectly formatted, but if we evaluate it again in the same input cell, without deleting the output cell, we get the correct version:

Mathematica graphics

To see what's going on, we can run Trace[Information[f]], but that produces an enormous output, most of which has nothing to do with formatting the output string. To look for mentions of the usage string itself, we can use

Trace[Information[f], x_String /; !StringFreeQ[x, "test"], TraceBackward -> True] 

Mathematica graphics

This fingers the function System`Dump`fixmessagestring as a possible culprit. The function definition can be found with


which returns

System`Dump`fixmessagestring[System`Dump`s_] :=
    StringReplace[System`Dump`s, {"\n" -> "\\n", "\\" -> "\\\\", "\"" -> "\\\""}], 

This function converts some special characters in the string to explict form, as is done in InputForm. However, there are many kinds of formatting that this function doesn't address, which may be part of the problem. We can redefine this function to do a more thorough job by evaluating

System`Dump`fixmessagestring[System`Dump`s_] := ToString@InputForm@System`Dump`s

and now ?f returns the correct result every time. It's still not clear to me why the original version would cause a problem on the first evaluation, but not on the second, but, regardless, it seems that we have a fix.

A concern might be if this has an effect on built-in usage messages, but in my testing, the built-in messages display identically.

The redefinition could be done inside the user-defined package, making the fix invisible.

Also, with the command On[System`Dump`fixmessagestring], we can have Mathematica send us a trace message whenever System`Dump`fixmessagestring is called. That will let us see if the function is ever called anywhere outside of Information[], where the redefinition might have other consequences. So far it seems that the function is just confined to Information[] and ?.

Since there seems to be a one-line fix to this problem, it would be nice if it were eventually fixed in Mathematica itself.

share|improve this answer
This is truly a very interesting discovery! How did you find the fixmessagestring function? – Silvia Apr 11 '15 at 13:07
@Silvia I edited my answer to describe how I found it. – Simon Rochester Apr 16 '15 at 0:43
Thanks! It's very helpful to know the process! :) – Silvia Apr 16 '15 at 8:03
+1 for that last line, almost three years on. – Emilio Pisanty May 4 at 21:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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