# Exporting documents
{{app.title}} can convert Markdown documents to XHTML, PDF, and plain text
formats. The application has conveniences for concatenating multiple files
together prior to typesetting.
## Collating
When exporting multiple documents, the application uses an alphanumeric sorting
algorithm to determine the order files are concatenated prior to processing.
This means files are collated in a natural order that honours both alphabetic
and numeric sequences within file names.
Consider the following file names:
Without alphanumeric sorting, `chapter_10.md` would incorrectly appear before
`chapter_2a.md` in a standard alphabetic sort because the computer would
otherwise compare the _text_ `1` vs. `2` rather than the _numbers_ `10` vs. `2`.
## Batch Processing
The application can process a single document or multiple documents. Batch
processing automatically discovers and processes additional files based on the
actively edited file's location and extension.
### Single document export
Export a single document as follows:
1. Open the document to export.
1. Click **File → Export As → PDF** (or type [Ctrl+p]{.kbd}).
1. Select a theme from the drop-down list.
1. Set the output file name.
1. Click **Save**.
The document is exported.
### Multi-document export
Export multiple documents into a single, concatenated file:
1. Open any document in the directory containing files to export.
1. Click **File → Export As → Joined PDF** (or type [Ctrl+Shift+p]{.kbd}).
1. Select a theme from the drop-down list.
1. Set the output file name.
1. Click **Save**.
The application searches recursively through the directory hierarchy starting
from the actively edited file's location. All files with the same extension are
discovered, sorted using the alphanumeric algorithm, and concatenated prior
to exporting.
If the first file processed contains numeric digits in its name, only files
containing numeric digits will be included in the export. If the first file
contains no digits, all matching files will be processed in alphabetical order.
### Chapter ranges
Chapter ranges can be restrict exporting to specific chapters. The range
specification supports several formats:
* Individual chapters: `1,3,5` exports only chapters 1, 3, and 5.
* Range: `1-5` exports chapters 1 through 5, inclusive.
* Starting range: `-5` exports chapters 1 through 5.
* Open-ended range: `3-` exports chapter 3 and all subsequent chapters.
* Multiple ranges: `1,3-7,10-` exports chapter 1, chapters 3 through 7, and chapter 10 onwards.
## XHTML exports
The application produces standards-compliant XHTML documents that can be viewed
in web browsers or further processed. XHTML export features include:
* Document metadata is added to the `<head>` tag as `<meta>` tags
* Diagrams and visualizations are embedded as `<image>` elements
* Cross-references and internal links are preserved
* Mathematical expressions can be output in multiple formats
Mathematical expressions in XHTML exports can be rendered as:
* TeX notation for processing by KaTeX or MathJax; or
* SVG images for direct display without requiring additional libraries.
## PDF exports
PDF exports use the ConTeXt typesetting system to produce high-quality output.
Mathematical expressions are rendered directly by TeX-based software, ensuring
optimal typography for technical content. Before exporting to PDF format, be
sure to have installed the theme pack and ConTeXt. See [@cha:installation] for
details.
## Theme selection
Themes control the visual appearance of exported PDF documents, including
fonts, spacing, colours, and layout. The application includes several predefined
themes, each optimized for different document types and purposes.
Some themes include:
* ***Boschet*** -- Based on Baskerville font with elegant styling.
* ***Handrit*** -- Double-spaced manuscript format using a courier font.
* ***Tarmes*** -- Based on Times Roman font with minimal styling.
* ***TeXomus*** -- A format suitable for technical documentaion.
Theme selection is available during PDF export through the theme drop-down menu
in the export dialog. Each theme may have specific font requirements that must
be installed separately.
Create themes by copying and modifying existing ones (e.g., *TeXomus* or
*Tarmes*).