Tag Info

Hot answers tagged

10

"Style" /. Developer`CellInformation[nb] where nb is the NotebookObject for the notebook you care about. Since you could have multiple cells selected, this will always return a list. It's also possible to have no cells selected, in which case CellInformation will return $Failed and the above code would throw an error.


10

I think I found it but I'd be more than happy to look at other alternatives if any provided: Shift + Ctrl + O to open Options > Notebook options > Evaluation options > Global preferences from the drop down menu at the top Change InitializationCellEvaluation to True and InitializationCellWarning to False The next time the .nb file is launched, the ...


10

You are inventing your own grouping types. If you open the Options Inspector and go to Cell Options -> General Properties -> CellGroupingRules the drop-down shows several options available: "NormalGrouping", "TitleGrouping", "SectionGrouping", "InputGrouping", "OutputGrouping", "GraphicsGrouping", "GroupTogetherGrouping", and "GroupTogetherNestedGrouping". ...


8

In the course of researching this question, I discovered an answer. Looking at the Option Inspector -> Cell Options -> General Properties for each of the cells shown above, reveals the option: CellGroupingRules. Unfortunately, there is little in terms of documentation for this option. Upon inspection, CellGroupingRules has the value of {"TitleGrouping", ...


6

If applying a new stylesheet doesn't change the appearance then it looks like the styling is local to each cell. If you have a look at the underlying expression of some of these input cells by going to the menu and choosing Cell > Show Expression you should see some StyleBoxes, as per this example using your code that you have supplied: So if it is the ...


5

Does this work as you wish? CreatePalette@Button["Evaluate down", With[{nb = InputNotebook[]}, SelectionMove[nb, Previous, Cell]; With[{prevCell = SelectedCells[nb] /. {c_} :> c}, Function[cell, SelectionMove[cell, All, Cell]; SelectionEvaluateCreateCell@nb ]~Scan~ Intersection[ ...


5

Now, with v9, I can undelete this answer :) You could set a context dependent on a certain counter value. Add to your stylesheet, to the "Input" style, the following option CellContext:>"Section"<>ToString@CurrentValue[{"CounterValue", "Section"}]<>"`" and in my few tests you get a context dependent on the last section number. It can ...


4

I could only get the kind of behavior you seek with an EventHandler and PassDownEvents -> True, in this case ClickPane. Manually Below is the ClickPane. We're going to replace "HL" manually by a Hyperlink later. First execute this and we'll paster the output later into the desired cell. I will use a "Section" cell for illustration; hence the style ...


3

Instead of Print one could use CellPrint with ExpressionCell and get the desired behavior (intermediate cells are collapsed by hands): Do[CellPrint@ ExpressionCell[ FindRoot[x^a - 2, {x, 1}, EvaluationMonitor :> Print["x = ", x, ", x^", a, " - 2 = ", x^a - 2]], "Output"], {a, 1, 3}]


3

Another quick(?) and dirty way: Let nb be the notebook to be printed. E.g., execute nb = EvaluationNotebook[] in the notebook you would like. Then execute NotebookPrint[NotebookGet@nb /. CellGroupData[data_, Closed] :> CellGroupData[data, Open]] or Export["/tmp/foo.pdf", NotebookGet@nb /. CellGroupData[data_, Closed] :> CellGroupData[data, ...


3

Here are two cells with weird embedded styles, including colors, background colors, and sizes: Select both cells and press Shift+Ctrl+N to re-parse to StandardForm:


3

The link that @rm -rf provides does most of what you have asked for. For the final part of your question Actually, ideally what I'd like to do, is say: Export all cells except the Input and Code cells. i.e. selective Export by types of cells. Evaluate this code -- which you can modify for your particular circumstances -- in your notebook. tmp = ...


2

One possibility would be to (programmatically) add dynamic options to all cells. E.g., one cell could look like : Cell["1-1", "Input", Evaluatable->Dynamic[eval], CellOpen->Dynamic[open], Background->Dynamic[bcolor]] Then, if you evaluate in a subsequenc cell (or by Button) this: eval = True; open = True; bcolor = LightGray the Cell becomes ...


2

CellContext seems to work on the notebook level, although its a Cell option. Anyway the behavior seems to be hardcoded to Mathematica and I wasn't able to see any indication inside the notebook apart from the option. But you can emulate the behavior using the command Begin. For example at the start of each Subsection you can run the command ...


2

To make it work, you have to set the option CellGrouping -> Manual either for the target notebook, or globally in the Option Inspector (Ctrl+Shift+O). Then the following code works as expected: nb = CreateDocument[{}, CellGrouping -> Manual]; SelectionMove[EvaluationNotebook[], All, Notebook]; NotebookWrite[nb, NotebookRead[EvaluationNotebook[]]];


2

Here is the code that should be added to KeyEventTranslations.tr. To learn more about editing this, and similar, system files look at this question and its related. (* Command, d - deletes the current cell (or selected set of cells) and its (or their) related group(s) if the group has exactly 1 Input cell; otherwise deletes only the cell from ...


1

You can select parent cell group of currently selected object in notebook nb with SelectionMove[nb, All, CellGroup] and then open it using FrontEndTokenExecute[nb, "SelectionOpenAllGroups"]. To open all groups containing currently selected cell you can use something like this: FixedPoint[ ( SelectionMove[nb, All, CellGroup]; ...


1

yes, but a notebook has a more involved structure than the .m files you have investigated. The code to do what you want isn't very complicated, though: CreateDocument[{CellGroup[{ TextCell["section", "Section"], TextCell["content", "Text"] }, Closed]}]


1

By long toing and froing I came butt against the answer. Here you are: Open the notebook prepared for the slide show. Assume its name is mySlideShow.nb. In the Slide Show palette press the "Start Presentation" button. The notebook will come into the Slide Show mode. Go to Menu/Format/Option Inspector. 2a. From the drop down menu of the "Selection" field ...


1

SetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{Cell[StyleData[StyleDefinitions -> "XXXXXX.nb"]], Cell[StyleData[All, "Working"], ShowGroupOpener -> True],Cell[ StyleData[All, "Presentation"], ShowGroupOpener -> True]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"] ] where "XXXXX.nb" is the name of ...


1

I should mention that I eventually resolved this confusion. Fultz's answer (referenced above) said Separate the examples into cell groups. You can use, e.g., Section or Subsection cells to do this I was thinking of cell groups merely as any cells joined by the brackets on the right-side of the screen, and I was manually adjusting the grouping. This ...



Only top voted, non community-wiki answers of a minimum length are eligible