4
$\begingroup$

I want to include a Hyperlink inside of a usage. For example:

function::usage = "function[x] does a complicated calculation
  following the algorithms in this paper."

where "this paper" is hyperlinked to a paper on the web.

To get an idea for how the boxes works for Hyperlinks, I did:

Hyperlink["here", "paclet:ref/Plot"] // ToBoxes

TagBox[ButtonBox[PaneSelectorBox[{False->"here", True->StyleBox["here", {HyperlinkActive}]}, False, BaseStyle->{Hyperlink}, FrameMargins->0, ImageSize->Automatic], BaseStyle->Link, ButtonData->paclet:ref/Plot, ButtonNote->paclet:ref/Plot], #1&]

That was a lot of boxes to put into the usage string:

function::usage = "function[x] does a complicated calculation
  following the algorithms in 
  \!\(\*TagBox[\(\*ButtonBox[\(\*PaneSelectorBox[]\),y]\),y]\)"

I got overwhelmed with all the \(\* \)'s so I gave up.

Is there a better way to include hyperlinks inside of usage?

$\endgroup$
9
$\begingroup$

I usually do it this way:

f::usage =
        ToString[Row[{
                      Style["f[ _Integer ]", Bold], " maps ", 
                      Style[Hyperlink["integer", "paclet:ref/Integer"], Italic], 
                      " to real number."
                     }], StandardForm];

?f

formated usage text

$\endgroup$
  • $\begingroup$ Haven't seen you for some days!:-) $\endgroup$ – xyz Nov 12 '14 at 13:28
  • $\begingroup$ @ShutaoTang Am kind of busy recently :) $\endgroup$ – Silvia Nov 13 '14 at 8:33
2
$\begingroup$

Just evaluate your hyperlink code:

Mathematica graphics

then copy the hyperlink from the output and paste it in your string

Mathematica graphics

The boxes were worked into your string automatically:

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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