Awesome Open Source
Awesome Open Source

SwiftLaTeX

Introduction for SwiftLaTeX

SwiftLaTeX, a WYSIWYG WebAssembly client-side LaTeX Editor. All computation is done locally and files are stored in user-provided cloud storage.

Screenshot

Main Features

  1. Speed. SwiftLaTeX engines run in browsers, all computation is done strictly locally. It makes SwiftLaTeX more responsive (i.e., faster compilation) and scalable.

  2. WYSIWYG. SwiftLaTeX provides a WYSIWYG viewer, allowing users to editing PDF output directly.

  3. Flexible Storage Backend. SwiftLaTeX stores files in user-provided cloud storage or potentially self-hosting S3/Minio.

  4. Realtime collaboration. Send a secret link to your friend to start real-time collaboration.

Installation Guide

No installation needed, just try it in https://www.swiftlatex.com

Host in Windows, MAC, Linux using precompiled binaries.

Download the latest release from https://github.com/SwiftLaTeX/SwiftLaTeX/releases.

Unzip the file, and execute the windows_webserver.exe, linux_webserver, or mac_webserver based on your OSs.

For Linux users, you may need to grant execution permission by doing

chmod a+x linux_webserver

Open your browser, and go to http://localhost:3011.

This option allows you to store files in your local hard drive, Google, or Dropbox.

Compile by yourself

If you do not have node and yarn yet, try the following commands first.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
nvm install 12 (you may need to restart your console to use nvm)
npm install yarn -g 

If you already have Node 12 and yarn, just run

git clone https://github.com/SwiftLaTeX/SwiftLaTeX
cd SwiftLaTeX
yarn
yarn start

Use Docker

If you prefer using Docker, you could try the following commands.

git clone https://github.com/SwiftLaTeX/SwiftLaTeX
cd SwiftLaTeX
docker build . -t swiftlatex/swiftlatexv2
docker run -p 3011:3011 swiftlatex/swiftlatexv2

The server will be up and running in http://localhost:3011. All storage options should work of the box. You could host your own Minio server and provide the credential info to src/server/minio.tsx, such that you can store playgroud files in your server.

SwiftLaTeX Technical Details

XeTeX Engine

SwiftLaTeX engine is based on Tectonic (a C++ reimplementation of XeTeX), which supports UTF-8 and Opentype fonts out of box. The engine is not 100% faithful to XeTeX. First, though XeTeX does support Chinese/Japanese/Korea/Arabic languages, the locale line breaking function is not available yet. This function is rarely used and supporting it requires a fully working ICU library, whose size may be unbearable in browser environments. Secondly, This engine not support graphite fonts, which are rarely used too. You can find the engine source code in https://github.com/SwiftLaTeX/SwiftLaTeX-Engine. Nevertheless, compiling it requires an Emscripten toolchain and some in-depth knowledge about WebAssembly. We would strongly recommend you to use the prebuilt binaries in this repo.

Screenshot

SwiftLaTeX supports most legacy TeX fonts automatically. SwiftLaTeX also supports opentype fonts (ttf, otf), SwiftLaTeX provides a set of basic fonts (same as what you get from apt install texlive-full in Ubuntu), you could of cource upload your own opentype fonts.

\usepackage{fontspec}

\setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
\setmonofont{Inconsolata}[Scale=MatchLowercase]

Screenshot

PDFTeX Engine

Despite XeTeX engine is considered to be much modern, many users may still prefer the good-old PdfTeX engine. In fact, the first SwiftLaTeX prototype was based on PdfTeX. PdfTeX possesses some advantages such as 3x faster compilation, faithful PDF display (means full support to Tikz and PGF) and a broader LaTeX package support. Therefore, we now allow users to use the legacy PdfTeX engine. PDFTeX engine does not fully support WYSIWYG editing.
Also Unicode and Freetype are not supported. You could switch the engine as shown below. Screenshot

Storage Backends

SwiftLaTeX has few requirements on storage backends. A developer who wishes to add new storage backends just needs to implement the following three simple methods.

abstract put(scope: string, itemKey: string, file: Blob): Promise<string>;
put a file to the (scope, itemKey) and return an accessible http url to the file. SwiftLaTeX stores files in a two-level key-val structure. 

abstract get(scope: string, itemKey: string): Promise<ArrayBuffer>;
get the file located in (scope, itemKey)

abstract list(scope: string): Promise<ItemEntry[]>;
list all files located in (scope)

For more concrete examples, please have a look at src/client/storage/minio.tsx.

Project Sharing and Real-time collaboration

SwiftLaTeX adopts a simple sharing mechanism, which is agnostic to storage backends, provided that the storage backends provide a public url to each file. (For example, a user can store his project in Google Drive and share the project to users who use Dropbox). Exposing public urls is not a security risk, as they are usually very long and impractical to guess.

Sharing is achieved by using the YJS, A CRDT framework with a powerful abstraction of shared data. Every changed is synced among users. https://github.com/yjs/yjs

CTAN files

LaTeX is not a stand-alone typesetting program in itself, but document preparation software that runs on top of Donald E. Knuth's TeX typesetting system. TeX distributions usually bundle together all the parts needed for a working TeX system and they generally add to this both configuration and maintenance utilities. Nowadays LaTeX, and many of the packages built on it, form an important component of any major TeX distribution. In SwiftLaTeX, all required files are fetched from CTAN (Comprehensive TeX Archive Network), https://www.ctan.org, or our mirror server.

Language Server

SwiftLaTeX is using Digestif as a LaTeX language server. It is amazingly small and powerful. You could check out the project at https://github.com/astoff/digestif.

Change Logs

You can check the detailed change logs in http://www.swiftlatex.com/changelogs.html

Production Use

SwiftLaTeX is almost ready for production use, with the following exceptions. These exceptions will be gradually removed.

  1. No graphite fonts and international line-breaking support. We so far deem this functionalty not very useful for English-speaking people.
  2. XeTeX engine cannot properly display standalone tikz pictures, we are still investigating this issue.

Slack Channel

https://join.slack.com/t/swiftlatex/shared_invite/zt-fupygr84-HO2SStUb9UvRhqeYNa0~PQ

We prefer Github Issues if you would like to submit bug reports.

License

The code in this repository is released under the GNU AFFERO GENERAL PUBLIC LICENSE, version 3. A copy can be found in the LICENSE file. Copyright (c) SwiftLab, 2018-2020.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c (14,739
editor (464
webassembly (340
latex (286
wysiwyg (104

Find Open Source By Browsing 7,000 Topics Across 59 Categories