Giter Club home page Giter Club logo

litex's Introduction

LiTeX: A LaTeX plugin for Light Table

LiTeX is a plugin for Light Table providing support for LaTex documents. It features integrated compilation and a PDF viewer. Forward and reverse syncing between the editor and the viewer are provided with SyncTeX.

Install

LiTeX is available in the plugins repository. Alternatively, you can clone this repository into your plugins folder:

  • Linux: ~/.config/LightTable/plugins/
  • Mac: ~/Library/Application Support/LightTable/plugins/
  • Windows: *%APPDATALOCAL%\LightTable\plugins*

You may need to reload your behaviors or restart Light Table to get everything loaded properly.

You'll need TeX installed, of course. For the internal PDF viewer, you also need the command-line programs pdftoppm and pdfinfo, part of Poppler. Linux users should find these in their repositories, if they aren't already installed. (On Debian-based systems, they're in the poppler-utils package.) On Macs, Poppler can be installed with brew install poppler. For Windows, I've found a build at alivate.com to work.

Usage

After loading a TeX file, the eval commands (see below) will save the file, run LaTeX on it, and display the resultant PDF in the integrated viewer. A forward sync command highlights the paragraph where your cursor is. (Hit Ctrl-Space and search for LiTeX: forward sync.) With Ctrl held, clicking on the PDF will perform a reverse sync and move the cursor to the relevant line in your editor.

There are two compilation options, named file and project. File is bound to the eval.one trigger (Ctrl-Enter by default) and project to eval (Ctrl-Shift-Enter), but they are otherwise identical. You may use one to compile individual files and the other for a large project, one to do a quick compilation and the other to fully regenerate the project, or something else. Each has three settings that you may set:

  • filename: The name of the TeX file, for use in the next two settings. By default it's set to null, in which case the name of the current file is used, if it's a TeX file, or the name of the most recently compiled file. It can be a relative filename, in which case it is resolved relative to the directory containing the current file, or an absolute filename. You probably only need this if you're working on a project with several TeX files.

  • commands: The commands to run. Either

    • a list of strings, each one a command to be run. The substitution patterns below will be replaced with values derived from filename.
    • one of "pdflatex" (the default), "latex-dvipdf", or "latex-dvips-ps2pdf", to call those commands with appropriate arguments.
  • outputname: The name of the PDF file created by this command. The substitution patterns may be used, and the default is "%b.pdf".

Pattern Substitution value
%f name of file
%p full path of file
%d directory of file
%b base name, without file extension
%e file extension
%% a percent sign

These settings are read from two JSON-formatted files, first litexrc in your configuration directory (~/.config on Linux, ~/Library/Application Support on Mac, or %APPDATALOCAL% on Windows) and then .litexrc in the current directory. The commands to edit LiTeX settings will open these files for you.These JSON object may have two attributes, "file" and "project", each of which may have attributes "filename", "commands", and "outputname". As an example:

{ "file": { "commands": "latex-dvipdf" },
  "project": { "filename": "main.tex",
               "commands": ["bibtex %b",
                            "pdflatex -halt-on-error --synctex=1 %f"] } }

If you are editing chapter1.tex, for example, and you press Ctrl-Enter, latex and dvipdf will be run on chapter1.tex, and the PDF viewer will open chatper1.pdf. When you press Ctrl-Shift-Enter, however, bibtex and pdflatex will be run on main.tex, and the PDF viewer will open main.pdf. If you switch to editing refs.bib, you can still build main.pdf with Ctrl-Shift-Enter.

Make sure that no commands will stop and wait for input if there is a problem, as LiTeX doesn't offer a way to enter input. Practically, this means you should call latex with the -interaction=nonstopmode or -interaction=batchmode options. LiTeX will stop processing as soon as a command returns a non-zero exit code. The PDF viewer will only be prompted to load the new PDF file if all commands exit without errors.

All commands are run from the directory containing filename. If you're doing something that requires commands run in several different directories, you're probably better off using makefiles or something like latexmk or rubber. Just set "commands": ["make"], and you should be all set.

External Viewers

LiTeX can use external PDF viewers in place of the internal one. The litexrc files also have a "PDF-viewer" attribute. Set to "internal", it uses the built-in viewer. Set it to a command to launch the PDF viewer of your choice. In addition to those above, the following substitution patterns may be used:

Pattern Substitution value
%o name of PDF file
%l current line number
%c current column number

The internal viewer contains a log viewer for reviewing the output of the compilation commands. When using an external viewer, this output is written to the Light Table console only when there is an error during compilation.

License

LiTeX is copyright 2014 Robert Schroll and others, released under the GPLv3. See the LICENSE file for details. The source is available at http://github.com/rschroll/litex.

litex's People

Contributors

osdf avatar rschroll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

osdf

litex's Issues

Settings

Right now, the compilation process is hard-coded into LiTeX. Things are set up to allow running an arbitrary set of commands, with arguments based on the input file name, but there's no way for the user to access this.

We should allow both global and local settings. The global settings can probably be set in the user's behavior file, but I'm not so sure where to set the local ones. They could be in

  • a per directory config file, .litexrc or similar. These settings would automatically apply to all tex files in (and under?) that directory. This would be easiest to set up and use, I suspect.
  • project files that explicitly state to which files the settings apply. Would allow for more power in terms of which file goes where, but would be more difficult to implement.
  • per file settings, stored in comments. Ultimate specificity, but a pain to maintain. Would require parsing each file.

I'm leaning towards the first right now, since it's the easiest and still rather powerful.

The settings should include:

  • The compilation command. A list of strings to be run, with replacements for the current file name. Could be a single command (pdflatex), several (latex, dvips, ps2pdf), or triggering a build system (make).
  • The input file name. Either based off the current file name, or a fixed value, in case your project is split into several input files. Also would be useful when editing bibtex files, or similar, but I'm not sure exactly how these cases interact.
  • The output file name, in case it isn't input.pdf.

The case I'm worried about is when you have several tex files in the same directory. Each can be compiled separately, but you also have a main one that gathers them altogether into one. There are other auxiliary files that can't be compiled alone, so when they should trigger a build of the full thing. How do we make it just work, no matter which file is open?

External commands for file eval

Hi,
First off, thanks for a fabulous plugin. I seem to be unable to pass "pdflatex" as an external command to the file eval trigger. Context: I use the Linux subsystem on windows (so far I've got the best of both worlds in userspace), and while LightTable is running as a Windows binary, my Latex installation is inside WLS. On a typical windows command line, I can run call pdflatex like so:

prompt>bash -c "pdflatex file.tex"

and this works fine. However, with a litexrc like so:

{ "file": { "commands": ["external-command bash -c pdflatex -interaction=nonstopmode %f"] },
  "project": { "filename": "%p",
               "commands": ["external-command bash -c pdflatex -interaction=nonstopmode --synctex=1 %f",
                            "external-command bash -c bibtex %b",
                            "external-command bash -c pdflatex -interaction=nonstopmode --synctex=1 %f"]}}

Pressing ctrl+enter does nothing. Nothing shows up on the console, the status pane says "Connected to PDF Viewer" and in the PDF Viewer pane is a message saying "The system cannot find the path specified"

Perhaps I'm doing something horribly wrong [and I do recognize that running lighttable from within WLS, while compiling a file within WLS would be the sensible thing to do. But I just can't seem to get lighttable working within WLS].

External PDF viewer

It should be possible to turn off LiTeX's PDF viewer, to allow another to be used. As a first step, we can just disable the internal viewer. But it'd be better to allow executing an arbitrary command, to allow for forward syncing.

Reverse syncing from external viewers would also be nice, but I'm not sure exactly how that would work.

Add lacheck or chktex support.

This plugin is great. It would be nice to have also a light syntax checker while editing latex code, in the spirit of vim/syntastic or emacs/flycheck.

Reverse sync errors out

Sorry to open the first bug report, so let me at first say thank you for this plugin, it's very useful!
I have tested it a bit already, and most of it works, with the exception of reverse sync. This does not work, giving me the error:

No such file: <path-to-my-existing-tex-file>

Invalid behavior: :lt.plugins.litex.viewer/on-out
TypeError: Cannot call method 'setCursor' of null
    at lt.objs.editor.move_cursor (app://lighttable/core/node_modules/lighttable/bootstrap.js:23454:50)
    at Function.__BEH__on_out (/home/cbuchner/.config/LightTable/plugins/LiTeX/litex_compiled.js:427:35)
    at c (app://lighttable/core/node_modules/lighttable/bootstrap.js:6151:14)
    at a (app://lighttable/core/node_modules/lighttable/bootstrap.js:6191:18)
    at lt.object.raise_STAR_ (app://lighttable/core/node_modules/lighttable/bootstrap.js:20425:74)
    at a (app://lighttable/core/node_modules/lighttable/bootstrap.js:20458:34)
    at b (app://lighttable/core/node_modules/lighttable/bootstrap.js:20462:14)
    at Socket.eval (app://lighttable/core/node_modules/lighttable/bootstrap.js:29675:78)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.eval (_stream_readable.js:746:14)

Rendering works, forward sync works. OS: Ubuntu13.10 32bit, pdftoppm (i.e. poppler-utils) is installed, synctex (i.e. texlive-extra-utils) is installed and works correctly in my latex setup (Kile+Okular). Litex has been installed with the LT plugin manager.

Another minor thing I don't know if you can optimize: In the command search, searching for "latex" yields no result, which is kinda suboptimal (I expected it to when rendering a latex file).
I don't know if you can define aliases for commands or somesuch (@ibdknox?), but if so it would be a good idea (imHo) to alias Latex here (or maybe rename the plugin? lt-latex or somesuch?)

PDF Viewer not showing pdf

Fresh LT install (version 0.6.5), litex is the only plugin installed.
Compiling (via ctrl-enter) a simple .tex file produces the correct .pdf file, however it is not displayed in the opened pdf tabset. A blue rectangular shows up in the pdf tabset and fades away, nothing else is there. Show logs doesn't show any errors. Show Connections in LT displays under Commands :editor.eval.tex and :litex.forward-sync. synctex is installed (version 1.2), pdftoppm has version 0.24.1, pdfinfo has version 0.24.1.

What am I doing wrong?

Smart quotes

LiTeX should convert double quotes to TeX style quotes: `` and ''. Light Table already handles quotes specially, so we should be able to glom onto that. It would be good to avoid doing this following a backslash, so you can enter umlauts. Perhaps we should also do this for single quotes.

This should be optional, but enabling it by default seems reasonable.

nothing happens

I cloned the latest litex into the plugin directory. I opened a tex file. I do Ctrl+Enter but nothing happens, not even some feedback in the console. Also I cannot search for litex commands as if it is not installed, but the files are in the plugin folder and the plugin manager says it's installed.

.pdf won't display

First of all thanks for this plugin. I am excited it exists.

I have followed the docs to the best of my ability but cannot get the .pdf to display when using the local .litexrc

Here is an example of my code (which is just a bit different than the one in the documentation):

{ "file": { "commands": ["pdflatex -interaction=nonstopmode %f"] },
  "project": { "filename": "myFile.tex",
               "commands": ["pdflatex -interaction=nonstopmode --synctex=1 %f",
                            "biber %b",
                            "pdflatex -interaction=nonstopmode --synctex=1 %f"]}}

This will successfully build the file. I get some document around 25 pages and can view it with another editor, however I don't see any output in the internal .pdf viewer.

I see have also tried adding something like:

"PDF-viewer": "internal"

to no avail. Although I'm not sure if I added that correctly when I did it, and I don't think it should be necessary.

Am I doing something incorrectly?

Thanks!!

Ctrl+Click Does not reverse sync on OSX

Forward sync works well, but reverse sync isn't doing what it's supposed to do. I've tried using both ctrl and cmd to try and activate this feature but neither of them work correctly (not alone or in combination with other modifiers like shift or option).

Give error if command string isn't found

In the settings, "commands" can be a list of strings or one of three specific strings. If it's a string that's not of of those three, it ends up getting treated as a list of characters. Thus it fails with an indecipherable error message.

We should catch this case and fail earlier.

error message: pdflatex not found

When trying to compile a TeX file I get the error message

/bin/sh: pdflatex: command not found

However, pdflatex is installed and on the path. Running pdflatex from a terminal works fine, even from one using /bin/sh instead of /bin/bash as shell.

Compile project from file in subdirectory

I have a project that is composed of a main file and inputed files from subdirectory like this

project
|- chap1
|  `- foo.tex
` main.tex

Is it currently possible to compile main.tex when foo.tex is opened without switching?

It would be nice, if the project evaluation would be aware of files in subdirectories.

LiTeX should work with Xpdf utils as well as Poppler utils

Summary by @rschroll: The Xpdf version of pdftoppm doesn't support the -png flag, but Xpdf does provide a pdftopng command that we could use instead. It currently has problems on Windows, but we should support it as soon as those problems are fixed.


PDF content is not rendered.

screenshot 2014-05-29_052914_023259_pm

Light Table version: 0.6.5 (on Windows 7 x64)
Binary version: 0.8.4
LiTeX version: 0,0.7
pdftoppm version 3.04

Error after upgrade to LightTable 0.6.6

Hi,

When trying to evaluate and inline display the PDF I get the following error. The exact same file evaluated flawlessly with LT 0.6.5.

Error loading JS file: /home/ghachey/.config/LightTable/plugins/Color_Picker/color picker_compiled.js : Error: Assert failed: Command doesn't have required keys: #{:desc :exec :command}
(every? cmd required-keys)"", source: file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js (28955)
[14370:0603/100858:INFO:CONSOLE(28956)] ""Error: Assert failed: Command doesn't have required keys: #{:desc :exec :command}
(every? cmd required-keys)
    at Error (\u003Canonymous\u003E)
    at lt.objs.command.command (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:21053:11)
    at eval (/home/ghachey/.config/LightTable/plugins/Color_Picker/color%20picker_compiled.js:96:25)
    at eval (native)
    at c (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:21392:41)
    at a (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:21400:18)
    at Function.lt.objs.plugins.__BEH__load_js (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:28947:33)
    at c (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:6196:14)
    at a (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:6236:18)
    at lt.object.raise_STAR_ (file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js:20559:74)"", source: file:///opt/LightTable/core/node_modules/lighttable/bootstrap.js (28956)

PDF Viewer

My original plan had been to use pdf.js to render PDF files, but this doesn't work under Light Table. I wrote PDF viewer using pdftoppm that was supposed to be just for demonstration purposes, but it's actually working pretty well. But before we continue to put work into it, let's make sure it's the right thing to do.

My two main worries are:

  • Compatibility. pdftoppm is widely available on Linux, but I suspect the situation is different on Windows and OS X. I don't know of another converter that is more available, so if we can't do it in javascript, we may just have to use different rasterizers on different platforms.
  • Performance. pdftoppm is snappy enough, but we do a round trip through the file system to get the images. We also render and load all the pages before we do anything with them, which will be bad for large files. We could address both of these by calling pdftoppm to render just the pages we need on demand. This would require us to know about the page sizes before calling pdftoppm, but right now we're using pdftoppm to figure that out.

It'd be nice to use Chrome's built-in PDF viewer, but that's apparently closed source and thus not shipped with Chromium.

I have no other clever ideas, so I'm hoping someone else will suggest the solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.