This tutorial covers how to add metadata and export to both PDF and Word documents!
See the video tutorial ๐บ
This video covers Scientific Articles as well as the material on this page.
๐ Throughout the tutorial, whenever youโre supposed to do something you will see a ๐
Exporting to Word & PDF destroys metadata! ๐ตโ๐ซ
MyST has excellent support for many different journal types and pre-prints. See Scientific PDFs for a list of the templates! We have put years of work into making this great and work for you! ๐
However, when you export to or Microsoft Word, these programs are designed for static, print documents. , for example, is heavily focused on typographic style rather than preserving metadata -- how the page looks is more important than the data.
These choices lead to many challenges of post-processing PDF documents to get out the actual data:
content, authors, citations, cross-references, equations.
This data is critically important for modern, networked science, and powering meta-research of scientific fields!
MyST can also export to other formats directly, such as JATS (Journal Article Tag Suite), which is what most scientific documents end up as when they are published.
By writing in MyST, you can export directly to these formats. Using MyST will also allow you to support interactive, computational media -- things that will never make it to the PDF!!
Help support the transition to FAIR[^fair], open science by preferring web-based formats and publishing your own work on the web.
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:
Next we will see how to change the template as well as how to add additional exports when working with and PDF!
Export to PDF with Latexยถ
To export to PDF with , 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
Install imagemagick
to convert GIFs
imagemagick
to convert GIFsAnimated images are not well supported by the PDF format, and MyST converts the first frame to a static image.
To do the conversion you need to download and install imagemagick
, for example:
# on Mac OS
brew install imagemagick
# on Ubuntu
apt install imagemagick
Emojis arenโt rendered in PDF ๐ญ
We are tracking emoji support, if you think this feature is important and want to help out, we would love your help. ๐ ๐ฆบ ๐ช ๐งฑ ๐ ๐
In the screenshot below we have removed the ๐ง emoji, which ... also works.
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).
Export to ยถ
If you would like to see the 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:
Write scientific articles using MyST Markdown with easy-to-use citations, metadata, and cross-references.
Learn how to use computation and execution with Jupyter in MyST.
Export MyST documents to a Word document, PDF, and !
See an overview of MyST Markdown syntax with inline demos and examples.
Learn how to use MyST in Jupyter Interfaces.
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.
If port
3000
is in use on your machine, an open port will be used instead, follow the link provided in the terminal.By default the
myst clean
command doesnโt remove installed templates or cached web responses; however, the function can with a:myst clean --all
, ormyst 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:If the server stopped, you can restart the server using
myst start
.