1
$\begingroup$

What is the standard method for inserting tiny, hidden information on notebooks (.nb files) ?

From now on, I am planning to insert small, hidden information on every new notebook. And also for some existing notebooks.

The information should not be affected by other tasks. And it should be easy to change when desired.

One possible method is...

AbsoluteOptions[EvaluationNotebook[]]

shows many many options. Some of these options are likely to be of low importance and rarely used. I thought about changing the value of one of these options.

From an aesthetic standpoint, I don't want that information to be visible(to eyes).

What do you think is the standard ?

After getting comments (a solution):

If you want to put some information of working notebook, you can do like following :

SetOptions[EvaluationNotebook[], 
 TaggingRules -> <|"NotebookPlace" -> "MyPC", 
   "NotebookYear" -> "2024", "NotebookMonth" -> "Feb"|>]

To retrieve the information for example, "NotebookYear", you can

Options[EvaluationNotebook[], TaggingRules][[1, 2, "NotebookYear"]]

As can be expected with common sense, SetOptions+TaggingRules -> overwrites value(right term), if key(left term) with same name already exists.

$\endgroup$
6
  • 4
    $\begingroup$ What is the purpose? $\endgroup$
    – lericr
    Feb 7 at 23:28
  • 3
    $\begingroup$ TaggingRules? $\endgroup$
    – Lukas Lang
    Feb 7 at 23:41
  • $\begingroup$ Discretely encode information using the least significant bit of decimal constants in the notebook? $\endgroup$
    – Bill
    Feb 8 at 0:02
  • 1
    $\begingroup$ TaggingRules is the way. $\endgroup$
    – ihojnicki
    Feb 8 at 11:53
  • $\begingroup$ I want to make a new notebook and load content of already saved notebook. Then I want to put brief information of loaded notebook. $\endgroup$
    – imida k
    Feb 9 at 1:44

1 Answer 1

3
$\begingroup$

You can use CellTags. The following sets tag of the first cell in notebook:

SetOptions[First@Cells[], CellTags -> "Top secret information"]

To get the value from the tag:

Options[First@Cells[], CellTags]

{CellTags -> "Top secret information"}

But be aware that SetOptions[EvaluationNotebook[], ShowCellTags -> True] will make the tags visible. Default value is however False.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you, but I think TaggingRules is the gold standard. Because even if all the content of the notebook is erased, the information still remains in the notebook. We can bind information to notebook itself using TaggingRules. $\endgroup$
    – imida k
    Feb 9 at 1:46

Your Answer

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

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