Customization Options - ekassos/swift-book-pdf GitHub Wiki

swift-book-pdf offers a range of options to customize your rendering of The Swift Programming Language book.

Output path   Static Badge

By default, swift-book-pdf will save the resulting PDF as swift_book.pdf in the directory it is called from.

You can specify an output path where swift-book-pdf will save the resulting PDF:

swift_book_pdf /path/to/output/directory

In this case, the PDF will be saved at /path/to/output/directory/swift_book.pdf. You can also specify the file name along with the directory:

swift_book_pdf /path/to/output.pdf

Input path   Static Badge

Use the --input-path/-i option to specify a path to the root of a local copy of the swift-book repository. The path should point to the root, i.e. the directory containing the TSPL.docc directory. If not provided, the repository will be cloned from GitHub.

swift_book_pdf -i /path/to/swift-book/

Custom Fonts   Static Badge

swift-book-pdf requires a set of fonts to typeset The Swift Programming Language book. You can use any of the available default options, or specify your own fonts. If you don’t have access to any of the predefined fonts in a font category, or want to specify your own fonts, use the following CLI options to provide swift-book-pdf with the font name to use for a font category:

  • --main
  • --unicode
  • -—mono
  • —-emoji
  • -—header-footer

swift-book-pdf will confirm that your custom fonts are available to LuaTeX before typesetting. Learn how to make your fonts available to the typesetter.

Multiple custom Unicode fonts   Static Badge

You can specify multiple custom Unicode fonts with the --unicode option to cover all glyphs required for typesetting.

Note

If you don’t have access to Arial Unicode MS, you can download and specify the following Noto Sans font families:

swift_book_pdf --unicode "Noto Sans" --unicode "Noto Sans SC" --unicode "Noto Sans KR" --unicode "Noto Sans Thai"

Rendering modes   Static Badge

swift_book_pdf supports two rendering modes:

  1. digital (default): Best for browsing The Swift Programming Language book as a PDF, the digital mode renders internal references and external links in blue hyperlinks.
  2. print: Best for reading through The Swift Programming Language book in print, the print mode includes page numbers for all internal references and complete URLs in footnotes for external links.

Use the --mode option to set your preferred rendering option:

swift_book_pdf /path/to/output.pdf --mode print

Appearance   Static Badge

swift_book_pdf renders The Swift Programming Language book in light mode by default. To render the book in dark mode, use the --dark flag.

swift_book_pdf --dark

Paper sizes   Static Badge

swift_book_pdf supports three paper sizes:

  1. letter (default)
  2. legal
  3. A4

Use the --paper option to set your preferred paper size:

swift_book_pdf --paper legal

Book Gutter   Static Badge

swift_book_pdf renders The Swift Programming Language book with a book gutter by default. To render the book without a gutter, use the --no-gutter flag. This flag also controls whether there is a difference in the header/footer design between odd and even pages.

swift_book_pdf --no-gutter

Number of typesetting passes   Static Badge

This package uses LaTeX to typeset the TSPL book. LaTeX arranges page elements dynamically, so references added in the second pass may shift the page content, and alter the placement of headers and footers. To ensure everything is properly rendered, swift_book_pdf typesets the document four times.

If needed, you can adjust the number of typesets:

swift_book_pdf /path/to/output.pdf --typesets 5

Caution

Only increase the number of typesets if the document has missing references or misaligned headers or footers.

Do not decrease the number of typesets. Given the document's complexity (650+ pages with relative anchors), the extra typesets ensure proper rendering of headers and footers.

Always run at least two typesets. Skipping this may break internal references to other sections.

⚠️ **GitHub.com Fallback** ⚠️