6
$\begingroup$

I'd like to share link that jumps directly to a particular section of deployed notebook, any tips?

Online Mathematica docs provide an anchor to each cell, so you can link to them directly -- example

I looked through the source of my deployed notebook and didn't see any anchors, so probably need changes on the notebook side.

In Google docs, it's possible to create such links by first creating Table of Contents (an example such link)

$\endgroup$
8
  • $\begingroup$ I have lectures organized as multiple notebooks (one notebook for one lecture). I used to give in one notebook a reference to a certain equation in another notebook. This reference has been organized as a button that opens this other notebook with the necessary equation being already on the screen. Is it close to what you need? If yes, I will share the code. $\endgroup$ Aug 26, 2021 at 8:17
  • $\begingroup$ @AlexeiBoulbitch does it work on wolfram cloud? I'm looking for a clickable link to a deployed notebook that I can share online $\endgroup$ Aug 26, 2021 at 8:26
  • $\begingroup$ I never tried it with the cloud. $\endgroup$ Aug 26, 2021 at 10:20
  • $\begingroup$ In my opinion it is not possible now, but maybe in the next release. Therefore I deleted my post. $\endgroup$
    – hieron
    Aug 26, 2021 at 16:53
  • 1
    $\begingroup$ Maybe you can use cell tags and NotebookLocate $\endgroup$ Apr 5 at 20:39

2 Answers 2

2
$\begingroup$

Update

In the recent post on the Wolfram Community Brian Van Vertloo (WRI) showed how it is possible to build HTML from the Documentation pages using "PacletTools`":

The documentation build code that is shipping with the desktop products is capable of building HTML pages already, believe it or not. The relevant function is PacletDocumentationBuild (https://reference.wolfram.com/language/PacletTools/ref/PacletDocumentationBuild.html), where you use:

Needs["PacletTools`"];PacletDocumentationBuild[paclet, outdir, "HTML"]

I haven't tried it, but probably it will add the anchors I described in the original version of this answer.


Original answer

You can easily check that every anchor on a published Documentation page is equal to the CellID of the corresponding Cell in the offline Documentation:

screenshot1

screenshot2

Your deployed notebook has no CellIDs set to its Cells.

According to the Docs,

Typically, a CellID will be created automatically by the system for each new cell inserted in a notebook that has the setting CreateCellID->True.

Setting CreateCellID->True will not affect CellID options of cells already in the notebook at the time the option is set.

Your Notebook has no CreateCellID->True. So you should first create a new Notebook and set this option:

SetOptions[EvaluationNotebook[], CreateCellID -> True]

Then you can copy-paste the contents of your original Notebook into the new Notebook. All Cells will have CellID assigned. After this you may deploy the new Notebook.

$\endgroup$
4
  • $\begingroup$ that sounds like exactly what I need.....how do I get CellID? The example in help for CellId uses NotebookRead command but that requires CellTags to be set first $\endgroup$ Aug 27, 2021 at 15:04
  • $\begingroup$ I think this may need something extra, I just tried deploying notebook with cell ids set, as seen by printing FullForm of the cell, but still no anchors -- wolframcloud.com/obj/yaroslavvb/newton/… $\endgroup$ Aug 27, 2021 at 15:07
  • $\begingroup$ @YaroslavBulatov You are right, it seems in deployed version anchors still aren't present. The Documentation pages aren't deployed in this sense, they were exported as HTML pages, I think. $\endgroup$ Aug 27, 2021 at 15:12
  • 1
    $\begingroup$ @YaroslavBulatov I updated the answer with a possible workaround via building HTML and deploying it to the cloud with PacletDocumentationBuild. See examples on the linked Docs page. $\endgroup$ Jan 17, 2022 at 11:00
0
+50
$\begingroup$

TLDR: Maybe you can use tags with Button["interesting tag",NotebookLocate["interesting tag"]] in text cells or (* NotebookLocate["interesting tag"] *) with in-place evaluation (Ctrl+Shift+Enter) in input cells. In a cloud notebook, you might have to use CellPrint with the CellTags option as I did not find a menu item for tags.

Usual Mathematica notebook (not the cloud notebook)

In the usual Mathematica notebook (not the cloud notebook) you can add a tag to a cell by right-clicking the cell and adding a tag. For example, you can add a tag called "interesting tag". Then you can use Button["interesting tag",NotebookLocate["interesting tag"]] to jump to that tag if the button is in an output cell or text cell.

If you would like to add the "link" in an input cell with an expression that will be evaluated like s=4+j, then instead of a button you can use a comment (* NotebookLocate["interesting tag"] *) and use in-place evaluation with Ctrl+Shift+Enter to evaluate only NotebookLocate["interesting tag"]. This method has the advantage that you can return back the previous cell using Ctrl+F for search and find and then search for that piece of code. One could also add a tag to the previous cell where the user "teleported from".

The cloud notebook

On the cloud notebook, I did not find a menu option for tags but it seems tags still work using CellPrint with the CellTags option. For example:

CellPrint[TextCell["abcd", "Text", CellTags -> "tag"]]

then I checked that NotebookLocate["tag"] seems to jump to the location of the tag placing the tag at the top of the screen without selecting the tag (unlike in the usual non-cloud notebook). This seems to work for two tags as well so I imagine that this works for any number of tags.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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