This repository provides a Codespace environment for instantly and automatically building and previewing LaTeX files.
The initial goal was to develop a Visual Studio Code extension for building LaTeX files and previewing PDFs "on-the-fly" within the web IDE. However, this is impractical due to the following limitations:
- LaTeX processing relies on various packages and dependencies typically run in a local environment.
- Web IDEs have limited access to the file system and system-level utilities.
The optimal approach is to create an extension using a codespace with all necessary dependencies. However, using a Docker image with Codespaces remains the simplest and most reliable solution for me at the current moment.
- Fork or use this repository and click on
Code
. - Click
Create codespace on main
. - Wait 2-3 minutes for the codespace to finish building.
- Open
latex/sample.tex
. - Click the green triangle or press
Ctrl + Alt + B
to build the LaTeX project. - View
sample.pdf
in thelatex/PDF
directory. - Customize the layout, e.g., 50%
sample.tex
and 50%sample.pdf
. - Changes to the
.tex
file will automatically rebuild and update the PDF preview.
Note
The initial PDF preview may take about 30 seconds to set up correctly. It will also open a new window for port forwarding. Once successful, this window can be closed.
Can also use Gitpod to create an environment based on this repository, click here or use the link below:
https://gitpod.io/#https://github.com/jotavare/latex-preview-container/
Note
Unlike Codespaces, Gitpod offers instant PDF previews from the start. No waiting for the first time.
The Docker image pulls the latest full version of TeX Live without documentation and source files, installs git
and perl
, and cleans unnecessary files, totalling 2.33GB. Depending on the project needs, other tags like minimal
, small
, or medium
may also be used, to reduce codespaces build time.
latex-preview-container/
│
├── .devcontainer/
│ ├── devcontainer.json # Configuration file for Codespaces devcontainer
│
├── docker/
│ ├── Dockerfile # Dockerfile for setting up the development environment
│ ├── docker-compose.yml # Docker Compose file for managing Docker containers
│
├── latex/
│ ├── sample.tex # Sample LaTeX file for testing purposes
│
├── LICENSE # Licensing information for the project
└── README.md # Project documentation
Below are links I used to create this repository and other information that may be useful in the future.
Link | Source |
---|---|
TeX Live | Website |
TeX Live Docker Image | Website |
Installing TeX Live | Website |
The Comprehensive TeX Archive Network | Website |
James-Yu/LaTeX-Workshop | GitHub |
PDFTeX | Website |
WebLaTex | GitHub |
TinyTeX | Unix |
MiKTeX | Windows |
MacTeX | Macintosh |
Typst is a new markup-based typesetting system that is designed to be as powerful as LaTeX while being much easier to learn and use.
Link | Source |
---|---|
Typst | GitHub |
Typst Setup | GitHub |
Typst Actions | GitHub |
Typst Live | GitHub |
- Create a smaller and optimized Docker image with minimal tools for LaTeX, to build and preview PDF files.
- Include new extensions in the
devcontainer.json
to enhance the workflow, such as grammar check, code formatting, Copilot, dark mode, etc. - Explore the LaTeX Workshop extension wiki to provide more features and utilities to the devcontainer.
If you find any issues or have suggestions for improvements, feel free to fork the repository and open an issue or submit a pull request.
This project is available under the MIT License. For further details, please refer to the LICENSE file.