From b39a5e39baad7da86119fbd885432a0ec95acbce Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 6 May 2021 10:50:44 +1000 Subject: [PATCH 1/2] [pdflatex] Enable book style build of PDF via LaTeX --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ .github/workflows/publish.yml | 20 ++++++++++++++++++++ environment.yml | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64de906d0..75ae07778 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,17 @@ jobs: python-version: 3.8 environment-file: environment.yml activate-environment: quantecon + - name: Install latex dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y \ + texlive-latex-recommended \ + texlive-latex-extra \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-xetex \ + latexmk \ + xindy - name: Display Conda Environment Versions shell: bash -l {0} run: conda list @@ -32,6 +43,18 @@ jobs: shell: bash -l {0} run: | jb build -W --keep-going lectures --path-output ./ + - name: Build Download Notebooks (sphinx-tojupyter) + shell: bash -l {0} + run: | + jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter + mkdir -p _build/html/_notebooks + cp -u _build/jupyter/*.ipynb _build/html/_notebooks + - name: Build PDF from LaTeX + shell: bash -l {0} + run: | + jb build lectures --builder pdflatex --path-output ./ -n --keep-going + mkdir _build/html/_pdf + cp -u _build/latex/*.pdf _build/html/_pdf - name: Save Build as Artifact uses: actions/upload-artifact@v1 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0ce6e86e9..e3e34f8fb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,6 +19,17 @@ jobs: python-version: 3.8 environment-file: environment.yml activate-environment: quantecon + - name: Install latex dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y \ + texlive-latex-recommended \ + texlive-latex-extra \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-xetex \ + latexmk \ + xindy - name: Display Conda Environment Versions shell: bash -l {0} run: conda list @@ -43,6 +54,15 @@ jobs: run: | mkdir _build/html/_notebooks cp _build/jupyter/*.ipynb _build/html/_notebooks + - name: Build PDF from LaTeX + shell: bash -l {0} + run: | + jb build lectures --builder pdflatex --path-output ./ -n --keep-going + - name: Copy LaTeX PDF for GH-PAGES + shell: bash -l {0} + run: | + mkdir _build/html/_pdf + cp _build/latex/*.pdf _build/html/_pdf - name: Deploy website to gh-pages uses: peaceiris/actions-gh-pages@v3 with: diff --git a/environment.yml b/environment.yml index 20e0e0d64..c645f3bc5 100644 --- a/environment.yml +++ b/environment.yml @@ -8,7 +8,7 @@ dependencies: - pip: - jupyter-book - sphinx-multitoc-numbering - - quantecon-book-theme==0.1.7 + - quantecon-book-theme==0.2.0 - sphinx-tojupyter - sphinxext-rediraffe - sphinx-exercise From 822fbf0960b0b89b4562db1b7185f94c6e767855 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 6 May 2021 13:12:22 +1000 Subject: [PATCH 2/2] build assets prior to html for quantecon-book-theme --- .github/workflows/ci.yml | 14 ++++++++------ .github/workflows/publish.yml | 24 +++++++++++++----------- lectures/_config.yml | 4 ++++ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75ae07778..aabb47991 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,22 +39,24 @@ jobs: branch: main name: build-cache path: _build - - name: Build HTML + # Build Assets (Download Notebooks and PDF via LaTeX) + - name: Build PDF from LaTeX shell: bash -l {0} run: | - jb build -W --keep-going lectures --path-output ./ + jb build lectures --builder pdflatex --path-output ./ -n --keep-going + mkdir -p _build/html/_pdf + cp -u _build/latex/*.pdf _build/html/_pdf - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} run: | jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter mkdir -p _build/html/_notebooks cp -u _build/jupyter/*.ipynb _build/html/_notebooks - - name: Build PDF from LaTeX + # Build HTML (Website) + - name: Build HTML shell: bash -l {0} run: | - jb build lectures --builder pdflatex --path-output ./ -n --keep-going - mkdir _build/html/_pdf - cp -u _build/latex/*.pdf _build/html/_pdf + jb build -W --keep-going lectures --path-output ./ - name: Save Build as Artifact uses: actions/upload-artifact@v1 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e3e34f8fb..101639392 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,10 +36,16 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - - name: Build HTML + # Build Assets (Download Notebooks and PDF via LaTeX) + - name: Build PDF from LaTeX shell: bash -l {0} run: | - jb build lectures --path-output ./ + jb build lectures --builder pdflatex --path-output ./ -n --keep-going + - name: Copy LaTeX PDF for GH-PAGES + shell: bash -l {0} + run: | + mkdir _build/html/_pdf + cp _build/latex/*.pdf _build/html/_pdf - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} run: | @@ -52,17 +58,13 @@ jobs: - name: Copy Download Notebooks for GH-PAGES shell: bash -l {0} run: | - mkdir _build/html/_notebooks - cp _build/jupyter/*.ipynb _build/html/_notebooks - - name: Build PDF from LaTeX - shell: bash -l {0} - run: | - jb build lectures --builder pdflatex --path-output ./ -n --keep-going - - name: Copy LaTeX PDF for GH-PAGES + mkdir -p _build/html/_notebooks + cp -u _build/jupyter/*.ipynb _build/html/_notebooks + # Build HTML (Website) + - name: Build HTML shell: bash -l {0} run: | - mkdir _build/html/_pdf - cp _build/latex/*.pdf _build/html/_pdf + jb build lectures --path-output ./ - name: Deploy website to gh-pages uses: peaceiris/actions-gh-pages@v3 with: diff --git a/lectures/_config.yml b/lectures/_config.yml index 27a984df0..a8a2f7f71 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -13,6 +13,10 @@ bibtex_bibfiles: html: baseurl: https://python.quantecon.org/ +latex: + latex_documents: + targetname: quantecon-python.tex + sphinx: extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter] config: