Questions tagged [boxes]

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

Filter by
Sorted by
Tagged with
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
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
19 votes
3 answers
514 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
22 votes
2 answers
636 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
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
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
10 votes
1 answer
553 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
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
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
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
12 votes
1 answer
785 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
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
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
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
6 votes
1 answer
280 views

TagBox + InterpretationBox vs ConvertTo/StandardForm

There appears to be a problem with a menu command Convert To / StandardForm (Crtl+Shift+N) with respect to InterpretationBox ...
Kuba's user avatar
  • 137k
6 votes
0 answers
364 views

How to prevent formatting as Mathematica code in inline cells?

We can start a new inline cell using Insert → Typesetting → Start Inline Cell. This is often used to insert mathematical formulae in text cells. Instead, I want to use it to insert small bits of non-...
Szabolcs's user avatar
  • 234k
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
14 votes
1 answer
936 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
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
7 votes
0 answers
172 views

Undocumented Backslash-LessThan operator in strings? [duplicate]

I'm aware of the backslash operators in strings, as in this SE answer, but I ran across a new one. I opened a new Styled Notebook ... in the front-end GUI, chose <...
Reb.Cabin's user avatar
  • 8,661
6 votes
2 answers
577 views

Symbolize Does Not Work in `.m` Files or What?

I have a .nb (notebook) file which I should convert to a .m (mathematica package) file to run it remotely from command line of a ...
Hosein Rahnama's user avatar
4 votes
2 answers
269 views

ToBoxes Respect Spaces Code

Is there a way to force either ToBoxes or MakeBoxes to respect the spacing that occurs in the code? For example is there a way ...
William's user avatar
  • 7,595
3 votes
2 answers
166 views

NotebookWrite in EvaluationBox forces Input CellStyle

There is a promissing new function EvaluationBox[] and a nice last example in documentation section for it: ...
Kuba's user avatar
  • 137k
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
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
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
12 votes
2 answers
664 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,583
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
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
9 votes
1 answer
222 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
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
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
8 votes
2 answers
219 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
697 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
7 votes
1 answer
219 views

Problem with conversion of UI controllers' boxes to expressions

Bug introduced in V10 and partially fixed in V11.1.1 TLDR Various of expressions which have fancy typeset form or are designed as UI elements won't survive ...
Kuba's user avatar
  • 137k
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
6 votes
1 answer
136 views

How to work with BoxOptions (ButtonBoxOptions, PanelBoxOptions, etc.)

The main question is in the title. Here are subtopics I'd like to focus on: Is there a tutorial related to them anywhere in documentation? How can I check what are current values of e.g. ...
Kuba's user avatar
  • 137k
6 votes
2 answers
298 views

How to build a TemplateBox with dynamic length GridBox?

I have created the following TemplateBox Rule. ...
user13892's user avatar
  • 9,255
6 votes
1 answer
151 views

To TagSet or not to TagSet when using MakeBoxes

What is the difference between the following two: ...
QuantumDot's user avatar
  • 19.6k
6 votes
2 answers
563 views

Customizing display of partial differential equations

I am manipulating partial differential equations symbolically, and would like to get the easily readable form $\rho \frac{\partial v}{\partial t}$, leaving variables implicit. Based on suggestions ...
Åsmund Hj's user avatar
5 votes
2 answers
191 views

How do I mimic the functionality of "<>"?

The Cell expression for: <> is Cell[BoxData["<>"], "Input"] However similar expressions are parsed into RowBox(...
Davorak's user avatar
  • 407
5 votes
2 answers
205 views

Removing spurious parenthesis in `TraditionalForm`

I don't understand the following behavior (in v 9.0.1) of TraditionalForm regarding insertion of parenthesis. Let us start with the a definition for ...
QuantumDot's user avatar
  • 19.6k
5 votes
1 answer
384 views

How to make some RowBox to be string

GeneralUtilities`GetUsages["System`Sin"] I want to get $\color{red}{\textbf{1}}$ plain string,but this function actually will give me some ...
yode's user avatar
  • 26.5k
5 votes
2 answers
168 views

Combination of CellPrint and PrintTemporary, or DisplayForm for Cells

I'm programmatically generating some formatted output that generates a cell in the form of a Cell[] expression. For instance, the output might be ...
Mechanical snail's user avatar
4 votes
1 answer
170 views

How to make TeXForm use TemplateBox to generate code?

If I define the TraditionalForm formatting of myFunction without TemplateBox, then ...
QuantumDot's user avatar
  • 19.6k
4 votes
1 answer
193 views

Unexpected result when reading Cell with comment-lines by NotebookRead

Bug introduced in 9.0 and fixed in 9.0.1 When considering this question about re-formatting Cell (also this one), I encountered an issue which confuses me. I'll ...
Silvia's user avatar
  • 27.5k
4 votes
2 answers
448 views

Using Symbolize to Convert Multiple Variables at Once

So, I have created a list of subscripted and overdotted variables that I would like to symbolize, so I run them through a for loop. Seems to me that this would work? Any help is appreciated. ...
MGoforth's user avatar
  • 125
3 votes
1 answer
229 views

Symbolized, Subscripted Variable Doesn't Look Pretty

Background I'm trying to programmatically generate a subscripted variable in a way that makes it appear "pretty". Here is a minimal working example that shows some strange behavior I'm ...
Sterling's user avatar
  • 543
2 votes
1 answer
42 views

Is it possible to make your own output format that uses the "Data not in notebook. Store now" mechanism?

Several functions in WL have a custom elided typesetting form that does not automatically embed large amounts of data into the notebook but presents you with the option to do so if you wish. ...
Sjoerd Smit's user avatar
  • 22.8k