Giter VIP home page Giter VIP logo

texcompile's Introduction

TeX Compilation Service

This service compiles TeX/LaTeX projects. It provides many conveniences, such as automatically detecting the main TeX file, compiling multiple files, and combining the output into a single file.

The compilation service is a lightweight wrapper around the AutoTeX library used by arXiv to automatically compile submissions to arXiv.

Setup

This project relies on a custom version of TeXLive. Download the TeXLive package with the command below. This command requires an account with Amazon Web Services, a local installation of the AWS Command Line Interface (CLI), and having configured the AWS CLI with your login. Your AWS account will be charged with the costs of downloading the TeXLive archive (see the Amazon S3 documentation for download charges).

cd texcompile/service
aws s3 cp --request-payer requester s3://texcompile/texlive.tar.gz texlive.tar.gz

Then, build the Docker container for the service. This will take a long time, as it requires building a custom version of Perl.

docker build -t tex-compilation-service .

Start the service

# Hosts the service on port 8000 of localhost.
docker run -p 8000:80 -it tex-compilation-service

Query the service

The service takes as input a directory containing a TeX/LaTeX project (without any prior compilation results or auxiliary files), and returns a list of generated PDFs and PostScript files.

Say, for example, you wish to compile the LaTeX project for arXiv paper 1601.00978. First, fetch the sources for the project:

wget https://arxiv.org/e-print/1601.00978 --user-agent "Name <email>"

Then, unpack the sources into a directory:

mkdir sources
tar xzvf 1601.00978 -C sources

Queries to the service can be made through a dedicated client library, which you can install as follows:

pip install git+https://github.com/andrewhead/texcompile

Once the client library is installed, you can make a request like so:

from texcompile.client import compile

result = compile(
  sources_dir='sources',
  output_dir='outputs',
)

Inspect whether the request succeeded:

# Did the query succeed?
print(result.success)  # Output: True

# What are the main TeX files that were compiled to produce the outputs? Note 
# that this only contains the names of main files that the TeX/LaTeX binaries
# were called on, and not those that were 'input' or 'included'.
print(result.main_tex_files)  # Output: ['craternn.tex']

# Inspect compilation logs.
print(result.log)  # Output: <Long string of logs from compiling the TeX>

# Manifest of generated files.
print(result.output_files)  # Output: [{ 'type': 'pdf', 'name': 'craternn.pdf' }]

Each of the files listed in result.output_files will have been written into the output_dir supplied as an argument to compile. At this point, you should be able to open outputs/craternn.pdf to see the compiled PDF. Generated files may be either PDFs (type: pdf) or PostScript files (type: ps).

Caveats

This service will not compile all TeX/LaTeX projects. It is designed to compile those that are hosted on arXiv. In fact, its backend uses tools that arXiv uses to compile papers.

The service also has a low success rate compiling recent arXiv papers written in the last few years, because the version of AutoTeX used to compile the papers is outdated. It is hoped that the AutoTeX dependency for this project will be upgraded soon.

License

Apache 2.0.

texcompile's People

Contributors

andrewhead avatar

Stargazers

 avatar  avatar Masanori Ogino avatar

Watchers

James Cloos avatar  avatar

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.