0

I can enter inline math with Ctrl+( in text cells, but saving this .wl file does not save the formatting. This can be seen by examining the source. How can I save this formatting?

(* ::Text:: *)
(*Math (a,b,c,d,e,f)*)

I am using Mathematica 12.1 Student Edition.

qwr
  • 413
  • 2
  • 11
  • Are you certain it's not saved? Try opening it up in Mathematica. A .wl//m file is intended for code, and is compatible with ordinary text editors, so the formatted cells are commented out, along with section headers, etc. The Mathematica front end can generally interpret and reconstruct those cells however. I just did a quick test on one of my packages and the formatted equation I wrote is there after I saved/closed/reopened. –  Oct 06 '23 at 02:05
  • The modified time for the file is updated, but none of the formatting is saved. I tested this by making some text inline math in the Mathematica frontend, saving, closing, and reopening. – qwr Oct 06 '23 at 02:08
  • I originally just tried entering an integral without limits and it did fine. When I added limits, (sub/superscripts), it breaks. So maybe the package editor doesn't fully support this after all and you just have to work with a .nb file to save formatted math. –  Oct 06 '23 at 02:55
  • I'm only trying to type variables and polynomials. What does the source code of inline math look like? – qwr Oct 06 '23 at 03:48
  • Does this address your question? 174172 – Kuba Oct 06 '23 at 04:37
  • No, I am not using any packages, but the built-in inline math formatting. – qwr Oct 06 '23 at 04:52
  • @qwr package == .m file in this topics, and .m is the same as .wl. So it is about using 2D typesetting in .wl files, which is what you are asking about, right? – Kuba Oct 06 '23 at 06:54
  • The answer Kuba linked to isn't confined to a particular package. His point is that 2-d typesetting isn't supported in .wl/.m files (effectively the same), but only in .nb files, which is what I commented on above. I also tried using inline TeX via ctrl-4; that doesn't work either. So there doesn't seem to be any way to do what you ask. –  Oct 06 '23 at 16:30
  • Ok. I didn't know inline math counted as typesetting. Do individual math cells work/ – qwr Oct 06 '23 at 17:26
  • What do you mean by "individual math cells"? Especially "individual"? What we're saying is that if you create a text cell in a .wl/.m file, and try to imbed math which contains super/sub scripts ("2d" expressions from the front end's point of view), this isn't supported. 1d - just typing in integral symbols and Greek letters - seems to work based on the small number of trials I performed. But that's not going to be enough to meet your needs. Package files (.wl/.m) are designed for writing code. And while they (sort of) support Greek letters, they don't support super/subscripts. –  Oct 06 '23 at 18:43
  • (Greek letters come out like [Alpha] after you save/reopen so I don't recommend using them for packages.) –  Oct 06 '23 at 18:46
  • I think my expressions are "1-D" and I can maybe get away with Unicode superscripts ² – qwr Oct 06 '23 at 19:35
  • individual meaning is there a cell style that displays as math? Ideally I'd be able to embed mathjax like Rmarkdown but I'm ok with just something distinct from text. – qwr Oct 06 '23 at 19:37
  • 1
    If you open up a .wl file, you'll notice that there is a single stylesheet available; all other choices are greyed out. Under Styles, you get a list of all available choices. There is an "inline math" choice, and a couple "display formula" choices - one numbers your formulas. If you enter a 2d expression, save/reopen, the equation is readable but is flattened out to 1d. I.e. x^2 + 3/(y + 2z) without superscripts/fraction boxes. But it is more legible than what you get entering inline stuff in a regular text cell. That's true for all 3 choices. –  Oct 07 '23 at 01:35

0 Answers0