# Tag Info

22

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\>"

17

You can use this to create a functionality which will fit your need the best. Here's how you can preview your input cell with c highlighted Red. CellPrint[ NotebookRead @ PreviousCell[] /. "c" -> InterpretationBox[ StyleBox["c", FontColor -> RGBColor[1, 0, 0]], c ] ] You can even evaluate such cell. General ...

17

Making the comments into an an answer as suggested. SetSystemOptions[ "TypesetOptions" -> "NumericalApproximationForms" -> False] will restore the legacy typesetting for Root and AlgebraicNumber. This command could be placed in the kernel's init.m file if you would like to be executed automatically every time. (The option inspector is for ...

16

Assignments to MakeBoxes and Format get special treatment. The definitions are stored as (under-documented) FormatValues: FormatValues[baseForm] // InputForm (* {HoldPattern[MakeBoxes[baseForm[a_, b_], fmt_]] :> ToBoxes[BaseForm[a, b]]} *) Note that if we omit InputForm from the expression above, then the system will attempt to apply the formatting ...

14

I believe this is the documentation you are looking for: String Representation of Boxes Notably: And:

14

It is well-documented! According to the Documentation page for StandardForm, StandardForm generates output that gives a unique and unambiguous representation of Wolfram Language expressions, suitable for use as input. » StandardForm is the standard format type used for both input and output of Wolfram Language expressions in notebooks. ...

13

I am a developer at Wolfram Research and I am trying to share some of the work I have been doing with parsing WL code. I have written a package for parsing WL code and retaining interesting metadata, such as file and line information. I also expose a tokenization function. The paclet is available on the public paclet server: In[1]:= PacletUpdate["AST","...

13

You can put it to the last cell and evaluate, it will resize all images from InputCells to the width of 100px. You can of course change affected cell set and output parameters. Do[ With[{nr = NotebookRead[cell]}, If[! FreeQ[nr, "ImageGraphics"], SelectionMove[cell, Cell, All]; NotebookWrite[ EvaluationNotebook[], nr /. g : ...

12

This was an intentional change. It is no longer possible to get "short form linear syntax", as we call it, from the kernel. Instead, the kernel now emits only "long form linear syntax" for StandardForm/TraditionalForm, and the boxes themselves do not do anything special for InputForm. This is the first step in what will be a multistep process to replace ...

11

The following functions will load the expressions and erroneous cells from a notebook: notebookExpressions[path_, pattern_:_] := Cases[Import[path, "Notebook"] // First , c:Cell[_, "Input"|"Output"|"Print", ___] :> Module[{v = eval[c]}, v /; MatchQ[v, _$Failed | Hold[pattern]]] , Infinity ] eval[cell_] := Quiet @ Check[ ToExpression[... 11 Thanks to andre's comment (where this link is provided), I now see the effect of those delimiters (I tested it in Mathematica 11 and also some earlier versions). When I add 2 newlines to the box representation of the cell: Cell[BoxData["\"\<a bc\>\""], "Input", CellChangeTimes->{{3.662918813714031*^9, 3.6629188530623317*^9}}] and switch back ... 11 An good explanation can be found an old mathgroup archive thread which I have reconstructed: When you create a typeset form for a function or operator, you must write a MakeBoxes definition for that function. For example, if you want Transpose[A] to have the typeset form$A^T$then you might, erroneously, write it this way: Transpose /: MakeBoxes[... 10 While I was working on alternative TeX export, I had similar requirement. I wanted to export annotated Mathematica code to TeX, with annotations reflecting FrontEnd's syntax highlighting. Since I couldn't find a way to use front end itself to do it, I decided to write my own package. My SyntaxAnnotations package is now available on GitHub. It works by ... 10 Summary of the all available information In the hoarier days space-like characters (spaces, newlines, tabs) inside strings were interpreted on input in an odd way: for example single newlines followed by spaces or tabs were converted to a single space. The \<\> syntax was introduced as a way to avoid this: between \< and \> the space-like ... 10 Question 1: What is the typesetting in Mathematica? What procedures does it include? I think that this 2008 year MathGroup post by John Fultz completely answers this question, so I'll cite it here: In version 6, the kernel has absolutely no involvement whatsoever in generating the rendered image. The steps taken in displaying a graphic in ... 9 Point of conversion A large and perhaps key difference is that MakeBoxes (foo) only transforms the expression into the expanded form when it is converted to Box form. It's FullForm remains unchanged. foo[1, 0.3] // InputForm foo[1, 0.3] This means that you can operate upon the expression in every standard way without thought to a hidden internal format.... 9 Assuming that you want to create a special display form for foo that can be used in all contexts, you should use neither of these solutions. Why? MakeBoxes controls how foo will be formatted. This is part of what you want. But the way you used it, the formatting is one-way. It will not be possible to convert the already formatted output as a foo ... 8 These are Operator Input Forms Characters that are not letters, letter‐like forms, or structural elements are treated by the Wolfram Language as operators. The Wolfram Language has built‐in rules for interpreting all operators. The functions to which these operators correspond may or may not, however, have built‐in evaluation or other rules. ... ... 8 You can check also the docs for PrecedenceForm for examples. Precedence can be used to force parenthesization. If you put a low-ish number, you will likely get a parenthesis. I am afraid I cannot help with the fourth argument (group). 8 As Kuba notices in the comment, undocumented FrontEndExportPacket allows conversion of a whole Notebook into plain text: nb = NotebookGet@EvaluationNotebook[]; First[FrontEndExecute[FrontEndExportPacket[nb, "PlainText"]]] "nb=NotebookGet@EvaluationNotebook[]; First[FrontEndExecute[FrontEnd`ExportPacket[nb,\"PlainText\"]]]" But it isn't the whole story. ... 8 I believe the existing rules for Times take precedence. (i.e. act first.) Perhaps a derivative of this can work for you: MakeBoxes[x_ /; ! FreeQ[Unevaluated@x, Power], TraditionalForm] := ToBoxes[Unevaluated[x] /. _Power -> "matched"]; Responding to your entirely valid performance concern please test these for comparison: MakeBoxes[x_Times /; ! ... 8 InterpretationBox will take care of making safe round trip from boxes to expression but we need to take extra care during condition checking and partition not to evaluate Obj's arguments. It does not matter that Obj is not holding them, Obj itself can be held. Hold @ Obj[1,2,3,4] etc. Edit to the old code As xzczd has noticed, an Input cell with e.g. Obj[... 8 expr = 3 - Sqrt[2]; Use ToNumberField to convert the expression to an AlgebraicNumber expr2 = expr // ToNumberField The short form display of the AlgebraicNumber is similar to that of Root RootReduce will convert the expression back to the radical representation. expr2 // RootReduce (* 3 - Sqrt[2] *) 7 how to convert a expression containing 2D format into corresponding string that retains the format programmatically? For example, how to convert {a^b + 1, 1.23*10^2, 2 Subscript[a, b]} (* Please Press Ctrl+Shift+N to convert it to standard form *) to {"\!$$\*SuperscriptBox[\(a$$, $$b$$]\)+1", "1.23\[Times]\!$$\*SuperscriptBox[\(10$$, $$2\$$... 7 Thank you for bringing this to our attention. I've done a preliminary investigation. On Unix only the kernel crashes, on Windows the FE crashes (or, more accurately, the FE crashes before the kernel has a chance to crash). Here are a few observations about the issue and your code. 1) You're mixing the Format world and the box world. If you want the kind ... 7 This answer may seem slightly off but it was posted before recent updates. The bottom line holds though. It symbolizes boxes, not expressions, it is not Subscript which is now special but SubscriptBox. You are supposed to use$x_1$in your code but if you can't use StandardForm/2d typesetting then you have to make a round trip to boxes and back to ... 7 This report finally found its way to me, and this is not a bug. I'm sorry support gave you incorrect information. This has nothing to do with the particular boxes involved, but rather with your use of the typeset generators Panel and Column. Most typeset generators, Graphics expression, and certain other symbols have "conditional text formatting rules". ... 7 This is what it looks like for me when I try to export the grid as HTML: These are just the first couple of errors. It goes on like that. On the other hand, ExportString[exp, "HTMLFragment"] seems to work. A solution could then be to do something like this: html = ExportString[exp, "HTMLFragment"] SystemOpen@Export[ FileNameJoin[{$TemporaryDirectory, "...

6

Generally speaking, that TagSetDelayed form is preferable, as the rule is attached to the myfuncF rather than to MakeBoxes. This means: Clear[f] will remove the FormatValues. The pattern is only matched against expressions which contain myfuncF rather than all expressions. The pattern won't compete against any other patterns attached to MakeBoxes (i.e, it'...

6

I'll provide an starting point for 2D case with single particle. Collisions with other particles are likely to be hard to model (or at least require adding an massive amount of WhenEvent rules if implemented this way), since NDSolve and WhenEvent tend to miss discrete events. Also, 3D case would be considerably more complicated to build; likely to take more ...

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