Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

according to the documentation at ref/InitializationCell,

When you first save a notebook that contains initialization cells, you have the option to make a parallel auto-generated .m package that contains only the contents of the initialization cells. The package is by default automatically updated whenever the initialization cells in the notebook are changed and saved again.

This would be a REALLY NICE feature, because it would give me a beautiful way to document a package in a notebook (instead of just textual code)!

To test it out, I took the documentation a bit literally and created a new notebook with a single initialization cell (with the little vertical-hook cell-bracket initialization-cell giveaway highlighted in yellow and circled in red in the screenshot, here:

enter image description here

The cell after the initialization cell is supposed to be just a reference to the initialization cell, and, when I evaluate the notebook, voila, there is the expected value.

However, when I now save the notebook, I don't get the advertised "option to make a parallel auto-generated .m package." Ok, so I make one manually (Save As.../Save As Type.../Mathematica Package .m), no problem, as follows:

enter image description here

But, of course, this one is not "automatically updated whenever the initialization cells in the notebook are changed and saved again." Here's the updated notebook:

enter image description here

but the .m file is not automatically updated. I would use this feature daily if I could get it to work. As always, I'll be very grateful for advice, guidance, clues.

share|improve this question

2 Answers 2

up vote 10 down vote accepted

This may be set from the Option Inspector (Format->Option Inspector) from this option:

enter image description here

Automatic automatically creates a package.

(to be clear, you need to select Global Preferences for this to apply to all your notebooks).

share|improve this answer
4  
I'd suggest setting it to Manual. If you set it to Automatic, it will automatically create the package every time. If you set it to Manual, it will explicitly ask whether the package should be created the first time the notebook is saved. If it is set to None, it will never create the package. –  Szabolcs Feb 5 '12 at 18:45

In case you do not want it to apply for all notebooks (which I prefer), you could put an additional line somewhere in your notebook:

SetOptions[InputNotebook[], AutoGeneratedPackage -> Automatic]

or

SetOptions[InputNotebook[], AutoGeneratedPackage -> Manual]
share|improve this answer
    
Hi Rolf. Do you know if it's ok to use this? I liked it a lot but the documentation says: "This function has not been fully integrated into the long-term Mathematica system, and is subject to change.". –  Murta Feb 24 '13 at 18:29
    
Hi Murta. Probably ok. There are only 279 such "not fully integrated" itmes. I doubt that those get ever really deleted. This gives you a list: nlt = FileNameTake /@ Select[ Select[FileNames["*.nb", $TopDirectory, 99], StringMatchQ[#, "*ReferencePages*"] &], FindList[#, "has not been fully integrated into the long-term"] =!= {} &]; –  Rolf Mertig Feb 24 '13 at 20:17
    
Nice way to scrap documentations. Tks! –  Murta Feb 24 '13 at 20:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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