Giter VIP home page Giter VIP logo

latex-docker's Introduction

Latex docker container Docker hub

This container helps compiling latex sources without the need to install all latex packages on your system.

Why should I use this container?

  • Easy setup, compile immediately after image download
  • Preserves UID and GID of local user
  • Use container like local command: latexdockercmd.sh pdflatex main.tex
  • Multiple distributions like ubuntu's texlive-full to cover all needs

Versions

All versions are based on Ubuntu: (See all tags)

If you need...

  • ...the most-stuff-works-out-of-the-box package, try blang/latex:ubuntu.
  • ...the most recent version of everything, try blang/latex:ctanfull.
  • ...a stable base for your custom texlive build, try blang/latex:ctanbasic.

For stability, choose a more specific version tag (See all tags)

Quick Setup

Compile latex sources using docker:

# Change to your project
cd my_latex_project

# Download the command wrapper and make it executable
wget https://raw.githubusercontent.com/blang/latex-docker/master/latexdockercmd.sh
chmod +x latexdockercmd.sh

# Optional: Change the version (see above, default blang/latex:ubuntu)
edit ./latexdockercmd.sh

# Compile using pdflatex (docker will pull the image automatically)
./latexdockercmd.sh pdflatex main.tex

# Or use latexmk (best option)
./latexdockercmd.sh latexmk -cd -f -interaction=batchmode -pdf main.tex
# Cleanup: ./dockercmd.sh latexmk -c or -C

# Or make multiple passes (does not start container twice)
../latexdockercmd.sh /bin/sh -c "pdflatex main.tex && pdflatex main.tex"

Requirements

First, add your local user to docker group (should already be the case):

sudo usermod -aG docker YOURUSERNAME

The latexdockercmd.sh will use your current user and group id to compile.

Daemon setup

If you're working on source in latex, you might want to compile it multiple times and don't want to start a container each time.

cd my_latex_source

# Start a daemon container on this path, it accepts commands from latexdockerdaemoncmd.sh
latexdockerdaemon.sh

# Execute the command in the daemon container, only the daemon container is running
latexdockerdaemoncmd.sh pdflatex main.tex

# Stop the daemon
docker stop latex_daemon

Customize

If software is missing, extend this base image with your own software:

Create a Dockerfile or download Dockerfile.blueprint for examples:

FROM blang/latex:ubuntu

# Minted + Pygments
RUN tlmgr install minted

Build your custom image:

docker build -t mycustomlateximg .

Edit latexdockercmd.sh to use your image mycustomlateximg.

Latex Make

Clean build using latexmk:

mkdir compile
latexmk -cd -f -jobname=output -outdir=./compile -auxdir=./compile -interaction=batchmode -pdf ./main.tex

Use latexmkrc in your project root:

# Example: Make glossaries
add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
sub makeglo2gls {
    system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
}

CTAN Packages

A list of available ctan packages can be found here: http://mirror.ctan.org/systems/texlive/tlnet/archive

Install texlive packages:

RUN tlmgr install minted

Contribution

If the image is missing a package only specific for you, please don't open an issue or pull request but build your own image as described above. If a critical package is missing or you have a recipe for missing packages in a common scenario, please create an issue / PR on Dockerfile.blueprint.

License

See LICENSE file.

latex-docker's People

Contributors

alex-pl avatar blang avatar denisvm avatar jmewes avatar k00ni 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

latex-docker's Issues

biber missing

the biber backend for biblatex is missing, i think such an essential part of latex has to be included in the container.

i use your image for automated builds. i think your image is really popular, because gitlab.com suggests it for gitlab-ci. but always execute apt-get update && apt-get install -y XY before build decelerates build time heavily for such an easy task...

curl missing

would be nice if you include the curl command. its so basic, should be installed on every container...

TexStudio

How to integrate with TexStudio?
Thanks.

Change default work directory

Hi, when I was building my custom image, I wanted to add some biblatex files to TEXMFHOME. The problem is that in the base image TEXMFHOME is located at /data/tex, which means that when the cmd scripts mount a directory like this: -v "$PWD":/data, it will overwrite the contents of TEXMFHOME.

I suggest changing the workdir to something like /data/src, so that TEXMFHOME is undisturbed.

Update Docker Hub README: dockercmd.sh not found

In https://hub.docker.com/r/blang/latex/ we can see that in README it suggests us to download dockercmd.sh, which has been replaced by latexdockercmd.sh:

The following statement is not working anymore:

wget https://raw.githubusercontent.com/blang/latex-docker/master/dockercmd.sh
--2018-04-08 00:47:14--  https://raw.githubusercontent.com/blang/latex-docker/master/dockercmd.sh
Resolving raw.githubusercontent.com... 151.101.92.133
Connecting to raw.githubusercontent.com|151.101.92.133|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-04-08 00:47:14 ERROR 404: Not Found.

So please replace according to the most recent README version, which can be found in this repository.

Missing section numbering due to titlesec bug in ubuntu container

Hi,
there seems to be a bug in the titlesec package within the ubuntu container which leads to missing section numbering in some documents. See https://bugs.launchpad.net/ubuntu/+source/texlive-extra/+bug/1574052 .
From my tests this seems to be fixed in the texlive package for ubuntu 18.04.

Another possible fix is described here: https://tex.stackexchange.com/questions/299969/titlesec-loss-of-section-numbering-with-the-new-update-2016-03-15 .

Lualatex

Lualatex uses a cache folder which is not accessible if you change the user to something else than root.

The error:

quiting: fix your writable cache path

My fix:

RUN chmod 1777 /var/lib/texmf

This changes the permissions so any user can write to the cache folder. The location of the cache folder is specified by the TEXMFCACHE environment variable. More info:
https://wiki.archlinux.org/index.php/TeX_Live#Usage

Consider adding biber to pre-installed packages

Thanks for this image, works just fine! I've started using it to kick off automatic builds of the PDF and publishing it using Gitlab-CI.

Since this image now is even sort of officially mentioned in the template for such tasks in the Gitlab documentation, why not make it more useable for biblatex-workflows by adding biber via apt?

Otherwise, any compilation will fail with the missing dependency.

Why is ubuntu image smaller than debian?

Hello,

I'm just getting into Docker and I thought I would be able to optimize the size of your LaTeX image, but to no avail; even though debian:latest is 2/3 the size of ubuntu:trusty (shaving off about 60 MB), the resulting debian:latest-based image is a whopping 300 MB larger! To satisfy my curiosity, would you happen to know why?

Base Image Virtual Size
ubuntu:trusty 3.664 GB
debian:latest 3.946 GB

Thanks for your work building this excellent repo.

build error: tlmgr not found

Steps to reproduce:

  1. clone repo
  2. cd into it
  3. sudo docker build -t latex .

expected result

Build completes without error

actual result

Step 9/10 : RUN tlmgr install latexmk
 ---> Running in cfb0b64790c9
/bin/sh: 1: tlmgr: not found
The command '/bin/sh -c tlmgr install latexmk' returned a non-zero code: 127

Path error on Docker for Windows from MINGW

I like to run my things from Bash on Windows, and mingw is a convenient way to do this. However, the dockercmd.sh script fails when used this way, with an error:
invalid mount config for type "bind": invalid mount path:
The reason for this is that mingw makes the results of pwd look unix-ey by converting the standard Windows C:\ into /c/ which, in turn, confuses Docker for Windows. The attached bash script fixes that using sed. It's not beautiful, but it works for me. I don't know if there is a reliable way to detect this issue and use the workaround automatically, but I thought I'd share it in the event that others have the problem.

I have to say, latex in Docker is fab - it has saved me a great deal of faffing around today!

I can't upload the script but I've made a gist and pasted the line below:

#!/bin/bash
docker run --rm -i --net=none -v "`pwd | sed -E 's/^\/(.)\//\1:\//'`":/data blang/latex "$@"

(I didn't seem to need the user stuff on Windows - and I'm not sure what the purpose is of the exec but that's probably just my ignorance...)

Remote repository is newer than local (2017 < 2020)

Related to the issue: #21

I encountered the below issue when I build docker image with Dockerfile.full

tlmgr: Remote repository is newer than local (2017 < 2018)
Cross release updates are only supported with
  update-tlmgr-latest(.sh/.exe) --update
Please see https://tug.org/texlive/upgrade.html for details.

I tried to fix the issue by following the #21 . However, it did not work because texlive/2017 directory structure is not matched as required.

Then, I tried to update tlmgr by a script update-tlmgr-latest(.sh/.exe) --update

My Dockerfile.full is now

FROM blang/latex:ctanbasic
MAINTAINER Benedikt Lang <[email protected]>

RUN wget https://mirrors.ircam.fr/pub/CTAN/systems/texlive/tlnet/update-tlmgr-latest.sh -o update-tlmgr-latest.sh -P /home
RUN bash /home/update-tlmgr-latest.sh -- --upgrade
RUN tlmgr install scheme-full

URGENT | BibTeX and Glossary Problems

Hi
I have my pipeline like this:

image: blang/latex:ctanfull

build:
  script:
    - cd latex_project_folder/
    - latexmk -bibtex -pdf
  artifacts:
    paths:
      - "*.pdf"

But my pipeline fail all time, I think is because the Bitbtex.
Any solution?

How to install palatino font on top of scheme-basic

I am writing a custom Dockerfile based on https://github.com/blang/latex-docker/blob/master/Dockerfile.basic
I have installed following packages and even xetex which installs texlive-fonts-recommended:

RUN tlmgr install latexmk pstricks xcolor xkeyval pgf pst-text pst-grad pst-pdf preview
RUN apt-get install -qy texlive-xetex

but still don't see the palatino font in the fonts directory.
This is a basic font. The full scheme has this font under

# find /usr/local/texlive/2017/texmf-dist/fonts -name palatino
/usr/local/texlive/2017/texmf-dist/fonts/map/dvips/palatino
/usr/local/texlive/2017/texmf-dist/fonts/type1/urw/palatino
/usr/local/texlive/2017/texmf-dist/fonts/vf/urw35vf/palatino
/usr/local/texlive/2017/texmf-dist/fonts/vf/adobe/palatino
/usr/local/texlive/2017/texmf-dist/fonts/tfm/urw35vf/palatino
/usr/local/texlive/2017/texmf-dist/fonts/tfm/adobe/palatino
/usr/local/texlive/2017/texmf-dist/fonts/afm/urw/palatino
/usr/local/texlive/2017/texmf-dist/fonts/afm/adobe/palatino

but a container based on basic theme does not have this font even after the extensions I installed. Can anyone tell me how to get this font? Thanks.

Remote repository is newer than local (2017 < 2018)

Using your instruction to add some packages for example:

FROM blang/latex:ctanbasic
RUN tlmgr install german

results in:

tlmgr: Remote repository is newer than local (2017 < 2018)
Cross release updates are only supported with
  update-tlmgr-latest(.sh/.exe) --update
Please see https://tug.org/texlive/upgrade.html for details.

are there some instructions to workaround the upgrade to the latest version (2018)?

can't write on file `example.pdf'

If I run the twice command in one line, e.g.:

docker run --rm -i --user="$(id -u):$(id -g)" --net=none -v path/to/texfile:/data blang/latex pdflatex example.tex && pdflatex example.tex

The compiler runs once but with the second compilation I get the error message:

! I can't write on file example.pdf'. (Press Enter to retry, or Control-D to exit; default file extension is .pdf')
Please type another file name for output:

Question: How to convert ps to pdf?

Hello,

I just started using this docker image and have a question. I am not able to figure out how to convert the ps to pdf. Online search tells me to use ps2pdf but it looks like this program is not installed in the image. If I try to install anything using apt-get I get errors.

For example, this is what happens when I try to install ghostscript:

root@eea737608448:~# apt-get install ghostscript
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ghostscript

And this is what happens if I try to update the package index:

root@eea737608448:~# apt-get update
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Btw using pdflatex is not an option for me due to the work I am doing. I need to convert a PS to PDF.

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.