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.
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
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/
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.
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"
swift_book_pdf
supports two rendering modes:
-
digital
(default): Best for browsing The Swift Programming Language book as a PDF, thedigital
mode renders internal references and external links in blue hyperlinks. -
print
: Best for reading through The Swift Programming Language book in print, theprint
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
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
swift_book_pdf
supports three paper sizes:
-
letter
(default) legal
A4
Use the --paper
option to set your preferred paper size:
swift_book_pdf --paper legal
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
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.