0
$\begingroup$

When working myfile.nb with mathematica, I don't know how to search or goto the lines In[529] or Out[422], in mathematica. Ctrl+F only searches text in the document.

I sometimes write down important lines like In[529] or Out[422] on a notepad. But with it, it is hard to go there(the right place in the document). I admit that my working process is not very organized so the In[..] numbers or Out[..] numbers are not ordered neatly.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

Thanks you lericr, it was good to execute the code in the new notebook. For example :

(In current working .nb, type following code)

MyWorkingNb = EvaluationNotebook[] 

(Then open a new .nb, and type following code. The code will move the focus to In[529])

NotebookFind[MyWorkingNb, "In[529]=", All, CellLabel] 
$\endgroup$
1
  • 4
    $\begingroup$ It would be more stable/repeatable to assign output to named variables, as in something = calculation[], so that afterwards you can refer to it by something instead of Out[422]. $\endgroup$ Commented Feb 16, 2022 at 9:58

1 Answer 1

1
$\begingroup$

This can be done, but first some important caveats:

  1. These cell labels are very volatile. If you re-evaluate a particular cell, the labels change for both the input cell and the output cell. If you start a new session, the numbering gets re-initialized. So, if what you really want is to keep track of data, then assigning it to a variable is much more efficient (see also Roman's comment).
  2. If you really are interested in keeping track of a particular cell (as opposed to a variable), it's probably better to use cell tags (more below).

There is a function NotebookFind. It's best to go read the documentation, but in short, you could do something like this (replace "Out[3]=" as needed):

NotebookFind[EvaluationNotebook[], "Out[3]=", All, CellLabel] 

On the other hand, if you want to find cells with a particular tag (replace "test-tag" as needed):

NotebookFind[EvaluationNotebook[], "test-tag", All, CellTags] 

One thing you might find nice about cell tags, as opposed to cell labels, is that some of the functionality is available via the menus. You can add, remove, and search cell tags via the Cell menu (specifically Cell->Cell Tags)

$\endgroup$
1
  • $\begingroup$ Thank you very much! $\endgroup$ Commented Feb 18, 2022 at 16:24

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.