Skip To Article

Export Static Documents

Export to Markdown, PDF, Word and LaTeX

This tutorial covers how to add metadata and export to both PDF and Word documents!

๐Ÿ›  Throughout the tutorial, whenever youโ€™re supposed to do something you will see a ๐Ÿ› 

Export to Microsoft Wordยถ

๐Ÿ›  In the 01-paper.md add export: docx to the existing frontmatter section:

---
export: docx
---

๐Ÿ›  Run myst build --docx

myst build --docx

The export process will run for any known files with docx specified in the export frontmatter. An equivalent command to export only this specific file is:
myst build 01-paper.md

๐Ÿ“ฌ Performing exports:
   01-paper.md -> _build/exports/paper.docx
๐Ÿ“– Built 01-paper.md in 247 ms.
๐Ÿ” Querying template metadata from https://api.mystmd.org/templates/docx/myst/default
๐Ÿ• Fetching template from https://github.com/myst-templates/docx_default/archive/refs/heads/main.zip
๐Ÿ’พ Saved template to path _build/templates/docx/myst/default
๐Ÿ“„ Exported DOCX in 166 ms, copying to _build/exports/paper.docx

In this case, the default word template was used, resulting in a document formatted like this:

Exporting your article to docx using myst export --docx.

Figureย 1:Exporting your article to docx using myst export --docx.

Next we will see how to change the template as well as how to add additional exports when working with LaTeX\LaTeX and PDF!

Export to PDF with Latexยถ

To export to PDF with LaTeX\LaTeX, first ensure it is installed, see Scientific PDFs for more information.

First, we need to decide which template to export to, for this, we will use the myst templates command, and for example list all the two-column, PDF templates available.

๐Ÿ›  List all two column PDF templates with:
myst templates list --pdf --tag two-column

arXiv (Two Column)       arxiv_two_column
Description: A two column arXiv compatible template
Tags: paper, two-column, preprint, arxiv, bioarxiv, eartharxiv

Volcanica                volcanica
Description: A template for submissions to the Volcanica journal
Tags: paper, journal, two-column, geoscience, earthscience

๐Ÿ›  Then, list the specific information needed for a template:
myst templates list volcanica --pdf

Volcanica                volcanica
ID: tex/myst/volcanica
Version: 1.0.0
Authors: Volcanica
Description: A template for submissions to the Volcanica journal
Tags: paper, journal, two-column, geoscience, earthscience

Parts:
abstract (required) - No description
acknowledgments - No description
author_contributions - No description
data_availability - Links to data repositories, and/or a statement...

Options:
article_type (choice) - Details about different article types...

In addition basic information on the template, the templateโ€™s specific โ€œpartsโ€ and โ€œoptionsโ€ are shown. Some of these may be marked as (required) and be essential for the building the document correctly with the template.

๐Ÿ›  In 01-paper.md create an exports list with docx and pdf formats.

---
exports:
  - format: docx
  - format: pdf
    template: volcanica
    article_type: Report
---

We have added a second export target for pdf and included additional information to specify the template, as well as set the article_type option, which is information we discovered when listing the template above! We also saw this template supports a number of โ€œpartsโ€ including a required abstract part, but as we already added an abstract part earlier in this tutorial, we are good to go.

You can now build the exports with the following command:

๐Ÿ›  Run myst build 01-paper.md

๐Ÿ“ฌ Performing exports:
   01-paper.md -> _build/exports/paper.docx
   01-paper.md -> _build/exports/paper.pdf
๐ŸŒ  Converting 3 GIF images to PNG using imagemagick
๐Ÿ“– Built 01-paper.md in 257 ms.
๐Ÿ“„ Exported DOCX in 205 ms, copying to _build/exports/paper.docx
๐Ÿ“‘ Exported TeX in 5.11 ms, copying to _build/temp/myst8BVu1k/paper.tex
๐Ÿ–จ Rendering PDF to _build/temp/mystvUibhD/paper.pdf
๐Ÿ“„ Exported PDF in 9.3 s, copying to _build/exports/paper.pdf

You can now see your two-column PDF in a submission ready format for the journal (check the _build/exports folder). It is very easy to change the template to a different format -- just change the template: field in the frontmatter! Notice also that the PDF has converted dynamic images to a static alternative (e.g. GIFs are now PNGs).

Exporting the article to a two column PDF with appropriate metadata to submit to a Journal.

Figureย 2:Exporting the article to a two column PDF with appropriate metadata to submit to a Journal.

Export to LaTeX\LaTeXยถ

If you would like to see the LaTeX\LaTeX source, you can look in the _build/temp directory, or you can update the

๐Ÿ›  In 01-paper.md: replace format: pdf with format: tex. Specify the output location as a zip file.

1
2
3
4
5
6
7
8
---
exports:
  - format: docx
  - format: tex
    template: volcanica
    article_type: Report
    output: arxiv.zip
---

๐Ÿ›  Run myst build 01-paper.md

You should see these two additional lines:

๐Ÿ“‘ Exported TeX in 4.87 ms, copying to _build/exports/paper_tex/paper.tex
๐Ÿค Zipping tex outputs to arxiv.zip

Without specifying the output: location, this will copy the unzipped contents into the _build/exports folder along with all other exports. Creating a zip file can be helpful when directly submitted to the arXiv or a journal!

Export to Markdownยถ

๐Ÿ›  In 01-paper.md create an exports list with docx, pdf and md formats.

---
exports:
  - format: docx
  - format: pdf
    template: volcanica
    article_type: Report
  - format: md
---

You can now build the exports with the following command:

๐Ÿ›  Run myst build 01-paper.md

๐Ÿ“ฌ Performing exports:
   01-paper.md -> _build/exports/paper.docx
   01-paper.md -> _build/exports/paper.pdf
   01-paper.md -> _build/exports/paper.md
๐ŸŒ  Converting 3 GIF images to PNG using imagemagick
๐Ÿ“– Built 01-paper.md in 257 ms.
๐Ÿ“„ Exported DOCX in 205 ms, copying to _build/exports/paper.docx
๐Ÿ“‘ Exported TeX in 5.11 ms, copying to _build/temp/myst8BVu1k/paper.tex
๐Ÿ–จ Rendering PDF to _build/temp/mystvUibhD/paper.pdf
๐Ÿ“„ Exported PDF in 9.3 s, copying to _build/exports/paper.pdf
๐Ÿ“„ Exported MD in 205 ms, copying to _build/exports/paper.md

Conclusion ๐Ÿฅณยถ

Thatโ€™s it for this quickstart tutorial!!

Check out the following tutorials for more step-by-step guides:

Footnotesยถ
  1. If you arenโ€™t familiar with git, it isnโ€™t required for this tutorial, you can download the zip file with the contents from the quickstart repository.

  2. If port 3000 is in use on your machine, an open port will be used instead, follow the link provided in the terminal.

  3. By default the myst clean command doesnโ€™t remove installed templates or cached web responses; however, the function can with a:
    myst clean --all, or
    myst clean --templates --cache.

    Before deleting any folders myst will confirm what is going to happen, or you can bypass this confirmation with the -y option. For example:

  4. If the server stopped, you can restart the server using myst start.

MyST MarkdownMyST Markdown
Community-driven tools for the future of technical communication and publication, part of Jupyter.