Show HN: SugarTeX – readable LaTeX language extension and transcompiler to LaTeX
github.com
github.com
A comparison to UnicodeMath (which seems very similar and is an existing standard which already works in Latex) would also be useful.
I'm not sure about this whole concept of unicode. It is more readable for sure, but harder to write (to remember which unicode to use, and how to get it).
Perhaps surprisingly, java allows unicode identifiers etc, so I experimented with variables like δx and δt, and even ½i for PIC grids in CFG. It's cute, but I'm not really sure it's a good idea.
BTW what is that kind of completion called (i.e. where it doesn't just complete, but also replaces it with something else); and is something like that available for vim - or for rlwrap? (I searched, but "completion" brings up all the standard vim completion modes). EDIT vim has "abbreviations", but the no built-in automcomplete mode for them (though you could also put them in a file, and have completion scan that file - or write your own).
A "desugarTeX" could transform an existing latex doc into a unicode version, which could still be used as a source document, via sugarTeX. Arguably, this desugarTeX is kinda sorta like an output format of latex (like pdf or dvi), except that it's also machine readable as latex input.
I myself prefer type `\^:` to get vector superscript symbol, type `\^->` to get another vector superscript symbol. Type:.\rot`to get matrix superscript symbol. Type `\-->` to get long arrow.
But yes, type `\\` to get broken vertical bar that's a new newline symbol, type `\&` to get small sing below that later again converts to `&`.
Echoing the root of this thread, I think a tutorial would help, covering the simplest and most common features first (and the ones that work most neatly and elegantly). I'd suggest, for every example, have three parts, in the order a user would experience them:
1. user-entered shortcut e=mc\^2
2. unicode appearing e=mc²
3. an image of pdf
I'd omit the actual latex from this tute, because the user never actually sees it...SugarTeX completions is forked from latex-completions Atom package. I haven't seen something like this before.
BTW: `mc\^2` gives mc²
https://github.com/kiwi0fruit/sugartex/blob/master/sugartex....
I guess Unicode Math is a part of SugarTeX as every valid LaTeX is a valid SugarTeX (unless it has new SugarTeX meaning, otherwise it's a bug). Or maybe there's something I do not know about Unicode Math? I thought it simply replaces/treats some Unicode characters with LaTeX commands. So I used this feature and didn't bother replacing some Unicode.
I use Markdown with Python code blocks for document programming via [Pandoctools](https://github.com/kiwi0fruit/pandoctools) (like R-Markdown).
Both Python and Markdown are very readable languages. Unfortunately LaTeX is not like this. So I wrote SugaTeX extension+transpiler that is highly readable. In order to achieve this it heavily uses Unicode so that SugarTeX install instructions even have recommended monospace font fallback chains.
[SugarTeX repo](https://github.com/kiwi0fruit/sugartex) with description.
Example of input to output conversion is at the end of [this PDF](https://github.com/kiwi0fruit/sugartex/blob/master/sugartex....).
What's the downside of having $formula$ blocks in Markdown?
An odd thing I found, was the once I learned how to verbalize many of the maths that I encountered, reading them became much easier. LaTeX actually helped a lot here, because most of the constructs have good readable macros to typeset them.
Edit: actually even more to the point is the eqn sublanguage which really competes with Knuth notation.
He discuses these matters of syntax in his Gibbs lecture of of January 1978 (https://projecteuclid.org/euclid.bams/1183544082): see Figure 3 on the top of page 344, where the notation of eqn is marked "Type B" (“developed at Bell Telephone Laboratories”) and the third column is "Type T".
I happen to have fond memories of using lots of TikZ to do lots of graphics, making full-color posters with it. It was only because I was too poor to buy InDesign.
https://www.gnu.org/software/auctex/img/preview-screenshot.p...
or fold-mode (shows unicode and abbreviations in place of commands)?
https://www.flannaghan.com/2013/01/11/tex-fold-mode
Changing the representation seems more sensible to me than changing the underlying file.
Also, while the a/b syntax is easier for easy cases, I shudder to think how a continued fraction might be type set: https://en.wikipedia.org/wiki/Continued_fraction
This seems to make easy things easier and harder things really hard.
Kinda like https://www.lyx.org/Screenshots or using org-mode for latex. Convenient for simple matters and something you have to fiddle with or work around when you want to do anything more advanced.
Examples of input to output conversion see in this PDF:
https://github.com/kiwi0fruit/sugartex/blob/master/examples/...
Not really sure why people are insistent on building on top of stuff - it's taking abstraction to a new level that imho is not needed - LaTex isn't particularly unreadable.
There are things that, if you did them in a GUI, would be multiple steps down the tree of menus. It seems natural to me that they require multiple commands.
(Not that LaTeX is perfect, for sure. Admit I only glanced at this. But after trying a bunch of things that the author asserts are simplifiers, I've not found one that is as capable. All too often they make super simple things that are already simple, and then fall back to LaTeX for the rest.)
Maybe in the sense that COBOL is "working fine", so we should all just stick to that too.
LaTeX produces beautiful papers, but it's old and showing signs of its age.
I love how LaTeX/TeX is completely programmable, and anything particularly unreadable/messy can be made readable with user-defined commands, environments etc.
The idea makes sense, though I'm not sure if it's... better. Do you expect people to input " ⃗E" and "⨌" as text? Or ... what? Do you type the TeX and then have Atom autocomplete it into the Unicode symbols?
``Both Python and Markdown are very readable languages. Unfortunately LaTeX is not like this. So I wrote SugaTeX extension+transpiler that is highly readable.``
means the same...
As about input. My bad: I forget to tell about SugarTeX completions package for Atom. There to write `` ⃗E`` you type ``\^->``(+E) this autocompletes to `` ⃗E``.
To go one step further: I think writing Greek letters (or, for that matter, any Latin letter that does not have a standard mathematical meaning) is an anti-pattern in mathematical prose: I think it is much, much better to write \coercivenessSymbol than \gamma or the unicode variant for the same reasons I would not name a floating point number gamma.
I mean having any macros name you want, even Unicode.
So you can even have \γ macros. But if you want to write \coercivenessSymbol (even on the blackboard) we cannot stop you - after all it gives you pleasure.
My conclusion about this feature: https://github.com/kiwi0fruit/sugartex/issues/1
Could you please clarify the documentation (add some context) so that it is understandable to LaTeX users? Especially to LaTeX users that will want to keep using their own editor, and do not want to touch Atom with a long stick...
There's no LaTeX package and I myself will not port it. SugarTeX is Pandoc/Markdown oriented project in the first place.
You can use it as a command line prepocess text filter though. It should work as long as you use ˎ or ˎˎ to define SugarTeX.
ˎˎ ˱∇ × [ ⃗B] - 1∕c ∂[ ⃗E]∕∂t ˳= 4π∕c [ ⃗j] ¦# ∇ ⋅ [ ⃗E]\ ˳= 4πρ ¦ ∇ × [ ⃗E] + 1∕c ∂[ ⃗B]∕∂t ˳= [ ⃗0] ¦ ∇ ⋅ [ ⃗B]\ ˳= 0 ˲ ,ˎˎ{#eq:max}
where ˎ[ ⃗B], [ ⃗E], [ ⃗j]: ℝ⁴ → ℝ³ˎ – vector functions of the form
ˎ(t,x,y,z) ↦ [ ⃗f](t,x,y,z), [ ⃗f] = (f_˹x˺, f_˹y˺, f_˹z˺)ˎ.
renders to:
$$ \begin{aligned}∇ × {\mathbf{B}} - \frac{1}{c} \frac{∂{\mathbf{E}}}{∂t} &= \frac{4π}{c} {\mathbf{j}}\ ∇ ⋅ {\mathbf{E}}\ &= 4πρ \ ∇ × {\mathbf{E}} + \frac{1}{c} \frac{∂{\mathbf{B}}}{∂t} &= {\mathbf{0}} \ ∇ ⋅ {\mathbf{B}}\ &= 0 \end{aligned} ,$${#eq:max}
where ${\mathbf{B}},,{\mathbf{E}},,{\mathbf{j}}:,ℝ^{4} → ℝ^{3}$ -- vector functions of the form $(t,x,y,z) ↦ {\mathbf{f}}(t,x,y,z),,{\mathbf{f}} = (f_{\mathrm{x}}, f_{\mathrm{y}}, f_{\mathrm{z}})$.
As if 'transpiler' was not nails-on-the-board grating enough. 'Compiler' is a fine word and the right word.
Anyone knows who started this 'transpiler' nonsense. Seems very common in the javascript community but not sure if it was their 'innovation'.
Just a couple of days ago I built a little editor to manipulate markdown, latex and even simple pictures thanks to the pspicture latex environment: http://mathdown.novidee.com/96699b9ccd482d662cd3332c2a53db25 I am using marked, katex and Latex2JS.
well, I thought it was funny.