From f8073ffdb8314ab26471be51a8e8877aea856834 Mon Sep 17 00:00:00 2001 From: Niema Moshiri Date: Thu, 23 Nov 2023 05:12:42 +0000 Subject: [PATCH] Added LaTeX PDF --- .devcontainer/Dockerfile | 2 +- .github/workflows/deploy.yml | 26 +++++- teach_online/_config.yml | 1 + teach_online/_toc.yml | 2 - teach_online/markdown-notebooks.md | 53 ------------- teach_online/notebooks.ipynb | 122 ----------------------------- 6 files changed, 25 insertions(+), 181 deletions(-) delete mode 100644 teach_online/markdown-notebooks.md delete mode 100644 teach_online/notebooks.ipynb diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 81d17c8..be3ce8e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:22.04 MAINTAINER Niema Moshiri RUN apt-get update && apt-get upgrade -y && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y g++ gcc git python3 python3-dev python3-pip && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y g++ gcc git python3 python3-dev python3-pip texlive-fonts-extra texlive-latex-extra texlive-xetex latexmk && \ python3 -m pip install --upgrade --no-cache-dir --ignore-installed pip && \ pip3 install --no-cache-dir --ignore-installed wheel && \ pip3 install --no-cache-dir --ignore-installed jupyter-book && \ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e927dbc..d99d3c2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,10 +37,12 @@ jobs: python-version: 3.8 - name: Install dependencies run: | - pip install -r teach_online/requirements.txt + pip install -r teach_online/requirements.txt && \ + sudo apt-get install -y texlive-fonts-extra texlive-latex-extra texlive-xetex latexmk - name: Build Book run: | - jupyter-book build teach_online + jupyter-book build teach_online && \ + jupyter-book build teach_online --builder pdflatex - name: Setup Pages uses: actions/configure-pages@v3 - name: Upload artifact @@ -50,4 +52,22 @@ jobs: path: 'teach_online/_build/html' - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 \ No newline at end of file + uses: actions/deploy-pages@v2 + - name: Generate release tag + id: tag + run: | + echo "::set-output name=release_tag::$(date +"%Y-%m-%d_%H-%M-%S")" + - name: Publish release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.tag.outputs.release_tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload built PDF to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: teach_online/_build/latex/book.pdf + asset_name: How-to-Teach-Online.pdf + tag: ${{ steps.tag.outputs.release_tag }} + overwrite: true \ No newline at end of file diff --git a/teach_online/_config.yml b/teach_online/_config.yml index de80030..50844db 100644 --- a/teach_online/_config.yml +++ b/teach_online/_config.yml @@ -12,6 +12,7 @@ execute: # Define the name of the latex output file for PDF builds latex: + use_jupyterbook_latex: false latex_documents: targetname: book.tex diff --git a/teach_online/_toc.yml b/teach_online/_toc.yml index 74d5c71..552caf6 100644 --- a/teach_online/_toc.yml +++ b/teach_online/_toc.yml @@ -5,5 +5,3 @@ format: jb-book root: intro chapters: - file: markdown -- file: notebooks -- file: markdown-notebooks diff --git a/teach_online/markdown-notebooks.md b/teach_online/markdown-notebooks.md deleted file mode 100644 index a057a32..0000000 --- a/teach_online/markdown-notebooks.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -jupytext: - formats: md:myst - text_representation: - extension: .md - format_name: myst - format_version: 0.13 - jupytext_version: 1.11.5 -kernelspec: - display_name: Python 3 - language: python - name: python3 ---- - -# Notebooks with MyST Markdown - -Jupyter Book also lets you write text-based notebooks using MyST Markdown. -See [the Notebooks with MyST Markdown documentation](https://jupyterbook.org/file-types/myst-notebooks.html) for more detailed instructions. -This page shows off a notebook written in MyST Markdown. - -## An example cell - -With MyST Markdown, you can define code cells with a directive like so: - -```{code-cell} -print(2 + 2) -``` - -When your book is built, the contents of any `{code-cell}` blocks will be -executed with your default Jupyter kernel, and their outputs will be displayed -in-line with the rest of your content. - -```{seealso} -Jupyter Book uses [Jupytext](https://jupytext.readthedocs.io/en/latest/) to convert text-based files to notebooks, and can support [many other text-based notebook files](https://jupyterbook.org/file-types/jupytext.html). -``` - -## Create a notebook with MyST Markdown - -MyST Markdown notebooks are defined by two things: - -1. YAML metadata that is needed to understand if / how it should convert text files to notebooks (including information about the kernel needed). - See the YAML at the top of this page for example. -2. The presence of `{code-cell}` directives, which will be executed with your book. - -That's all that is needed to get started! - -## Quickly add YAML metadata for MyST Notebooks - -If you have a markdown file and you'd like to quickly add YAML metadata to it, so that Jupyter Book will treat it as a MyST Markdown Notebook, run the following command: - -``` -jupyter-book myst init path/to/markdownfile.md -``` diff --git a/teach_online/notebooks.ipynb b/teach_online/notebooks.ipynb deleted file mode 100644 index fdb7176..0000000 --- a/teach_online/notebooks.ipynb +++ /dev/null @@ -1,122 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Content with notebooks\n", - "\n", - "You can also create content with Jupyter Notebooks. This means that you can include\n", - "code blocks and their outputs in your book.\n", - "\n", - "## Markdown + notebooks\n", - "\n", - "As it is markdown, you can embed images, HTML, etc into your posts!\n", - "\n", - "![](https://myst-parser.readthedocs.io/en/latest/_static/logo-wide.svg)\n", - "\n", - "You can also $add_{math}$ and\n", - "\n", - "$$\n", - "math^{blocks}\n", - "$$\n", - "\n", - "or\n", - "\n", - "$$\n", - "\\begin{aligned}\n", - "\\mbox{mean} la_{tex} \\\\ \\\\\n", - "math blocks\n", - "\\end{aligned}\n", - "$$\n", - "\n", - "But make sure you \\$Escape \\$your \\$dollar signs \\$you want to keep!\n", - "\n", - "## MyST markdown\n", - "\n", - "MyST markdown works in Jupyter Notebooks as well. For more information about MyST markdown, check\n", - "out [the MyST guide in Jupyter Book](https://jupyterbook.org/content/myst.html),\n", - "or see [the MyST markdown documentation](https://myst-parser.readthedocs.io/en/latest/).\n", - "\n", - "## Code blocks and outputs\n", - "\n", - "Jupyter Book will also embed your code blocks and output in your book.\n", - "For example, here's some sample Matplotlib code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from matplotlib import rcParams, cycler\n", - "import matplotlib.pyplot as plt\n", - "import numpy as np\n", - "plt.ion()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Fixing random state for reproducibility\n", - "np.random.seed(19680801)\n", - "\n", - "N = 10\n", - "data = [np.logspace(0, 1, 100) + np.random.randn(100) + ii for ii in range(N)]\n", - "data = np.array(data).T\n", - "cmap = plt.cm.coolwarm\n", - "rcParams['axes.prop_cycle'] = cycler(color=cmap(np.linspace(0, 1, N)))\n", - "\n", - "\n", - "from matplotlib.lines import Line2D\n", - "custom_lines = [Line2D([0], [0], color=cmap(0.), lw=4),\n", - " Line2D([0], [0], color=cmap(.5), lw=4),\n", - " Line2D([0], [0], color=cmap(1.), lw=4)]\n", - "\n", - "fig, ax = plt.subplots(figsize=(10, 5))\n", - "lines = ax.plot(data)\n", - "ax.legend(custom_lines, ['Cold', 'Medium', 'Hot']);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There is a lot more that you can do with outputs (such as including interactive outputs)\n", - "with your book. For more information about this, see [the Jupyter Book documentation](https://jupyterbook.org)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.0" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -}