Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: BUILD_LATEX: latex export support #256

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
branches:
only:
- master
env:
- BUILD_LATEX=true
before_install:
- wget https://repo.continuum.io/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh
--output-document miniconda.sh
Expand Down
83 changes: 83 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,87 @@ if [ "${BUILD_DOCX:-}" = "true" ]; then
"$INPUT_PATH"
fi

# Create LaTeX output (if BUILD_LATEX environment variable equals "true")
if [ "${BUILD_LATEX:-}" = "true" ];
then
echo >&2 "Exporting LaTeX manuscript"
mkdir -p output/latex
cd output/latex
pandoc \
--from=markdown \
--to=latex \
--standalone \
--wrap=preserve \
--filter=pandoc-fignos \
--filter=pandoc-eqnos \
--filter=pandoc-tablenos \
--bibliography=../../$BIBLIOGRAPHY_PATH \
--csl=../../$CSL_PATH \
--metadata link-citations=true \
--number-sections \
--metadata=documentclass:ws-procs11x85 \
--resource-path=.:../../content \
--extract-media=images \
--output=manuscript.tex \
../../$INPUT_PATH
echo >&2 "Exporting PDF from LaTeX manuscript"
#if [ -L output/latex/images ]; then rm output/latex/images; fi # if output/latex/images is a symlink, remove it
#ln -s ../../content/images output/latex/images
docker run \
--rm --interactive --tty \
--user "$(id -u):$(id -g)" \
--volume "$(pwd)":/home \
--workdir /home/ \
dockershelf/latex:full \
xelatex manuscript.tex
rm images
fi


CSL_PATH=build/assets/style.csl
BIBLIOGRAPHY_PATH=output/references.json
INPUT_PATH=output/manuscript.md

# sudo apt install librsvg2-bin
# https://anaconda.org/conda-forge/librsvg
# texlive-xelatex texlive-full

pandoc \
--verbose \
--from=markdown \
--wrap=preserve \
--filter=pandoc-eqnos \
--filter=pandoc-tablenos \
--filter=pandoc-fignos \
--number-sections \
--metadata=documentclass:ws-procs11x85 \
--bibliography=../../$BIBLIOGRAPHY_PATH \
--csl=../../$CSL_PATH \
--metadata link-citations=true \
--resource-path=.:../../content \
--pdf-engine=xelatex \
--output=manuscript-pandoc-latex.pdf \
../../$INPUT_PATH

# https://github.com/jgm/pandoc/issues/4721
--pdf-engine-opt=-output-directory=output/latex \
--metadata=documentclass:ws-procs11x85 \


echo >&2 "Build complete"

docker run \
--rm --interactive --tty \
--volume "$(pwd)":/home \
--workdir /home/output/latex \
dockershelf/latex:full \
pandoc --version

docker run \
--rm \
--volume "$(pwd):/data" \
--user "$(id -u):$(id -g)" \
--entrypoint which \
pandoc/latex:2.7.3 \
pandoc

2 changes: 1 addition & 1 deletion build/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- jinja2=2.10
- jsonschema=3.0.1
- pandas=0.24.2
- pandoc=2.7.2
- pandoc=2.7.3
- pango=1.40.14
- pip=19.1
- psutil=5.6.2
Expand Down