[Plugin] LiTeX: LaTeX compilation, previewing, and syncing

1,379 views
Skip to first unread message

Robert Schroll

unread,
Jan 22, 2014, 1:43:43 AM1/22/14
to light-table...@googlegroups.com
Continuing this evening's theme of markup languages, I'm pleased to
announce LiTeX, a Light Table plugin for LaTeX. It's in the plugin
repository and on GitHub: https://github.com/rschroll/litex

LiTeX hooks up the evaluate action to compile the LaTeX document, and
it provides a PDF viewer so you can see what it looks like. Using
SyncTeX, it provides both forward and reverse synchronization between
the editor and the PDF. Here's what it looks like:
https://raw.github.com/wiki/rschroll/litex/images/ss.png

I never got pdf.js working, so I'm relying on pdftoppm to render the
PDF to bitmaps that I display as images. pdftoppm is installed (or
easily installable) on all Linuxes, but I'm not sure about the
situation on Macs or Windows. If you know about such things, please
let me know.

There are a lot of rough edges right now. Notably, the LaTeX command
is hard-coded in. One of my next goals is to make that into a setting.
(Is there a particular way we should do that?) This is my first time
programming in any Lisp [1], so I'm sure my code is littered with
non-idomatic bits and outright errors. I'll happily accepts bugs and
pull requests at GitHub about these and other problems. I started by
modifying existing Light Table code, so I'm sure I've left bits of that
in that aren't doing anything anymore.

Share and enjoy,
Robert

[1] Preliminary impression: only slightly less frustrating than TeX.

Robert Schroll

unread,
Jan 23, 2014, 4:16:25 PM1/23/14
to light-table...@googlegroups.com
Hi all,

I've released a new version of LiTeX, which fixes several issues with
syncing. It also features a massive clean-up of the code, which should
help in the future.

Speaking of the future, I've opened bugs about settings [1] and the PDF
viewer [2] to gather opinions. So if you think you might like to use
LiTeX, here's your chance to make sure it'll be useful for you.

Share and enjoy,
Robert

[1] https://github.com/rschroll/litex/issues/3
[2] https://github.com/rschroll/litex/issues/4



Matthew West

unread,
Jan 23, 2014, 7:38:01 PM1/23/14
to light-table...@googlegroups.com
How do you use it? I'm not finding any commands.

Robert Schroll

unread,
Jan 23, 2014, 7:59:55 PM1/23/14
to light-table...@googlegroups.com
On Thu, Jan 23, 2014 at 7:38 PM, Matthew West
<matthew...@gmail.com> wrote:
> How do you use it? I'm not finding any commands.
>

First, make sure you've reloaded your behaviors (or restarted) after
installing the plugin.

Once you've done that, any open tex file should be compilable by
running eval (Ctrl-Enter, by default). This should open the PDF viewer
automatically. There is also a command for forward sync named "LiTeX:
Forward sync from LaTeX to PDF" that should appear in your command list.

If not, let me know. We'll try to figure out why.

Robert

Matthew West

unread,
Jan 24, 2014, 10:42:48 PM1/24/14
to light-table...@googlegroups.com
Found it. I just had neglected to restart!

Mauro Andreolini

unread,
Jan 29, 2014, 11:30:21 AM1/29/14
to light-table...@googlegroups.com


On Wednesday, January 22, 2014 7:43:43 AM UTC+1, Robert Schroll wrote:
Continuing this evening's theme of markup languages, I'm pleased to
announce LiTeX, a Light Table plugin for LaTeX.  It's in the plugin
repository and on GitHub: https://github.com/rschroll/litex

LiTeX hooks up the evaluate action to compile the LaTeX document, and
it provides a PDF viewer so you can see what it looks like.  Using
SyncTeX, it provides both forward and reverse synchronization between
the editor and the PDF.  Here's what it looks like:
https://raw.github.com/wiki/rschroll/litex/images/ss.png

I never got pdf.js working, so I'm relying on pdftoppm to render the
PDF to bitmaps that I display as images.  pdftoppm is installed (or
easily installable) on all Linuxes, but I'm not sure about the
situation on Macs or Windows.  If you know about such things, please
let me know.
Awesome work! 

There are a lot of rough edges right now.  Notably, the LaTeX command
is hard-coded in.  One of my next goals is to make that into a setting.
 (Is there a particular way we should do that?)  This is my first time
programming in any Lisp [1], so I'm sure my code is littered with
non-idomatic bits and outright errors.  I'll happily accepts bugs and
pull requests at GitHub about these and other problems.  I started by
modifying existing Light Table code, so I'm sure I've left bits of that
in that aren't doing anything anymore.
I think it would be fantastic if LiTeX could compile documents split
into multiple .tex files.

Thanks again (using LiTeX right now ;-)
Mauro

Robert Schroll

unread,
Jan 29, 2014, 1:11:32 PM1/29/14
to light-table...@googlegroups.com
On Wed, Jan 29, 2014 at 11:30 AM, Mauro Andreolini
<mauro.an...@gmail.com> wrote:
> I think it would be fantastic if LiTeX could compile documents split
> into multiple .tex files.
>

This is definitely in the plans, by way of making the compilation step
configurable: https://github.com/rschroll/litex/issues/3

While I'm here, I might as well ask, does Light Table have a built-in
function for reading and parsing JSON files? I'm planning on storing
the settings in JSON. I'm sure all the pieces are there to read and
parse such files, but if there's an already-existing solution, I might
as well use that.

Robert

Chris Granger

unread,
Jan 29, 2014, 1:13:10 PM1/29/14
to light-table...@googlegroups.com
lt.objs.files/open-sync will open a path and give you back line-ending, type, and content in a map. Then you'd just use js/JSON.parse to parse it.

Cheers,
Chris.




--
You received this message because you are subscribed to the Google Groups "Light Table Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to light-table-discussion+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Robert Schroll

unread,
Jan 29, 2014, 1:14:47 PM1/29/14
to light-table...@googlegroups.com
On Wed, Jan 29, 2014 at 1:13 PM, Chris Granger <ibd...@gmail.com>
wrote:
> lt.objs.files/open-sync will open a path and give you back
> line-ending, type, and content in a map. Then you'd just use
> js/JSON.parse to parse it.
>
Fantastic! Thanks,
Robert



Robert Schroll

unread,
Feb 1, 2014, 4:46:50 PM2/1/14
to light-table...@googlegroups.com
On Wed, Jan 29, 2014 at 11:30 AM, Mauro Andreolini
<mauro.an...@gmail.com> wrote:
> I think it would be fantastic if LiTeX could compile documents split
> into multiple .tex files.
>

I've just released version 0.0.3, which includes settings. With them,
you can specify which file to run latex on, as well as the sequence of
commands to run. I've done my best to explain how they work here
(https://github.com/rschroll/litex#usage), or you can use one of the
"edit settings" commands to open the appropriate file with a template
for you to edit.

Ideally, the settings should make easy things easy, moderately
complicated things possible, and let you use a real build system for
really complicated things. But if you have trouble getting it to work,
please let me know.

Share and enjoy,
Robert



Robert Schroll

unread,
Feb 6, 2014, 12:21:39 AM2/6/14
to light-table...@googlegroups.com
I've just released version 0.0.4, which improves the PDF viewer
significantly. Instead of rendering all the pages at high resolution
at once, pages are now rendered as needed. This means the viewer
should get into a usable state in under a second, regardless of the
length of the document. I'm still using utilities from Xpdf/Poppler.
I know they're widely installed on Linuxes, but I don't know how easy
they are to install on Windows or OS X. If you have experience on
those systems, please speak up.

At this point, LiTeX has basically all the functionality that I want.
If it's missing something that you need, speak up!

Robert


On Sat, Feb 1, 2014 at 4:46 PM, Robert Schroll <rsch...@gmail.com>
wrote:

Robert Schroll

unread,
Apr 14, 2014, 6:08:53 PM4/14/14
to light-table...@googlegroups.com
A small update to LiTeX today. There's some better error detection and
reporting, but hopefully you won't notice this. LiTeX also respects
your system settings for the configuration directory for the global
litexrc file, instead of hardcoding it to ~/.config. If you're on
Linux, you probably won't notice any difference, but on other systems,
you'll need to move your global settings to the new location, if you're
using them. If you're not sure where this file should go, run the
LiTeX global settings command to open the correct file.

Robert


On Thu, Feb 6, 2014 at 12:21 AM, Robert Schroll <rsch...@gmail.com>
wrote:

Jan Strube

unread,
Jun 8, 2014, 9:47:05 PM6/8/14
to light-table...@googlegroups.com
Apologies for replying to this stale thread. If there's a better place for LiTeX discussion, please let me know.
I just discovered Light Table and LiTeX, and I'm still quite excited about it.
Many thanks to the developers.

I found that LiTeX does not by default insert LaTeX quotes, i.e., when marking a word and pressing ", it inserts " before and " after the word.
Contrast this with the way it's done in the Sublime Text plugin, which inserts `` (two backticks) before the word and '' (two single quotes) after, as required by LaTeX.
Not knowing anything about LightTable or LiTeX, yet, could this be done as well?

Second feature request: Is there a way to use an external viewer instead of the internal one? The internal pdf viewer doesn't seem to support hyperlinks on my machine (macosx).

Thanks for considering.

    Jan

Robert Schroll

unread,
Jun 9, 2014, 12:51:48 AM6/9/14
to light-table...@googlegroups.com
On Sun, Jun 8, 2014 at 9:47 PM, Jan Strube <jan.s...@gmail.com> wrote:
> Apologies for replying to this stale thread. If there's a better
> place for LiTeX discussion, please let me know.

I think this is a fine place for discussion, but if the Light Table
devs object, I can make another list. That said, it's probably better
to submit feature requests on Github
(https://github.com/rschroll/litex/issues), so it's harder for me to
forget about them.

> I found that LiTeX does not by default insert LaTeX quotes, i.e.,
> when marking a word and pressing ", it inserts " before and " after
> the word.
> Contrast this with the way it's done in the Sublime Text plugin,
> which inserts `` (two backticks) before the word and '' (two single
> quotes) after, as required by LaTeX.
> Not knowing anything about LightTable or LiTeX, yet, could this be
> done as well?

I think it could, although I haven't looked at the details yet. Light
Table already treats quotes specially, to insert pairs of quotes, so we
should be able to override that behavior with our own. This is now
issue 15: https://github.com/rschroll/litex/issues/15

> Second feature request: Is there a way to use an external viewer
> instead of the internal one? The internal pdf viewer doesn't seem to
> support hyperlinks on my machine (macosx).

Yeah, the PDF viewer is very simplistic. I originally planned to use
PDF.js (http://mozilla.github.io/pdf.js/) for the viewer, but I never
got that to work with Light Table.

As a first step, it should be possible to disable the internal viewer,
so you can use your favorite viewer instead. It'd be even better to
let you specify an arbitrary command to run, so you can set up forward
syncing. See issue 16: https://github.com/rschroll/litex/issues/16

I can't promise that I'll get to either of these soon. I'm happy to
answer questions if anyone else wants to take a shot at it.

By the way, the recent Light Table upgrade revealed a bug in older
versions LiTeX. So if it just stopped working for you, upgrade to the
most recent plugin version.

Thanks,
Robert



Robert Schroll

unread,
Jul 1, 2014, 12:11:36 AM7/1/14
to light-table...@googlegroups.com
Good news, everyone! I've released a new version of LiTeX.

On Sun, Jun 8, 2014 at 9:47 PM, Jan Strube <jan.s...@gmail.com> wrote:
> I found that LiTeX does not by default insert LaTeX quotes, i.e.,
> when marking a word and pressing ", it inserts " before and " after
> the word.
> Contrast this with the way it's done in the Sublime Text plugin,
> which inserts `` (two backticks) before the word and '' (two single
> quotes) after, as required by LaTeX.
> Not knowing anything about LightTable or LiTeX, yet, could this be
> done as well?

LiTeX now converts double quotes to backticks or single quotes where
appropriate. It also treats $ as a paired delimiter and is more
intelligent with parenthesis and brackets. For example, typing
"\left(" will automatically insert "\right)" after the cursor, and
typing ")" just before the "\right)" will move the cursor to the end of
it.

> Second feature request: Is there a way to use an external viewer
> instead of the internal one? The internal pdf viewer doesn't seem to
> support hyperlinks on my machine (macosx).

This is now supported through an option in your litexrc files. See the
README for more information. It's sort of basic right now; do let me
know if you see improvements that should be made.

Robert



Jan Strube

unread,
Jul 8, 2014, 5:08:59 AM7/8/14
to light-table...@googlegroups.com
This is a great update!
I get this to work on mac like this:
In litexrc:
"PDF-viewer": "/Applications/Skim.app/Contents/SharedSupport/displayline %l %o %f"

In Skim.app preferences, in the sync tab:
Preset: Custom
Command: light
Arguments: "%file"

Then, Shift+Cmd+Click opens the right file

In other apps, e.g. sublime, I can jump to a line in the given file on the command line: subl "%file":%line
How do I achieve that in light table?

Robert Schroll

unread,
Jul 8, 2014, 2:29:32 PM7/8/14
to light-table...@googlegroups.com
On Tue, Jul 8, 2014 at 5:08 AM, Jan Strube <jan.s...@gmail.com> wrote:
> In other apps, e.g. sublime, I can jump to a line in the given file
> on the command line: subl "%file":%line
> How do I achieve that in light table?

As for as I can tell, Light Table doesn't have this capability. I've
submitted a bug: https://github.com/LightTable/LightTable/issues/1549

Robert



Reply all
Reply to author
Forward
0 new messages