Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: (lax) a pythonic way of writting latex (github.com)
12 points by iogf 4 months ago | hide | past | web | favorite | 6 comments

>I always found it boring and a pain to write some mathematical formulaes in latex. Mainly those with a lot of \frac{x}{Y} stuff.


This is what keybinds were invented for. I feel really silly for saying this but I made a huge list of custom keybinds only then finding out that the default keybinds in Vim-LaTeX-Suite are super good.

For example


backtick slash, expands to


where <++> are so called bullets that you can jump to with <C-j>. Another example


expands to


and all the other letters work as well (`b to \beta, `g to \gamma, etc.). Look into it, it makes typing LaTeX a breeze!

Thank you for the link to the latex suite. I should have seen this before.

Links for the curious:





I dislike the latex math syntax per the reasons stated in the github article. I also like the idea of being able to output polynomials from a math calculation in python without having to roll my own latex pretty printer (many libraries exist here, but given my infrequent use case I like to keep things as simple as possible).

If I'm honest, I had only thought of intermixing tex with other constructs from the web (e.g. Markdown) and 'lax' gave me the idea to look around. I found a few more tidbits:

https://github.com/s9w/preTeX https://github.com/jobh/latex.py https://github.com/lukasdietrich/untex https://github.com/kosmikus/lhs2tex/ (cool example at https://github.com/kosmikus/lhs2tex/blob/master/doc/AGExampl...)

While I prefer vim and like the bindings, I like to have editor agnostic tools.

For those interested, I currently use pandoc, markdown, and latex -- via vim -- with an Ergodox EZ... (https://configure.ergodox-ez.com/layouts/ywYn/latest/0).

I suspect you may have some issues:

  lax -c 'xyz^(alpha(x-2))'
Here, I suspect that alpha is intended to be a single identifier. Yet, TeX will typeset this as a product of the five terms a, l, p, h and a.

Note how in the case of sqrt, there is a special control sequence \sqrt and not just a clump of four letters. Without the backslash, it would just be the product term s q r t.

You need something like \text{alpha} or whatever is the correct approach; not sure about this.

But then you have an ambiguity in your source language: why is xyz a product of terms, but alpha a single term.

You might need some notation like \alpha which will mean "the clump of letters which follows is a unit". Your code can decide whether this is something standard like sin, so that \sin can map to \sin, or whether it is nonstandard, requiring treatment like \alpha -> \text{alpha}. Or other ideas: let the user define the symbols, and use "maximal munch": take the longest consecutive sequence of letters that exists as an entry in the user's dictionary of variables and functions.

Looks super useful. Have you thought about extending it to write entire LaTeX documents with this syntax?

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact