# Tag Info

11

If the first appearance of the Symbol in the Notebook is the definition, or close enough to the definition to be convenient, you could use the following Palette button to find that first appearance for whatever token the cursor is within. With[{nb := SelectedNotebook[]}, DynamicModule[{token}, Button["Find First", SelectionMove[nb, All, Word]; ...

8

This syntax was deprecated in the version 6.0 era. According to the legacy documentation, For example, in version 5.2, the following strings are interpreted differently string1 = "first line second line" string2 = "\<first line second line\>"

8

This MathGroup discussion should answer your question, so I'll cite it here: On Tue, 29 May 2012 05:47:52 -0400 (EDT), JCW wrote: Please forgive my dragging up ancient history: I have been using Mathematica from version 2.2 through 7.0. I remember at least one (maybe two?) format conversions that were necessary to update old ...

8

that is what the third argument of ToExpression is for: ToExpression["\\sqrt{2.0}",TeXForm,HoldForm]

7

To whom it may concern, a workaround: path = FileNameJoin[{$HomeDirectory, "Desktop", "testWorking.nb"}]; nb = Notebook[{}, Saveable -> False, NotebookEventActions -> {{"MenuCommand", "Save"} :> {}} (*the fix*) ]; Export[path, nb, "NB"] 7 In case you want to plot in place you can use something like: Button["Plot", NotebookWrite[ InputNotebook[], ToBoxes @ Plot[ Evaluate @ ToExpression @ CurrentValue @ "SelectionData", {x, 0, 10} ] ] ] You may want to add Method -> "Queued" for more complicated plot to avoid timeout. And if you want x from ... 7 According to the documentation, "PasteButton, evaluates its arguments in an ordinary way, so that expr is immediately evaluated" It is like you evaluate Plot[\[SelectionPlaceholder], {x, 0, 10}] which will give empty plot. This could be one solution: PasteButton["Plot", Defer[Plot[\[SelectionPlaceholder], {x, 0, 10}]]] 6 LogLogPlot plots contain a dynamic objects which when you open the notebook, the security of Mathematica prevents the dynamic objects from being updated. Check this What you can do is wrap your plot with dynamic and when opened again and when you click Enable Dynamic, you will get the correct plot. Dynamic@Labeled[LogLogPlot[x, {x, 10^-5, 1}], "Test"] 6 You can't. This feature only works with certain programs and as of version 10.4 Mathematica is not one of them. Maybe the coming Mac front end improvement mentioned in this presentation will fix that, but this is purely a guess on my part. As a workaround you can use window control software such as Spectacle, which makes it easy to arrange notebooks in a ... 5 How about: Export[ StringDrop[path, -2] <> "txt", StringRiffle[ NotebookImport[path, "Input" -> "InputText"], "\n" ] ] 5 UPDATE As Kuba correctly notes in the comment, with negative CellMargins we can make the cell height to be effectively zero: CellPrint@Cell[BoxData["a"], CellElementSpacings -> {"CellMinHeight" -> 0, "ClosedCellHeight" -> 0}, Background -> Hue[.8], CellMargins -> -2, CellOpen -> False, CellFrame -> 0, ShowCellBracket -> ... 5 Similar approach to Mr.Wizard's but searching only code and input cells. Put that procedure inside joker.m file, as described in 72914 or as a procedure for Button in a Palette. Module[{name, nb}, nb = InputNotebook[]; Label["readName"]; name = NotebookRead[nb]; If[name === {}, FrontEndExecute@FrontEndToken[nb, "ExpandSelection"]; Goto["readName"] ... 4 There is a straightforward way to set CellMargins to be zero: DialogInput[ DialogNotebook[{ExpressionCell[Pane[RandomImage[], ImageMargins -> 8], CellMargins -> 0]}]] Instead of ImageMargins we can rely on CellFrameMargins: DialogInput[ DialogNotebook[{ExpressionCell[RandomImage[], CellMargins -> 0, CellFrameMargins -> 8, ... 4 You can get this behaviour by setting StucturedSelection to True at the Global, Notebook, or Cell level. See the Options for Expression Input and Output guide. This can be done with the Options Inspector or with SetOptions. To set it at the notebook level: SetOptions[EvaluationNotebook[], StructuredSelection -> True] After this is done you will only ... 4 The workaround suggested by Algohi works but it leads to reevaluation of the entire LogLogPlot each time you open a Notebook. The following workaround avoids this: With[{g = Labeled[LogLogPlot[x, {x, 10^-5, 1}], "Test"]}, Dynamic@g] Another workaround is to place this Graphics as Inset inside of another Graphics object: pl = LogLogPlot[x, {x, 10^-5, 1}]; ... 4 Here three approachs: 1. Using comments like (* metadata *) written as plain text directly in the notebook's file. Pros: Human readable. Simple to manage. Readable from other application. If in XML format, simply to validate against a DTD. Cons: Unpredictable behaviour (well, ... a behaviour that I can't understand): sometime I have seen comments, all of ... 3 You can execute the following inside the notebook SetOptions[EvaluationNotebook[], ShowCellLabel -> False] Alternatively, you can change the options of the desired notebook (testnb1.nb in the example below) by executing SetOptions[...] in a different notebook (untitled-3.nb in the example): Or, use the Option Inspector (in the Format Menu) to change ... 3 Here is a function came from this page setFont[fontFamily_, fontSize_] := With[ { styleNB = Notebook[{ Cell[StyleData[StyleDefinitions -> "Default.nb"]], Cell[StyleData["StandardForm"], FontFamily -> ToString[fontFamily], FontSize -> ToExpression[fontSize]]} ], styleSheetName = FileNameJoin[ ... 3 I gave up looking for neat solution. Here's brute force. Since the bottom CellMargins are not respected then let's not use any! :) We can use Pane and its ImageMargins to take control over padding. DialogInput[ DynamicModule[{}, Pane[RandomImage[], ImageMargins -> 8], Initialization :> (SetOptions[EvaluationCell[], CellMargins -> ... 3 You can use SetOptions directly on any Notebook like this: myNewCell = Cell@RawBoxes@ ToBoxes@Style["Title of talk, Conference, Location, Date", 22, Italic, FontColor -> Blue, FontFamily -> "Times"]; SetOptions[EvaluationNotebook[], DockedCells -> myNewCell] Since DockedCells are not editable but may still contain dynamics, this is ... 3 Just to give back to community, here's a little piece of code: Item[KeyEvent["e", Modifiers -> {Control}], FrontEndExecute @ Module[{nb, t}, nb = InputNotebook[]; SelectionMove[nb, All, Expression]; t = NotebookRead[SelectedNotebook[]]; NotebookWrite[nb, ButtonBox[RowBox[{"(", CounterBox["Section", t], ".", ... 3 It seems that sometimes Cells and friends are not smart enough to be aware of the parent notebook, supplying the code with EvaluationNotebook gives something working for me: Tooltip["TEST!", Dynamic @ Rasterize @ NotebookRead @ First @ Cells[ EvaluationNotebook[], CellTags -> "TestTag"] ] Is this what you are after? 3 Here's a slightly more limited approach, that doesn't require changing the stylesheet or environment of the notebook. The following styles are bulleted, with increasing levels of indentation: Subchapter Item Subitem Subsubitem Subchapter is usually accessible via a keyboard shortcut; check Format > Style for specifics. Item is automatically used as the ... 3 Instead of SelectionMove and NotebookSelection one can use NotebookRead[PreviousCell[]] and then cleanup the text returned by the ExportPacket. Thread @ MakeExpression[ "{" <> StringReplace[ First[FrontEndExecute[FrontEndExportPacket[NotebookRead[PreviousCell[]], "InputText"]]], {"\r\n " -> "", "\r\n" -> ","}] <> "}", ... 2 As noted by ilian, this behaviour is explained in StoringAndTrackingPaletteStates tutorial. Shortly, CurrentValue[$FrontEnd, SystemPalettesMenuSettings] keeps those values cached. In order to achieve what I described in the question we have to drop an entry that coresponds to our palette. It doesn't really matter when it's done. Just do it before you ...

2

It really expects that you have some buttons along the bottom. DialogInput[Column[{Pane @ RandomImage[], Button["OK", DialogReturn[0]]}]] but you can do it this way DialogInput[Column[{Pane @ RandomImage[], ""}]] Update I Think it looks better with the bottom margin a bit larger than the top, but if you are being picky about equal margins, try ...

2

InitializationGroup vs group of InitializationCells If you create a new cell in an InitializationGroup it will automatically become an InitializationCell. For the group of InitializationCells you will get a default one, which you can turn into another InitializationCell or not. A set of InitializationCells vs one InitializationCell. I can't find any ...

2

There is no reason to keep your Input inside of Manipulate, you don't want a dialog show up every time it updates, right? Probably you need something like this: ClearAll[f, x, \[Alpha]] f[x_, \[Alpha]_] = Input["Please input a function of x to plot with one parameter \ \[Alpha] to manipulate"]; Manipulate[Plot[f[x, \[Alpha]], {x, 0, 1}], {\[Alpha], 0, ...

2

This gives the recently opened files as a list of rules: Lookup[Options@$FrontEnd, NotebooksMenu] Just the file names: First /@ Lookup[Options@$FrontEnd, NotebooksMenu] FileNameJoin instead of FrontEndFileName: (only tested on windows) FileNameJoin[(Append @@ ((First@Last[#])[[;; 2]]))[[2 ;;]]] & /@ Lookup[Options@\$FrontEnd, NotebooksMenu]

2

Here is one approach (Mathematica version 10 is required). Paste the following code as the next cell after the cell with your image and evaluate: cell = NotebookRead[PreviousCell[]]; m = CurrentValue[Magnification] Cases[cell, GraphicsBox[__, OrderlessPatternSequence[ImageSize -> {w_, _}, ___, ImageSizeRaw -> {w0_, h0_}], ___] :> {m {w, ...

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