Tag Info

Hot answers tagged

15

My other answer is a nice solution for interactively looking at boxes, but in the comments, Mr.Wizard seems to be indicating that he's more interested in programmatic usage, and that he's definitely interested in seeing the box form after the FE has stripped non-semantic boxes to send to the kernel. So here's a totally different method for doing this which ...


10

Here's some code which produces an InputField and the box form of anything you type into the InputField as you type it: DynamicModule[{boxes = ""}, Column[{InputField[Dynamic[boxes], Boxes, ContinuousAction -> True], Dynamic[boxes, BaseStyle -> {ShowStringCharacters -> True}]}]] The critical idea here is using a Boxes style InputField to ...


9

My colleague John Fultz suggested the following answer. f /: MakeBoxes[dat : f[args_], fmt_] := TagBox[ToBoxes[Rasterize@RandomImage[1, {100, 100}]], InterpretTemplate[f[args] &], Editable -> False, Selectable -> True, SelectWithContents -> True, Tooltip -> "tooltip"] After a bit of exploring I realized that I should have checked ...


8

You can place your desired output in a Row and then put it into DisplayForm. Manipulate[ Switch[testStatChoice, 1, testText1], {{testStatChoice, 1, "Select Calculation"}, {1 -> "1: First Calculation Example"}, ControlType -> PopupMenu}, Initialization :> {testText1 := Row[{SuperscriptBox["R", "*"]// TraditionalForm, " = ", "Rate of star ...


8

The problem here is independent of Manipulate or Dynamic. It is about how to display a Cell object without using a CellPrint statement. testText1 in itself is always displayed as Cell[...]. Therefore I suggest reconstructing the expression as something else, not wrapped in Cell. testText1 := TraditionalForm@Row[{Superscript[R, "*"], " = Rate of star ...


8

This is a nice exercise on boxing: MakeBoxes[u[v_[r_[b_]]], TraditionalForm] := Module[{b1, b2, b3, t}, t = ToBoxes[#, TraditionalForm] &; {bl1, bl2, bl3} = StyleBox[#1, #2] & @@@ { {"{", {20, Orange}}, {"[", {15, Purple}}, {"(", {12, Blue}}}; {br1, br2, br3} = {bl1, bl2, bl3} /. {"[" -> "]", "{" -> "}", "(" -> ")"}; ...


7

tokenize[str_] := Module[{exp, nb = CreateDocument[{ExpressionCell@ InputForm@MakeExpression[str, StandardForm]}, Visible -> False]}, SelectionMove[nb, Next, Cell]; exp = Flatten[ NotebookRead[nb][[1, 1]] /. {RowBox -> List, i_String /; StringMatchQ[i, Whitespace ..] :> Sequence[]}]; NotebookClose[nb]; exp[[3 ...


6

Why not use ToBoxes (or MakeBoxes) to construct boxes, instead of doing it yourself? DisplayForm[ ToBoxes[Row[List[0, 1, Superscript[2, 3], Superscript[1, 2], a]]]]


6

The simple answer is, if you want a string converted to StandardForm, you could wrap BoxData around it. E.g., CellPrint[Cell[BoxData["myFunction::usage=\"myFunction does ...\";"], "Input"]] But, in general, I wouldn't structure this as a question of CellPrint vs. FrontEnd`CellPrint. FrontEnd`CellPrint is undocumented, and therefore there is no contract ...


5

Interesting question. I don't have much experience with this sort of thing so I imagine there is a better way but this is what I could hack together at the moment: frac[lst_List] := Column[ Column /@ Partition[Riffle[lst, \[HorizontalLine]], 2, 2, -1, {}], Alignment -> Center, Spacings -> 0] {"x", 200, Integrate[Sin[x^2], x]} // frac Here ...


4

Not an answer since I could not find where it is documented (but I did not spend much time searching) But just to show that they are really same thing, which I did not know this myself as I do not really use subscripts as they do not work nicely across function calls. But this shows that $x_{[[1]]}$ is really the same as $x[[1]]$ , it is just different ...


3

I'm not sure this answers You won't get this to work with a text cell. Your CellEvaluationFunction already receives a parsed string. If you use an inline text cell you can get it to work CellPrint@ Cell[BoxData@Cell@TextData["őúű"], "Program", Evaluatable -> True, CellGroupingRules -> "InputGrouping", CellEvaluationFunction :> (#[[1, 1]] ...


3

Not quite tested embeddedNotebookForm /: MakeBoxes[embeddedNotebookForm[nb : Notebook[cells_List, ___]], StandardForm] := MakeBoxes@ DocumentNotebook[{TextCell@"tag"}] /. {{{Cell["tag"]}} :> Block[{}, List /@ cells /; True], _Notebook | _DocumentNotebook :> nb} So you would do Notebook[...]//embeddedNotebookForm


3

One approach that may be familiar to more experienced users is based on the input syntax described in String Representation of Boxes. \(input\)             raw boxes This appears to work but closer inspection shows that it is not exact: "\({1*^4, 000123, a*b c}\)" // ToExpression ...


3

The reason that MakeExpression has any FormatValues at all is because there's one defined in GetFEKernelInit.tr for some experimental functionality (which we probably ought to clean up in a future release). The fact that it's experimental also led to our not fully implementing the error-handling cases of typesetting, which is the source cause of the pink ...


2

I thought it might have to do with reserving space for an invisible plus sign. In that case wrapping the 1 in NumberForm would get rid of this nagging space (adding an explicit NumberSigns isn't necessary as NumberForm already has the correct default value for this option). DisplayForm[RowBox[List[0, NumberForm[1], Superscript[2, 3], Superscript[1, 2], a]]] ...


2

Michael Pilat has stated that you cannot create your own compound operators. You may find some utility in these posts: Prefix operator with low precedence How can one define an infix operator with an arbitrary unicode character?


2

Are you interested only in the case of "less than" and "greater than" symbols? Might other variations serve the purpose? The following parentheses are represented like "<>" (they are represented without using RowBox), regardless of the order of the characters:


1

I don't know if it will be possible to produce the Cell dingbat et al, as those don't appear on inline cells. However, you can at least get the formatting of your Cell expression by preventing it from being converted to Box form (doubly, making it inert). Here is a practical example: myPrintTemp[expr_Cell] := Internal`InheritedBlock[{MakeBoxes}, ...


1

This, with a suitable transform function to traverse the tree, would be an adequate tokenizer: TreeForm[Hold[ Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 4]]]]



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