# Tag Info

18

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 ...

11

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 ...

10

This took some digging but at least in Version 7 the FrontEnd command is FT, e.g.: FEFT["Plot"] You can read the definition with Definition[FEFT]. If you want the only Box form itself we can modify it accordingly (here for version 7): templateCell[name_String] := Module[{template}, If[! StringQ@ToExpression[name <> "::usage"], ...

9

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} /. {"[" -> "]", "{" -> "}", "(" -> ")"}; ...

8

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

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. FrontEndCellPrint. FrontEndCellPrint is undocumented, and therefore there is no contract ...

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

Not quite tested embeddedNotebookForm/: MakeBoxes[embeddedNotebookForm[nb:Notebook[cells_List,___]],StandardForm]:= MakeBoxes@DocumentNotebook[{TextCell@"tag"}]/.{ {{Cell["tag"]}}:>Block[{},List/@ Replace[cells, Cell[CellGroupData[{cs__Cell},_]]:>cs, {1}] /;True], ...

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]]]]

5

Perhaps it's not obvious because this doesn't look like a box. But the way that DocumentNotebook, et al, get translated into Notebook is by going through MakeBoxes. Which means that RawBoxes saves the day by preserving its guts in MakeBoxes: DocumentNotebook@{TextCell["Hello world!", "Section"], RawBoxes@cell, TextCell["The solution is:", "Text"]}

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 ...

5

When I see this right, then the evil function is TraditionalFormDumpordplus. This seems to change the order. The arguments can be extracted from a Trace TraditionalForm[a + b]; (* Dummy call *) TraditionalFormDumpordplus[{{"+", "b"}, {"+", "a"}}, {}] (* {2,1} *) If we change this to give a sorted list, then your arguments are not reordered ...

4

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 ...

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 ...

4

David Carlisle wrote about it back in 2007. The process seems to be rather cumbersome and I have not checked myself if it is reliable working but here are some links that might help you on your specific problem: XHTML and MathML from Office 2007 Going Wordless at the Advanced Mathematica Summer School

4

I believe it is not a restriction, but this comes with the way how Mathematica formats derivatives. That being said, the same way you cannot use 3 superscript primes to input a third derivative, you won't see 3 primes in the output either. D[f[x], x, x, x] gives If you could type this as input, then you would have a way to specify your third ...

4

Here is how you attack this: First click on the little "+" in the right upper corner. Then you select either "Subpod content" or directly "Formula data". Both will result in a more specific request which gives you the hint you need: {WolframAlpha[ "6.38905609893065", {{"PossibleClosedForm", 1}, "FormulaData"}], WolframAlpha[ "6.38905609893065", ...

3

If you look at the internal expression of the cell containing the image, you'll find that it also uses the compressed form. However, the usual trick of Cell@BoxData@ToBoxes... doesn't seem to work here, as that only gives us the RawArray representation. This gives us a hint at a possible way of retrieving the compressed representation without having to build ...

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

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:

2

Another solution involves messing with the box structure directly. This is just a basic example but GridBox accepts as argument cells of the form {{cell}..}. In fact this is what DocumentNotebook actually outputs Cells inside of a GridBox. Column and Row both use GridBox internally also. A simple example would be. CellPrint@Cell[BoxData[ GridBox[{{ ...

2

I hate situations when MMA is forcing me to create such inelegant solutions. It is how I am dealing with it: The basic idea is to govern the margins by outerFrame FrameMargins. One good thing here is FrameMargins: specifies the absolute margins in printer's points to leave inside the frame With[{ outerFrame = Sequence[Alignment -> Center, ...

2

If you are willing to enter your code as a String you can use this function: parseStringRaw[s_String] := FrontEndExecute @ UndocumentedTestFEParserPacket[s, False] Now: Note that the " characters were entered last; if you enter them earlier the auto-indenting will not be the same and neither will the output. Alternatively you could manually paste ...

2

halirutan gave a very nice explanation why this only happens in TraditionalForm and not in StandardForm. For completeness I will add the workaround that Rojo mentioned: Associate the definition to x and not to MakeBoxes using UpSet: MakeBoxes[x, form_] ^= RowBox[{"b", "+", "a"}]; Association with TraditionalForm also works: Unprotect[TraditionalForm]; ...

1

Here is a literal answer to your question in which I just insert the "spaces" code as a String: CellPrint@Cell[BoxData@MakeBoxes[f["\n" y "\n"]], "Output"] This may not be what you need, but I thought it may be worth mentioning. Edit Another simple-minded idea is to define the new-line output for a specific function, say f, as follows: f /: ...

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