Tag Info

Hot answers tagged

20

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


14

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


12

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


11

You can convert any expression to string by using ToString. If you want to preserve the visual representation, you should use ToString[(*your expression*), StandardForm]. logo = Import["http://wolfram.com/favicon.ico", "Image"] logostr = ToString[logo, StandardForm] StringJoin["Mathematica", logostr] % // StringQ Edit: By checking the cell expression ...


10

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


9

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


9

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


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

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


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


7

This is documented in Part >> More Information (Part >> Details in V9):


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

This is caused by the AutoMultiplicationSymbol option in the front end. SetOptions[$FrontEnd, AutoMultiplicationSymbol -> False] Will make the space disappear.


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

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


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

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


5

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


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

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


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

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


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

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

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

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

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


3

It seems that there are no special boxes for these symbols. One can, however, use standard operators of the box language and insert there symbols from the palette Menu/Palettes/Special Characters/Symbols such as integral or partial derivativederivative. Like this one finds: StyleBox[RowBox[{"\[Integral]", "y", "(", "x", ")", "\[DoubleStruckD]", "x"}], ...


3

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



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