MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Convenient way to add inline formatting to usage Messages

  • To: mathgroup at
  • Subject: [mg119831] Re: Convenient way to add inline formatting to usage Messages
  • From: Mike Bryniarski <michael.bryniarski at>
  • Date: Fri, 24 Jun 2011 07:47:05 -0400 (EDT)
  • Reply-to: comp.soft-sys.math.mathematica at

On second examination, it's not really clear to me what you are looking to 
accomplish and my initial response wasn't very useful. I think the styles in question are just used to format internal stuff consistently; they have names like "TI"(Times Italic?) and "SO" (Sans Oblique).

Are you looking for a way to automate the formatting usage messages? I don't think there is any built in system for doing that so you would have to style your messages manually. For functions with flat sequences of arguments you could do something like:

ClearAll[makeUsageTemplateString, makeStyledString];
Attributes[makeUsageTemplateString] = {HoldAll};
makeUsageTemplateString[fn_[args___], style_: "TI"] :=
  ToString[Defer[fn] @@
    Thread[Style[{args}, style, StripOnInput -> True]], StandardForm];

makeStyledString[str_String, style_: "TI"] :=
  ToString[Style[str, style, StripOnInput -> True], StandardForm];

makeUsageTemplateString::usage =
  makeUsageTemplateString[makeUsageTemplateString["f", "sty"]] <>
   " applies the style " <> makeStyledString["sty"] <>
   " returns the function " <> makeStyledString["f"] <> " as string.";

makeUsageTemplateString::usage // FullForm

If you want the RowBoxs included you may need to do some stuff with MakeBoxes. I don't see much point in this since the ctrl+shift+K template stuff works properly with this setup.

I hope this is helpful

On Tuesday, June 21, 2011 4:52:57 AM UTC-5, Alexey Popkov wrote:
> Usage Messages of built-in functions have embedded in-line formatting. For example:
> In[1]:= AiryAiPrime::usage // FullForm
> Out[1]//FullForm=
> "\!\(\*RowBox[{\"AiryAiPrime\", \"[\", StyleBox[\"z\", \"TI\"], \"]\"}]\) gives the derivative of the Airy function \!\(\*RowBox[{SuperscriptBox[\"Ai\", \"\[Prime]\"], \"(\", StyleBox[\"z\", \"TI\"], \")\"}]\). "
> One can see that this in-line formatting is based on the set of styles defined in "Styles for Inline Formatting" section of the Core.nb stylesheet. But I have not found any description of these styles as well as any description of the convenient way to add formatting to usage Messages.
> What is the convenient way to add in-line formatting to user-defined usage Messages in Mathematica? What are the usage rules of default styles for in-line formatting defined in the Core.nb stylesheet? I would like to add in-line formating for messages in my package just with Mathematica, without installing additional components like Workbench etc.

  • Prev by Date: Re: RevolutionPlot3D Help
  • Next by Date: How can I concatenate elements
  • Previous by thread: Re: Convenient way to add inline formatting to usage Messages
  • Next by thread: Re: Multiple use of Set on lists