1
$\begingroup$

I want to protect generated inline cell (which contains TeX source) from attempts to edit, since any attempt to regenerate box structure will fail. In particular, suppose in a text cell one creates inline cell (with ctrl+9) in which, in turn, one tries to put some TeX formula (press ctrl + dollar sign). For example, try simple input a\w b . Since at the moment there are no command \w after you exit the input box you will see just a b. Now if your edit .../Mathematica/13.x.x/SystemFiles/IncludeFiles/TEXImport/latex.tnb file (make a reserve copy!) and append in the end of it the line (I inserted it between lines \input datetime.tnc and \makeatother of that file)

\def\w{\wedge}

and then once more enter and exit the inline cell, the content will be automatically reprocessed an nice a [Wedge] b structure will appear. Since I plan to share that notebook a user can accidentally enter the inline cell. After it exits the inline cell the output will be broken. How to protect from such an accident?

$\endgroup$
8
  • $\begingroup$ I wonder if the Editable attribute can be set to False for an inline cell. $\endgroup$ Commented Dec 8, 2023 at 13:35
  • $\begingroup$ @GustavoDelfino It can't be set (otherwise I would not ask for help), however, the inline cell contains other containers like FormBox. Also there might be some specific solution to prevent auto generation of content in texinput mechanism itself. At the moment I am not sure that solution is not possible. $\endgroup$
    – Acus
    Commented Dec 8, 2023 at 15:22
  • $\begingroup$ I just did small test by manually adding the option using "Show Expression" and it worked. However, I know that this is easier said than done for a large cell. $\endgroup$ Commented Dec 8, 2023 at 15:32
  • $\begingroup$ @GustavoDelfino For me it don't work. For example, take this: Cell[TextData[{ "\nThis ir text cell with tex inlined cell ", Cell[BoxData[ FormBox[ TemplateBox[<|"boxes" -> FormBox[ RowBox[{ StyleBox["a", "TI"], "+", StyleBox["b", "TI"], "+", StyleBox["s", "TI"]}], TraditionalForm], "errors" -> {}, "input" -> "a+b+s", "state" -> "Boxes"|>, "TeXAssistantTemplate"], TraditionalForm]], Editable->False] }], "Text"] Despite I set Editable->False to the inlined cell I can edit it. What is your example? $\endgroup$
    – Acus
    Commented Dec 8, 2023 at 15:46
  • $\begingroup$ The issue is with the Editable attribute not being respected for the boxes in your comment above. But it has nothing to do with subcells. Use CellPrint on you inner Cell and it remains editable. $\endgroup$ Commented Dec 8, 2023 at 18:01

1 Answer 1

1
$\begingroup$

This is not an answer. It is just too much code for a comment. The following code generates a cell, without any subcells. This cell has an Editable -> False option as well as the internal TemplateBox. Yet, the output is editable. Does anyone know why?

Cell[
    BoxData[
        FormBox[
            TemplateBox[
                <|
                    "boxes" -> FormBox[ 
                                  RowBox[
                                      {
                                          StyleBox["a", "TI"],
                                          "+",
                                          StyleBox["b", "TI"],
                                          "+",
                                          StyleBox["s", "TI"]
                                      }
                                  ],
                                  TraditionalForm
                              ],
                    "errors" -> {},
                    "input" -> "a+b+s",
                    "state" -> "Boxes"
                |>,
                "TeXAssistantTemplate",
                Editable -> False
            ],
            StandardForm
        ]
    ],
    Editable->False
 ] // CellPrint
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.