Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Using hyperlinks to move to computations and back to text
Replies: 2   Last Post: Feb 6, 2013 5:51 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alexei Boulbitch

Posts: 483
Registered: 2/28/08
Re: Using hyperlinks to move to computations and back to text
Posted: Feb 6, 2013 5:51 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I am using M9 to take notes from an online course, writing into a Text
cell, but occasionally I want to be able to use a hyperlink at a place in
the text to jump to some illustrative computation code in the same
notebook. At the end of that code there should be another hyperlink to
jump back to the original text position.

I can do this procedure manually (tediously) of course, but has anyone
formulated some more automated procedure for this please?

It would be really efficient if a "button" can be clicked to input the
label for the hyperlink that jumps to the computation code, while dividing
the current text cell just below the cursor and inserting a new cell, in
order to assign a tag to this new cell for returning from the computation
code. Another "button" would create a new hyperlink after the code, in
order to jump back to the text.

Or is there a better solution for effectively typing-up a textbook with
hyperlinks for illustrative example detours?

Any help would be much appreciated.

Hi, David,
In addition to the advices of David Park communicated here I would like to
add few things. I do the thing you are looking for on the everyday basis,
since I for years keep my whole work documentation in the form of Mathematica notebooks. This includes all types of documents: drafts of calculations, memoirs for personal use and internal papers and presentations (that I do for the company I work in). The main reason for me to use Mathematica is the ability to keep the calculations and the code together with the text.

Most often I use a very quick and simple approach: I have the input and output cells with the code and results collapsed around the neighbour cell (typically with a formula which is obtained in these input-output cells, but also with any text). This is easily done. I usually from the very beginning put Cell Grouping to Manual: Menu/Cell/Grouping/Manual Grouping. In the course of writing the notebook, as soon as I have such input-output cells that I need to collapse, I group them with the neighbour cell by marking them all and clicking Ctrl+G. Then make a double click on the bracket of the cell around which you wish to collapse the group which is at the right notebook margin. Like this you can keep all types of materials including formulas, text and any graphics in addition to input-output. The cells that you want to hide may also be defined as Closed. Go to Menu/Cell/Cell Properties and uncheck Open. This prevents such cells from occasional opening, in case such an opening is strongly undesired. This may be the case, if you, say, share the notebook with colleagues.

Further, a simple version of a sidebar, described in the answer of David Park may be easily done also without Presentations package. For example, evaluate this:

Button["Sinus plot",
Plot[Sin[x], {x, 0, 2 \[Pi]}],
Button[Style[" Close the window", 14, Blue], NotebookClose[]]
WindowTitle -> "Sinus plot", WindowSize -> {500, 400}]

Evaluating this code results in a button. Its pressing opens a new notebook, a sidebar, showing a plot. You can now mark the button itself and copy-paste this button everywhere in the notebook, including any place inside a text cell. You only need now to put the cell with this Button statement in a separate cell in your notebook and declare it to be the Initialization cell (Menu/Cell/Cell Properties/Initialization Cell). You may then close it as I described above, or collapse.

However, this button will only bring up the result of evaluation of the code Plot[Sin[x], {x, 0, 2 \[Pi]}], but not the code itself. If you need to show also the code, and/or occasionally to provide some text, the thing becomes more complex. It can also be done, but will require too much programming efforts in the place you generally expect to simply type a small text. In this case it is much faster to go to the Presentations package.

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.