I notice that built in functions have a drop-down interface that displays multiple usage messages. enter image description here


How do I implement more than one usage message (for a single function) in a package.

I have tried

f::usage = "f[x],

but this fails to work.

(Mathematica 11.3)

  • 7
    $\begingroup$ Get rid of the comma and the spaces at the start of the second line. Then it will work. You can also write \n instead of an explicit newline. Personally I do them like this, but it's absolutely not necessary to use <>. f::usage = "f[x]\nf[x,y]" works, and so does the version where you just press enter (and add no spaces!) in place of \n $\endgroup$
    – Szabolcs
    Jan 13 '19 at 13:16
  • $\begingroup$ You might also be interested in the FormatUsage function of the ForScience paclet that I'm developing - It allows you to easily add formatting (e.g. italic text) to your usage messages. The problem with formatting is that the front end seems to be quite picky, so if the formatting is not done carefully, you won't get the usage messages to display. So even if you don't use the function itself, you can still use it to general "valid" usage messages to see how they're structured. $\endgroup$
    – Lukas Lang
    Jan 13 '19 at 14:33
  • 1
    $\begingroup$ You may find this question and it answers helpful. $\endgroup$
    – m_goldberg
    Jan 13 '19 at 15:00
  • $\begingroup$ Possible duplicate of User-defined usage message template; removing repeated text $\endgroup$
    – bbgodfrey
    Jan 13 '19 at 22:52

Browse other questions tagged or ask your own question.