Skip to article frontmatterSkip to article content

Jupyter Book 2 currently supports two primary ways to export your book as a PDF: LaTeX or Typst. Both are powerful tools for generating high-quality PDFs, but they differ in several key aspects (additional advantages and disadvantages described here):

FeatureTypstLaTeX
Ease of UseModern syntax, easier to learn and useSteeper learning curve, more complex syntax
SpeedFast compilationSlower compilation, especially for large docs
CustomizationTemplates are easy to modifyHighly customizable, but requires more effort
IntegrationDesigned for MyST Markdown and Jupyter BookWidely supported in academic publishing
CommunityGrowing, newer ecosystemLarge, established community
FeaturesGood support for math, figures, and tablesExtensive support for math, figures, tables, and packages
Output QualityHigh-quality, modern lookProfessional, traditional academic look

In short: choose Typst for simplicity and speed, or LaTeX for advanced customization and compatibility with academic standards.

Below we provide the screen shots of the PDF output using Typst (left) using the plain_typst_template and LaTeX (right) using the plain_latex_template.

Comparison of PDF output using Typst (left) and LaTeX (right) using both the plain book template.

Figure 1:Comparison of PDF output using Typst (left) and LaTeX (right) using both the plain book template.

You can specify the output template, download the template and tweak to match your preferences. We won’t go into detail here, but you can find more information in the MyST Markdown documentations.

Choosing Typst or LaTeX

When starting your own project, consider whether a PDF output is desired. If so, consider the interactive elements that may be included and wether or not, some functionality and not all multimedia are supported in a PDF. For instance, a *.gif file cannot be included in a PDF. JB2 is thoughtful in this by choosing the best possible alternative if multiple files with the same name but different extensions are present: gif is chosen over png, png over jpg. Rather than specifying the extension, you can just use the file name and an asterisk, e.g. ![figure](figures/mystvstex.*).

For YouTube clips and online interactive materials embedded through iframes, you can make use of plugins. See for instance the iframe-to-thumbnail plugin. This plugin replaces the iframe with a thumbnail image that links to the original content as well as a QR code and a link in the caption.

Additional Considerations

WIP

Excluding and including sections for PDF[1]

If you need to inject some LaTeX or Typst-specific content into their respective exports, you may use the {raw:latex} or {raw:typst} role and directive. For example, to insert a new page in Typst with two columns:

Or,

+++ { "page-break": true } for a page break.

The content in these directives and roles will be included exactly as written in their respective exports, and will be ignored in all other contexts.

You may use block metadata to insert page breaks into your PDF or docx export with +++ { "page-break": true }. This will have no impact on your MyST site build nor other static exports that disregard “pages” (e.g. JATS).

Typst

When exporting to Typst format, you can provide Typst-specific math content using the typst option. This allows you to use native Typst syntax instead of relying on tex-to-typst conversion, which may give incorrect results.

Example with typst argument in a math block: https://mystmd.org/guide/math#typst-math

Footnotes
  1. Directly copied from the official Myst documentation.