Questions tagged [boxes]

Boxes are the underlying representation of two-dimensional forms in notebooks.

Filter by
Sorted by
Tagged with
37 votes
2 answers
3k views

How do I extract the contents of a selected cell as plain text?

My aim is to extract the contents of an Input cells as plain text. Ideally I would like to be able to select one or more Input cells and press a button which would then extract the text from these ...
Heike's user avatar
  • 35.8k
24 votes
3 answers
1k views

How can I get the unchanged Box form of an arbitrary expression?

One may observe that MakeBoxes does not give the actual Box form of various expressions: MakeBoxes[{1*^4, 000123, a*b c}] <...
Mr.Wizard's user avatar
  • 271k
22 votes
3 answers
819 views

Tokenize Mathematica input in a simple way

Background Usually, I give detailed descriptions when I have a question which sometimes lead to that users don't write their answers because they maybe think their answer is too simple. Therefore, I ...
halirutan's user avatar
  • 113k
22 votes
2 answers
639 views

Understanding evaluation and typesetting

Background So, one could be surprised by the fact that: Hold @ Grid[{{1, 2}}] (*or*) Hold @ Graphics @ Disk[] This issue and methods of prevention are ...
Kuba's user avatar
  • 137k
20 votes
0 answers
252 views

Inconsistent handling of Dynamic option values; intended, omission, or bug?

In answering Dynamic ClipPlanes calculated from current ViewPoint Kuba and I got into a brief exchange regarding how Option values wrapped in Dynamic should be ...
Mr.Wizard's user avatar
  • 271k
19 votes
3 answers
515 views

What are "\<" and "\>" delimiters in box expressions?

If I enter a string (say, "abc") in a cell, and then switch to box representation (Shift+Ctrl+E or menu item ...
Vladimir Reshetnikov's user avatar
18 votes
3 answers
348 views

How do I use the third and fourth arguments of Parenthesize?

Parenthesize seems to do a good job with constructing boxes that need to be appropriately parenthesized: ...
QuantumDot's user avatar
  • 19.6k
18 votes
3 answers
571 views

Notebook vs. DocumentNotebook; display a Notebook inline, like a DocumentNotebook

If you evaluate a DocumentNotebook[] expression in the front-end, it nicely displays inline, inside of an output cell in the current notebook: For my purposes, <...
Mechanical snail's user avatar
17 votes
1 answer
345 views

How to make version 12 print Root objects to screen normally as in earlier versions?

From clean kernel, when typing result = Reduce[2 d^2 == -((2*(1 + d) + ((4 d^3)/(1 - d)))*(d - 1)),d] Here what version 12 displays on the screen, compared to ...
Nasser's user avatar
  • 142k
17 votes
0 answers
189 views

Issue with undo after copying a string inside a string

Bug introduced in 10.0 and persisting through V11.3 Here's a small but annoying issue related to undo and copying of strings. Steps required to get the problem: Type ...
Kuba's user avatar
  • 137k
16 votes
2 answers
1k views

Backslash commands in strings?

I discovered by playing around that Text[DisplayForm@SubscriptBox["λ", "k"]] produces the same result as ...
Reb.Cabin's user avatar
  • 8,661
14 votes
1 answer
938 views

How to convert a notebook cell to a string retaining all formatting, colorization of identifiers etc?

I have an opened Mathematica notebook containing several cells. Suppose, I am interested in one of them -- it may contain a complete or incomplete expression (e.g. with syntax errors, highlighted ...
Vladimir Reshetnikov's user avatar
14 votes
1 answer
238 views

How to create a general AttachedCell toolbar?

For example, when an image is displayed in the frontend, the image suggestion toolbar, which is an AttachedCell, pops up: It can can be found here, among other ...
István Zachar's user avatar
13 votes
2 answers
1k views

How to embed an image into a string?

Note: The bug described in the post is in Mathematica 9, and has been fixed in 10.0. The documentation for String contains the following statements: Strings can ...
Vladimir Reshetnikov's user avatar
12 votes
6 answers
12k views

Notation of partial derivative

I want to write partial derivatives of functions with many arguments. Why is it that when I type f[x,y] ctrl+6 (0,1) it turns out to be bad syntax? The output of ...
yohbs's user avatar
  • 7,046
12 votes
2 answers
666 views

What are the differences between using MakeBoxes and Interpretation?

Say I want to define a custom graphical representation for my function foo. I can do this using MakeBoxes as in the following: <...
glS's user avatar
  • 7,593
12 votes
2 answers
321 views

ToExpression and ToBoxes aren't inverses of each other?

Applying ToExpression and ToBoxes repeatedly to Hold[1/1] gives many ...
Bruno Le Floch's user avatar
12 votes
1 answer
788 views

How to change the font color of a variable in whole input cell

I want to track the occurrence of a particular variable in a code. So the idea is to change its color. Usually I do it in a crude way - convert the code into text and then use ...
Sumit's user avatar
  • 15.9k
12 votes
1 answer
179 views

Strange behavior of UpSetDelayed together with MakeBoxes

In order to answer this question, I just stumbled into the world of UpValues. Though I managed to find a solution for the problem, I'm confused by my own code now 囧,...
xzczd's user avatar
  • 65.4k
11 votes
1 answer
225 views

Functions returns Command Completion Output

Is there a function that returns the output as if you invoked Command Completion. To help clarify I am looking for a function that returns the Cell Data as if you invoked ...
William's user avatar
  • 7,595
10 votes
1 answer
222 views

How to get string representation of boxes in v10.2?

In Mathematica versions up to 10.1 we could get string representation of given boxes by passing them to ToString with InputForm: ...
jkuczm's user avatar
  • 15.1k
10 votes
1 answer
130 views

How do I view the built-in definition of TemplateBox styles in terms of low level boxes?

The following: TemplateBox[{"a", "b"}, "Binomial"] // RawBoxes yields the correctly formatted (2d box structure) of Binomial[a,b]: $$\...
QuantumDot's user avatar
  • 19.6k
10 votes
2 answers
193 views

Are there any good tutorials on Boxes?

I am fairly competent in Mathematica, but I admit that I am baffled by Boxes, both making boxes and converting boxes back into expressions. I want to educate myself,...
Daniel W's user avatar
  • 3,406
10 votes
1 answer
554 views

How to convert arbitrary raw boxes directly into String?

This question is motivated by the recent question about searching inside of the NB files. According to the Documentation, ToString expects a high-level WL ...
Alexey Popkov's user avatar
10 votes
1 answer
213 views

How to defer creating/displaying boxes in front end until requested?

If the size of an output expression is larger than threshold ByteCount, the front end will display an abbreviated version of it by producing an ...
QuantumDot's user avatar
  • 19.6k
9 votes
1 answer
461 views

How to get a list of all expressions in a notebook matching a certain pattern?

Suppose I have a Mathematica notebook saved to a certain location on disk. Given a pattern I need to get the list of all expressions matching this pattern that appear in input, output or print cells ...
Vladimir Reshetnikov's user avatar
9 votes
3 answers
296 views

Why does MakeBoxes mess up RowBox ordering?

When I use RowBox for MakeBoxes the order of the elements is changed for TraditionalForm, if there is a plus (+) in the list of elements. ...
Friedrich's user avatar
  • 403
9 votes
1 answer
244 views

Is there a way to have a Tooltip for non-editable raster graphics produced by MakeBoxes?

I have a function which produces a large object I would like to hide. Formatting is of course an option but I'm hoping for something a little more meaningful using raster graphics and ...
Andy Ross's user avatar
  • 19.3k
9 votes
1 answer
160 views

On an existing notebook, how to transform all "double brackets" into "DoubleBracket"

Sometimes, having all double brackets [[...]] transformed into \\[LeftDoubleBracket] ... \\[RightDoubleBracket] can really ...
P. Fonseca's user avatar
  • 6,665
9 votes
1 answer
223 views

Ways to obtain a BoxObject

Is there any way to get a BoxObject, except with EvaluationBox or ParentBox? So usually one ...
Kuba's user avatar
  • 137k
9 votes
1 answer
299 views

Pasting TemplateBox with a Dynamic argument

Ok, this is pretty specific... The objective is to use a TemplateBox to format something that is programatically inserted with ...
Rojo's user avatar
  • 42.6k
8 votes
2 answers
99 views

MakeBoxes for Power not matching when inside Times?

If I try to define boxes for Power[x,-1] like this, MakeBoxes[Power[x, -1], TraditionalForm] := "matched"; it works as long ...
QuantumDot's user avatar
  • 19.6k
8 votes
2 answers
1k views

How to convert expression with Subscript to string

I've tried ToString[], but it doesn't work properly with subscripts: How to convert expr containing subscript to a string with ...
Stepan's user avatar
  • 155
8 votes
1 answer
699 views

How to change brackets in TraditionalForm output

I'm trying to improve TraditionalForm's output by using different brackets when there are more than one. For instance, instead of $u(v(r(b))))$, I'd like to get $u\{...
Pipe's user avatar
  • 1,099
8 votes
2 answers
220 views

Reading Cells or Boxes expression by expression

Let's say we have a cell: (*newline*) (*newline*) Plot[ x, {x, 0, 1} ] (*newline*) Plot[x, {x, 0, 2}] How to read it expression by expression? So e....
Kuba's user avatar
  • 137k
8 votes
1 answer
334 views

Converting string representation of boxes into explicit boxes [duplicate]

It is very easy and convenient to write textual labels as Strings in the WYSIWYG mode. For example, I define a short form describing a linear model: ...
Alexey Popkov's user avatar
8 votes
1 answer
2k views

How to extract a possible closed form from WolframAlpha[] output

To find a possible closed form of a number, I can use the function WolframAlpha["6.38905609893065", IncludePods -> "PossibleClosedForm"] It returns a result ...
Vladimir Reshetnikov's user avatar
8 votes
2 answers
232 views

How to open and explore the codes of the system Palettes files

The built in Palettes of Mathematica are simply .nb files which can be found in the following place: ...
Basheer Algohi's user avatar
8 votes
0 answers
126 views

What does the pair "\<" and "\>" in a string do? [duplicate]

What do \< and \> mean inside of a string? ...
QuantumDot's user avatar
  • 19.6k
7 votes
4 answers
542 views

Make a custom object look like MatrixForm of a matrix?

Let's say I have a custom object that I denote Obj[a,b,c,...] There are always n^2 entries in the object for some integer <...
Kagaratsch's user avatar
  • 11.9k
7 votes
2 answers
2k views

Formatted text in a Dynamic or Manipulate control

I am using a Manipulate control to show different calculations for the same user-specified parameters. I would like to show the results for the calculation the ...
BrianWaMc's user avatar
  • 177
7 votes
2 answers
283 views

How can you resize all the images in a notebook section?

I've pasted a large number of photos and they are too big which makes scrolling hard. Is there a way to automatically have Mathematica size them to 10% or something reasonable without have to click on ...
M.R.'s user avatar
  • 31.4k
7 votes
3 answers
300 views

How to avoid spaces between numbers when displaying TagBox(es)

The instruction : DisplayForm[RowBox[List[0,1,Superscript[2,3],Superscript[1,2],a]]] displays a gap between the first two items of the list but if one is careful ...
ogerard's user avatar
  • 957
7 votes
3 answers
417 views

How to extract the displayed name of an entity

Entities are typically displayed in their elided form: It's useful when exploring the output of EntityList to have access to the canonical name of the ...
Charlotte Hadley's user avatar
7 votes
1 answer
120 views

Why doesn't defined MakeBoxes display what is constructed in RHS?

Inspired by the @ybeltukov 's answer to this question, if I have the following polynomial poly = a^2 + (a^2 + b^2 - c^2)*x + b^2*x^2; var = x; this generates ...
QuantumDot's user avatar
  • 19.6k
7 votes
1 answer
459 views

Why only up to two \[Prime] superscripts are interpreted as derivatives?

I noticed that only up to two \[Prime] superscripts are interpreted as derivatives. Is there a reason for this restriction? Is it documented? ...
Vladimir Reshetnikov's user avatar
7 votes
2 answers
387 views

Prevent front-end from reformatting long fractions while editing

I am editing an expression containing wide fractions (typeset with fraction boxes): But if, while editing the equation, the fraction exceeds some threshold (seems to be approximately the window width)...
Mechanical snail's user avatar
7 votes
1 answer
86 views

How do I include additional kinds of boxes that are Tab-selectable

Observe that "PlaceHolder" and InputFieldBox are known by the FE to respond to pressing the Tab key: ...
QuantumDot's user avatar
  • 19.6k
7 votes
1 answer
208 views

Convert between string and expression representation of boxes

Boxes may be represented as expressions or as strings. How can I convert between the two forms? In particular, how can I convert from the string representation to the expression representation? ...
Szabolcs's user avatar
  • 234k
7 votes
1 answer
149 views

Quick way to preview and tweak styles?

I find the old stylesheet UI clunky and hard to use: FrontEndExecute @ FrontEndToken @ "EditStyleDefinitions" There's also the clunky style previewer as well: ...
M.R.'s user avatar
  • 31.4k