Message Boards Message Boards

0
|
3911 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Wolfram Language Package Notebook - Line Indenting Query

I've created a new Wolfram Language Package notebook from Mathematica V12.1.1 running on a Mac.

I want to set line indenting to a value of, say, 2 for expression formatting for the whole notebook. using the Option Inspector, this works on a cell by cell basis, but not for the selected notebook or globally.

Also, unlike ordinary notebooks, the "Edit Stylesheet" menu is disabled in package notebooks.

Is anyone able to give me a pointer as to how I can set line indenting for all code cells so I don't have to set the value individually for every single cell.

EDIT: I've just noticed that if I save and re-open the package notebook, my cell-by-cell indentations are forgotten.

Thanks in anticipation...

POSTED BY: Ian Williams
3 Replies

Hi Rohit, That's actually quite a neat trick. Thanks for the suggestion, I can see me using it. For packages I still prefer the package notebook, but haven't yet figured out how to control indenting. Perhaps such control features haven't yet been implemented. Thanks again, Ian

POSTED BY: Ian Williams

Thanks Rohit,

I'll take a look at what you suggested. But I quite like the functionality of the built-in package notebooks for writing smallish packages so would like to figure out how to get the code to indent as it does in standard notebooks. I guess there must be a way of doing this, but it's not obvious to me and I'm hoping that somebody out there has a straightforward solution.

All the best,

Ian

POSTED BY: Ian Williams
Posted 3 years ago

Hi Ian,

Not really an answer to your question, but may work for you.

I usually use a normal notebook to write the code that I want to put in a package. All cells are marked as Initialization cells and the first cell in the notebook is

SetOptions[InputNotebook[], AutoGeneratedPackage -> Automatic]

Whenever the notebook is saved, a package file is automatically created with the same name as the notebook but with a .m extension. I don't have to worry about indenting because I never work with the code in the .m file directly.

I can then Get the package in another notebook where I can use or test the functions in the package.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract