We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

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


3

Answering the title question, when creating boxes, everything should be a *Box object or a string (or possibly a list). Inside of a box object, excluding options, again, everything should be a *Box object or a string (or list). There is one exception to this rule. It is ok to use integers instead of the corresponding strings. I'm not sure why this exception ...


3

Pardon me if I miss the point, as this looks rather complicated but I'm only giving it a quick look-over. Does it work to move your first If expression inside the Dynamic as follows? holdIF[Dynamic[var_], Dynamic[boxes_]] := DynamicModule[{updateFunction}, InputField[ Dynamic[If[boxes === Null, boxes = ToBoxes[SetPrecision[var, 5]]]; boxes, {...


3

Thanks to jkuczm for an idea: https://mathematica.stackexchange.com/a/159407/5478: MakeBoxes[ActuarialSurvivalProbability[x_, t_], StandardForm] := With[{row = Table[Slot[i], {i, 2, Length[x] + 1}]} (*Key point, row of slots generated*), TemplateBox[ Prepend[MakeBoxes /@ Unevaluated@x, MakeBoxes[t]] , "ActuarialSurvivalProbability", ...


3

If you really want to be able to enter multivariate derivatives as they appear in StandardForm, you could define a MakeExpression rule to do so: MakeExpression[ SuperscriptBox[s_, RowBox[{"(", d:RowBox[{_, ",", __}], ")"}]], StandardForm ] := MakeExpression[ RowBox[{RowBox[{"Derivative", "[", d, "]"}],"[",s,"]"}], StandardForm ] Then, entering:...


2

I think you can just use a TemplateBox to fix this. Change: TagBox["⟶",Identity,SyntaxForm->"\[Equal]"] to: TemplateBox[{}, "Reaction", DisplayFunction->("⟶"&), SyntaxForm->"\[Equal]"] You can also use a TagBox. The problem you are encountering is that the options order gets canonicalized, and doesn't match the order you are expecting. Using:...


2

The simplest possibility is to just accept the fact that Mathematica parses SubsuperscriptBox["C", "60", "*"] as SuperStar[Subscript[C, 60]] and use: AssignLabel[SuperStar[Subscript[b_, s_]], sym_Symbol] := Notation[ DoubleLongLeftRightArrow[ ParsedBoxWrapper @ SubsuperscriptBox[MakeBoxes[b], MakeBoxes[s], "*"], ParsedBoxWrapper @ ...


2

You can use TemplateSlotSequence for variable length TemplateBox arguments: MakeBoxes[ActuarialSurvivalProbability[x_, t_], StandardForm] := TemplateBox[ Prepend[MakeBoxes[t]] @ BoxForm`ListMakeBoxes[x, StandardForm], "ActuarialSurvivalProbability", InterpretationFunction -> ( RowBox[{ "ActuarialSurvivalProbability", ...


2

You can use InfinitePlane without having to get the PlotRange of input plot: Show[ListPointPlot3D[points, BoxRatios -> 1], Graphics3D[{Opacity[0], EdgeForm[{Blue, Thick}], InfinitePlane[{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}}]}]] Update: An alternative that also works in version 9 is to use FaceGrids: facegrids = {#, {{}, {0}}} & /@ Join[#, -#] &...


2

You can use the useful-but-undocumented function Charting`get3DPlotRange to find the plot range, and use that to make your box: points = RandomReal[{-50, 50}, {100, 3}]; plot = ListPointPlot3D[points, BoxRatios -> 1]; {x, y, z} = Charting`get3DPlotRange @ plot; Show[plot, Graphics3D[ { EdgeForm @ Blue, FaceForm @ ...


2

MakeExpression needs to return a HoldComplete object. So, the following might do what you want: MakeExpression[TemplateBox[{boxes_}, "RawBoxes", ___], StandardForm] := HoldComplete[boxes] For example: CellPrint @ Cell[ BoxData @ TemplateBox[ {RowBox[{"0", "+", "1"}]}, "RawBoxes", DisplayFunction->(#&) ], "Input" ]...


1

You can try Solve[Thread[list2 == Prepend[ConstantArray[0, Length[list2] - 1], 1]], list1]


1

Replace boxes = SubscriptBox[x, y] with SubscriptBox[ToBoxes@x, ToBoxes@y]: ClearAll[foo] foo /: MakeBoxes[c : foo[x_, y_], form : (StandardForm | TraditionalForm)] := With[{boxes = SubscriptBox[ToBoxes @ x, ToBoxes @ y]}, InterpretationBox[boxes, c]] Examples: foo[2, 3] Subscript[2, 3] foo[2, 3] Subscript[2, x] foo[{a, b}, {1, 2, 3}] ...


1

You can use RawBoxes to render a Cell object: PrintTemporary[RawBoxes @ cell]; Pause[2]


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