# Latex in code blocks

Right now, Latex only works in normal text. However, many of Mathematica's symbols can be generated using Latex, especially the part that makes it more readable in the frontend, for example superscript notation. I understand that this makes the code non-copy-paste-able, but I think the benefit for short conceptual code pastes is larger than the possibility of having non-copyable answers. (Also consider that the latter can be resolved by editing or leaving a comment.)

An example for this is this question: Difficulties in creating strict and robust equivalence between two symbols using the Notation package

Notation[ParsedBoxWrapper[\[Beta]]\[DoubleLongLeftRightArrow]ParsedBoxWrapper[beta]]

vs

$$\mathrm{Notation[\beta~\Leftrightarrow~beta]}$$

(Alright, Latex doesn't seem to work in meta, but you get the idea)

• Or you could use Unicode, which Mathematica can still parse: Notation[β ⟺ beta] – J. M.'s technical difficulties Jan 18 '12 at 16:31
• My DoubleLongLeftRightArrow button on the keyboard is a bit rusty I'm afraid. – David Jan 18 '12 at 16:33
• I don't remember the entirety of Unicode, so I did use a Character Map program for that last bit... – J. M.'s technical difficulties Jan 18 '12 at 16:38

While I understand why you're requesting this feature, I disagree with the request. Your block should either be understood as code or math, but it can't be both at the same time without confusing a good number of users. As a counter point to your example, consider:

With[{x$a = 1, y$b = 2}, {x$a, y$b}]


That is valid Mathematica syntax. Now you wouldn't want the engine to automatically display that as

would you? This is what would happen if this feature-request were to be implemented.

• That's more of a problem with the dollar tags than with my request. Something like [tex] inside code environments would do the trick. – David Jan 19 '12 at 2:17

The whole point of code blocks is that they're verbatim, kept as-is, without any processing.

When you're talking about Mathematica code, you want to have

Notation[ParsedBoxWrapper[\[Beta]]\[DoubleLongLeftRightArrow]ParsedBoxWrapper[beta]]


If you want to have

instead, you wouldn't put it in a code block.

I understand that this makes the code non-copy-paste-able, but I think the benefit for short conceptual code pastes is larger than the possibility of having non-copyable answers.

There is no such thing as a conceptual code paste; either it's code, or it's not. But even taking your argument as given, that must be one huge benefit you're getting for breaking everyone's expectation that code is verbatim and copyable.

• Yes: highlighting, the other reason to use code blocks. – David Jun 19 '12 at 14:09