Tag Info

Hot answers tagged

49

The first step would be to not think of Mathematica's notebook editor as a full-fledged editor, but rather as an interactive interface with the kernel that has some editing capabilities, perhaps at par with notepad. If you don't, you'll always be disappointed. The Mathematica editor: As with all editors, you'll have to grok the editor before you can be ...


25

Here's a rather unsophisticated approach. The code below creates a toolbar in the current notebook, with buttons to create, refresh and close a replica notebook. The replica is given a gray background and cannot be edited or evaluated. I tried to do something with Dynamic to automatically refresh the replica notebook, but without success. Update Here is a ...


19

One thing that we can do is exploit the CellEvaluationFunction option of cells to replace the standard evaluator with a function of our own design. In this case, that evaluation function will invoke the system shell. First, let's create a helper function that can create such cells: evaluatableCell[label_String, evaluationFunction_] := ( CellPrint[ ...


15

Double click the output cell instead EDIT: From murrays comment: tutorial/WorkingWithCells: "To specify which cells remain visible when the cell group is closed, select those cells and double-click to close the group."


11

You can create a palette to show/hide all the input cells in the selected notebook. CreatePalette[ Column[{ Button["Hide code", { NotebookFind[SelectedNotebook[], "Output", All, CellStyle]; FrontEndExecute[FrontEndToken[SelectedNotebook[], "SelectionCloseUnselectedCells"]] }], Button["Show code", ...


10

Yes, plain-text programming, as you call it, can be done in Mathematica. It is often used for developing packages (.m files). Try searching this site with the phrase "package development" to get more info. There is even a built-in working environment supporting package development. It has its own style sheet in which code-form cells (plain-text ...


8

I'm really keen to see the ideas of other people. Nevertheless, I want to show want I came up with. The approach I show here is hopefully general enough to be used in many situations, but I will use the aforementioned Dracula theme as example. What I took as basis for this approach was the background color of the editor window. Now I considered several ...


7

In the Option Inspector (CtrlShift O) look for AutoQuoteCharacters and set this on empty list. I presume you could set the same in the stylefile too.


4

This question is related to What are the advantages of using .nb rather than .m files? That question details some of the differences you will face in using a plaintext format. If you are merely seeking manual code formatting rather than having Mathematica reflow your input you can use the Code cell style, or a customized version (e.g. without being ...


4

I like to save my files in "plaintext" for 3 reasons: Can use SVN to have embedded version information, look at diffs from coauthors, etc. Don't mix the code itself with the output of the code, which also makes interacting with coauthors difficult and is unclear what has been run and what hasn't. Be able to run the files commandline on a cluster if ...


4

In the notebook you want to have the chapter be numbered other than 1, select the title cell (to which you have inserted automatic numbering for "Title", assuming your chapter titles are in cells of style "Title" -- otherwise change as needed). Go to the Options Inspector and search for CounterAssigments. Add {"Title", 1}, to the list to have the chapter ...


4

Try setting the option FractionBoxOptions, suboption MultilineFunction to None for the style, or globally.


4

I'll show you hoe to do it for a 3 x 3 matrix of values. You should be able to extend to 3 x 12 without much trouble First do some initialization. headers = {"Jan", "Feb", "Mar"}; rowLbls = {" ", "Tmax", "Tmed", "Tmin"}; valTbl = ConstantArray[0, {3, 3}]; Next build the spreadsheet. MapThread[Prepend, { Prepend[ ...


3

I have to do this all the time. I only have an annoyingly manual way to solve this. On a mac, Alt-click on the cell marker on the right for an InputCell containing the code, this should select ALL input cells. Then go to the Cell -> Cell Properties menu at the top and unselect the Open item. All the input cells should hide. On the right there should ...


3

If there's no way to colorize bracket nesting, is there a keyboard shortcut for "Check Balance" like shift-% in VIM for C-code? Yes, right from the help file: Check Balance     Shift+Ctrl+B


3

For the record, here are some platform-specific suggestions for enhancing keyboard use. If you're using Mac OS X, there are many ways you can customize your working environment, and if you spend all day at the keyboard you'll probably already be doing a lot of customizations. Although it's a good idea to master the techniques of individual applications, ...


3

In version 9: suppose nb is your notebook object (this can be nb=EvaluationNotebook[], but if you're going to be closing input cells you probably want to have an auxilary notebook a choose the correct notebook from Notebooks[]). Then, to close all the Input cells, for example, do cells = Cells[nb, CellStyle->"Input"] SetOptions[#, CellOpen -> False] ...


3

I did this for a little while, for mathematics lectures. It's faster than typing them in LaTeX, and very shortly you won't have trouble remembering the ctrl/alt/esc commands (which you should definitely learn). For the most part it's faster than writing. Two pieces of advice: 1) Audio record the lecture (it's polite to clear this with the lecturer ...


2

Very straightforward: plot = Plot[Sin[x], {x, 0, 2 Pi}]; plot /. (AxesLabel -> _) -> (AxesLabel -> {"x", "y"})


2

Options[EvaluationNotebook[], CommonDefaultFormatTypes] gives the default formatting: You can use Options Inspector to change the format type for Text from its default value TextForm to StandardForm: To change the setting programmatically for the evaluation notebook, you can use: SetOptions[EvaluationNotebook[], CommonDefaultFormatTypes -> ...


2

This is almost a solution: Module[{str}, checkPrevWord[char_] := ( SelectionMove[nb, Previous, Word]; SelectionMove[nb, All, Word]; str = StringJoin[ StringCases[NotebookRead[nb] /. StyleBox[a_, b___] :> a, RegularExpression["\\w"]]]; If[StringLength[str] =!= 0 && Length[DictionaryLookup[str, IgnoreCase -> ...


2

It is unfortunate that so few of the front-end internals are exposed through the front-end's API. Hopefully this will change in the near future as part of the front-end's evolution into a worthy competitor to LaTeX for producing scientific documents. Unfortunately the Wolfram team has a lot of work to do to match the quality of LaTeX's output, or even ...


2

Hi Denver and welcome to Mathematica.SE.I see that this is your first question here. Your description of the working of % and %n and their limitations is correct and unavoidable. I understand you are a novice MMA user so let me tell you how and when an experienced user uses % and %n. NEVER! ...Well almost never :-) In pre-Mathematica days people used to ...


2

There is no way you can avoid the In / Out number increase. Keep in mind that, even if Mathematica is not showing all the output is still keeping everything in memory. So if instead of using just % you use %n you programs will not break. EDIT: As an example: In[140]:= m = {{1,2},{3,4}} Out[140]= {{1,2},{3,4}} In[141]:= v= {x,y} Out[141]= {x,y} ...


2

Many (most?) code editors offer a check box labeled something like "Search in selected text only" (that's the wording used by the Find dialog of the OS X code editor BBEdit), Mathematica's Find dialog, unfortunately, does not support such an option. Until such time as this is rectified by the Mathematica developers, I think the work-around suggested by Sosi ...


2

You want all the basic stuff, the same stuff I do, but unfortunately it seems support here is pretty thin on the ground. Some others I've found: https://github.com/melton1968/math - seems to be a full attempt at a parser, which is amazing, but it doesn't appear to be functioning properly right now. As much as I'd like to deep dive on that, I don't have the ...


2

There is a style associated with this behavior, that you can disable by evaluating CurrentValue[$FrontEnd, {PrivateCellOptions, "EvaluationUnmatchedStyle"}] = {} To re-enable the behavior, set the value to Inherited: CurrentValue[$FrontEnd, {PrivateCellOptions, "EvaluationUnmatchedStyle"}] = Inherited


1

As far as I know, the answers are NO and NO. The front end does not support tabbed panes. It doesn't even support splitting a notebook window into two panes, which is something most code editors can do. The code editor for input cells is simply not line oriented. Select an input cell with some moderately complicated code, and type Ctrl+Shift+e. This will ...


1

Assuming you mean vim for vi, you could build a searchable index that may be an acceptable compromise. Suppose that you have a searchable convention that you use for marking each function. The obvious one to me is one where you precede each function with a usage, like foo::usage = "..." ; foo[ x_ ] = Module[{}, ... ] ; That would allow use of grep to ...


1

First select just the input cells. command-click will do this on OS X, but I don't know what the Windows equivalent is. Your selection should look like this Then, with the mouse cursor on one of the blue highlighted cell brackets, right click and select Merge Cells. This produces



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