You are on page 1of 5

Deploy LATEX as PDF via GitHub and TravisCI

This document will explain how to automatically convert LATEX-documents into PDFs and can
publish them via the services GitHub and TravisCI. The advantage of this method over the local
transformation (Eg via git hooks) and insertion into the repository, among other things are:

• No binary data in the repo


• Check the code at each commit
• Testing of pull requests
• Independence from the local system

Of course, this can be extended to cover the conversion of Markdown by using pandoc.

In the instructions, I assume that it is a public document. Therefore free accounts can be used
at GitHub and TravisCI. There are no costs through the use.

1
Step by step

1. Creation of a git-Repository
• fork this repo or
• create a new repo on GitHub
2. git clone the repo (yes, you could also edit online, but we ignore it this time)
3. for configuration, we use Travis.yml-YAML file (more details below)
• in line 18 is sample code to see howto use Markdown as input format
• in line 22 and 24 is the call of the pdflatex program for converting .tex to .pdf
• in line 27 and 28, the PDF gets converted to a DjVu document
• in line 31 you can see how to transfer the generated data via wget
• the at line 36 defined provider releases stands for GitHub releases
• in line 40 the required oauth string for storing releases is saved, it can be generated
with different commands
– travis setup releases generates the full deploy-block (33-51)
– travis encrypt ***$OAUTH_STRING*** generates only the encrypted part in
row 40
• in lines 44 to 48 the files to upload are defined
4. to activate the repo for Travis builds it may be necessary to refresh the list of repos in
your TravisCI profile.
5. now the LATEX or Markdown-files are to be created (remember to update the filenames in
.travis.yml)
6. at every git push a GNU/Linux VM will be started automatically at TravisCI which
generates the PDF and DjVu files and publishes them as GitHub release. This file was
created exactly this way, each step can be viewed in the TravisCI logfile.

2
Travis Config (YAML)
1 os: linux
2
3 # we use the R VM because i t contains LaTeX and pandoc
4 language: r
5
6 # we need super user p r i v i l e g e s , so we depend on the old t r a v i s−c i i n f r a s t r u c t u r e
7 sudo: required
8
9 # we can i n s t a l l a d d i t i o n a l software
10 apt_packages:
11 # we download pdf2djvu to a l s o generate a djvu f i l e o f our LaTeX source
12 − pdf2djvu
13
14 script:
15 # i f you have a markdown source , you can use pandoc to convert i t to a LaTeX
document
16 − c a t README. md | g r e p −−i n v e r t −match " \ [ \ ! \ [ " i README2. md
17 − c a t README2. md | g r e p −−i n v e r t −match " Howto Deploy LaTeX Documents " i README.
md
18 − pandoc −s −−from=markdown_github −−t o=l a t e x −M t i t l e =" Howto Deploy LaTeX
Documents " −M a u t h o r=" Simon Waldherr " −V geometry : a4paper , margin=2cm −o
README. t e x README. md
19
20 # in the next step we use pdflatex to convert . tex to . pdf
21 # o f course we could use pandoc f o r t h i s also , but pdflatex generates n i c e r PDFs
22 − p d f l a t e x − i n t e r a c t i o n=nonstopmode HowtoDeployLatexDocs−DE. t e x
23 − p d f l a t e x − i n t e r a c t i o n=nonstopmode HowtoDeployLatexDocs−EN. t e x
24 − p d f l a t e x − i n t e r a c t i o n=nonstopmode README. t e x
25
26 # now we convert the pdf f i l e to a much smaller djvu document
27 − p d f 2 d j v u −d 1200 −o HowtoDeployLatexDocs−DE. djvu HowtoDeployLatexDocs−DE. p d f
28 − p d f 2 d j v u −d 1200 −o HowtoDeployLatexDocs−EN. djvu HowtoDeployLatexDocs−EN. p d f
29 after_success:
30 # upload the previously generated pdf f i l e to simonwaldherr . de ( use $UPLOADSECRET
as password )
31 # − wget −−post−f i l e=HowtoDeployLatexDocs−DE. pdf −q −O− " https :// simonwaldherr .
de/pdf /? repo=HowtoDeployLatexDocs&mode=save&key=$UPLOADSECRET&p u l l=
$TRAVIS_PULL_REQUEST"
32
33 deploy:
34
35 # provider r e l e a s e s means GitHub Releases
36 provider: releases
37 api_key:
38
39 # Travis CI public key encrypted GitHub oauth key f o r pushing to GitHub Releases
40 s e c u r e : lY9d0fRtaeW16zSZMRiUf2zX85k1kF4tyW20+/
tLW3oeIXgKuuNHydULmNOqtVomhBwwbhsnciZjx4k/+LQ/
z6OtQIxRFLUvEzwaphCTH5pqof94HeDtjwSP/
NTv5dOn46IGmJ0gGopD5YE5acCpZVdkkyrp36c4rsk4ZG6RjxKy5kQ+
jSIJ93vnT1y4gOlUj1zWh5u7DuTKyvEJHse7iO3WE7KXHQtT7snOQQQ/
wjYcpcCBuYTqqdsSJWoO68yLJosNF32pCBYj/
tMuGDOPNbNFxEmJM3Bx0xkDDuVGtQCVs3p89Q49LBEVzL3bGNLBhsdbu0PHQrsEaHOVlXeIG3wuE0gHtYhiQ8QYaZ3BOSoaLZ
/ x2+
pHdXn2MRSXkwKd2AqAwX3X1guBklVJMpGWM9vKD7f2E8MR8mNWoitiAwHr0ZSHL747TBOviUU8J2w0EeJDBIk4tsJArn8K
+6g /3 Px6xb7wlXcnqimAKlrhh /E+9F s j o /M/9 kItCv+
JkYVmCu08Q6Ps12wZ7ZAi0xKlnCxtKwxQvaR0FWouUUK0e/v7wQwPPxWj5cwzOqXjdykC1V6x18/
mEs=
41
42 # the l i s t o f f i l e s to upload
43 file:
44 − " HowtoDeployLatexDocs−DE. p d f "

3
45 − " HowtoDeployLatexDocs−EN. p d f "
46 − "README. p d f "
47 − " HowtoDeployLatexDocs−DE. djvu "
48 − " HowtoDeployLatexDocs−EN. djvu "
49 skip_cleanup: true
50 on:
51 r e p o : SimonWaldherr /HowTo−Deploy−LaTeX−Documents
.travis.yml

4
Terms of Use

All Rights Reserved. No guarantee for completeness or actuality. All content of this Repository
is licensed under a Creative Commons Attribution - Share Alike 4.0 License International.

You might also like