9

Using “Create Hyperlink” dialog window I can create a link to a tagged cell in my notebook (it's “Destination notebook: Current notebook” radio button).

Now, I can't figure it out how to create such links with Hyperlink[] command.

I tried

Hyperlink["label", {"", "tag"}]
Hyperlink["label", {None, "tag"}]
Hyperlink["label", {Automatic, "tag"}]

etc., but nothing works.

Alekh
  • 93
  • 3

1 Answers1

14

You have to use EvaluationNotebook[] to point to the actual notebook you are working in (you don't even have to save it). First, create a cell with a tag:

CellPrint@Cell["Target cell", "Text", CellTags -> {"target"}]

and then create the link that points to the target cell:

Hyperlink["link", {EvaluationNotebook[], "target"}]

Clicking the link will select the cell with tag "target".

István Zachar
  • 47,032
  • 20
  • 143
  • 291
  • Thanks for your answer! Sorry for such a late thanks. – Alekh Dec 26 '12 at 18:36
  • Just one remark. With {EvaluationNotebook[], ...} I get a {NotebookObject[FrontEndObject[LinkObject[...]], 12], target} in the status line when hovering over the "link", while it’s just "target" with the “Create Hyperlink” dialog. – Alekh Dec 26 '12 at 18:43
  • 1
    @Alekh I guess you have to live with that, as I don't think there is any way to format the status notification of Hyperlink. Unfortunately, a StatusArea wrapper does not overwrite it. Perhaps it is possible to create a customizable hyperlink using lower level interface elements. – István Zachar Dec 26 '12 at 21:11
  • 1
    An extension: As noted in How to create permanent intra-notebook links, EvaluationNotebook[] may be replaced by another destination notebook (which I would have thought was obvious, but, hey, a new system can really undermine one's confidence until you get a good feel for how it works). – Michael E2 Jun 24 '16 at 19:24