diff --git a/openspec/changes/add-cover-letter-pdf-conversion/proposal.md b/openspec/changes/add-cover-letter-pdf-conversion/proposal.md new file mode 100644 index 0000000..0abbb97 --- /dev/null +++ b/openspec/changes/add-cover-letter-pdf-conversion/proposal.md @@ -0,0 +1,24 @@ +# Add Cover Letter PDF Conversion + +## Why + +The current system generates cover letters in markdown format, but many job applications require PDF submissions. This creates a gap in the workflow where users must manually convert their generated cover letters to PDF format using external tools. Adding native PDF conversion will complete the job application workflow by providing professionally formatted Swiss-style business letters ready for submission. + +## What Changes + +- Add new slash command `/convert-cover-letter` for converting markdown cover letters to PDF +- Implement environment validation to check for required tools (Pandoc, LaTeX) +- Create Swiss letter template (scrlttr2) with proper formatting for Swiss business correspondence +- Support automatic extraction of metadata from markdown frontmatter (sender, recipient, date, subject, etc.) +- Generate PDF output in the same directory as the markdown source +- Provide helpful error messages and setup guidance when tools are missing + +## Impact + +- **Affected specs**: New capability `cover-letter-pdf-conversion` +- **Affected code**: + - New slash command: `src/.claude/commands/convert-cover-letter.md` + - New LaTeX template: `src/.claude/templates/swiss-letter.tex` + - Test environment: Will need to update test directory with new command +- **Dependencies**: Requires Pandoc and LaTeX (texlive-latex-base, texlive-lang-german) to be installed on the user's system +- **User workflow**: Completes step 7 "Generate PDFs" in the project workflow (see project.md:51) diff --git a/openspec/changes/add-cover-letter-pdf-conversion/specs/cover-letter-pdf-conversion/spec.md b/openspec/changes/add-cover-letter-pdf-conversion/specs/cover-letter-pdf-conversion/spec.md new file mode 100644 index 0000000..fee1d23 --- /dev/null +++ b/openspec/changes/add-cover-letter-pdf-conversion/specs/cover-letter-pdf-conversion/spec.md @@ -0,0 +1,144 @@ +# Cover Letter PDF Conversion Specification + +## ADDED Requirements + +### Requirement: Cover Letter Detection + +The system SHALL detect the presence of a valid cover letter markdown file in the current directory before attempting conversion. + +#### Scenario: Valid cover letter found +- **WHEN** a file named `cover-letter.md` exists in the current directory +- **AND** the file contains valid markdown with frontmatter +- **THEN** the system proceeds with conversion + +#### Scenario: No cover letter found +- **WHEN** no `cover-letter.md` file exists in the current directory +- **THEN** the system displays an error message indicating no cover letter was found +- **AND** suggests running `/write-cover-letter` first + +#### Scenario: Invalid cover letter format +- **WHEN** `cover-letter.md` exists but lacks required frontmatter fields +- **THEN** the system displays an error listing the missing required fields +- **AND** provides an example of correct frontmatter structure + +### Requirement: Environment Validation + +The system SHALL validate that all required tools are installed before attempting conversion. + +#### Scenario: All tools available +- **WHEN** the user runs `/convert-cover-letter` +- **AND** Pandoc is installed and accessible +- **AND** LaTeX (pdflatex) is installed and accessible +- **THEN** the system proceeds with conversion + +#### Scenario: Pandoc missing +- **WHEN** the user runs `/convert-cover-letter` +- **AND** Pandoc is not installed +- **THEN** the system displays installation instructions for Pandoc +- **AND** provides platform-specific commands (apt, brew, etc.) +- **AND** stops the conversion process + +#### Scenario: LaTeX missing +- **WHEN** the user runs `/convert-cover-letter` +- **AND** Pandoc is installed but LaTeX is not installed +- **THEN** the system displays installation instructions for LaTeX packages +- **AND** lists required packages (texlive-latex-base, texlive-lang-german, texlive-latex-extra) +- **AND** stops the conversion process + +### Requirement: Swiss Letter Formatting + +The system SHALL generate PDFs using Swiss business letter standards (scrlttr2 with SN configuration). + +#### Scenario: Address window positioning +- **WHEN** converting a cover letter to PDF +- **THEN** the recipient address is positioned according to Swiss Norm (SN) +- **AND** fits within standard Swiss envelope window dimensions + +#### Scenario: Swiss German formatting +- **WHEN** the cover letter content contains German text +- **THEN** Swiss German hyphenation rules are applied +- **AND** date formatting follows Swiss convention (DD.MM.YYYY) +- **AND** number formatting uses Swiss conventions + +#### Scenario: Professional layout +- **WHEN** converting to PDF +- **THEN** the output includes proper margins for Swiss business letters +- **AND** sender information is positioned in the header +- **AND** contact information (phone, email) is formatted with hyperlinks + +### Requirement: Metadata Extraction + +The system SHALL extract metadata from markdown frontmatter and map it to LaTeX variables. + +#### Scenario: Complete frontmatter +- **WHEN** the markdown contains all required frontmatter fields +- **THEN** sender information (name, street, city, phone, email) is extracted +- **AND** recipient address lines are extracted +- **AND** letter details (date, subject, opening, closing, signature) are extracted +- **AND** optional enclosures list is extracted if present + +#### Scenario: Minimal frontmatter +- **WHEN** the markdown contains only required frontmatter fields +- **THEN** the system uses default values for optional fields +- **AND** generates a valid PDF without enclosures section + +#### Scenario: Invalid frontmatter structure +- **WHEN** the frontmatter cannot be parsed as YAML +- **THEN** the system displays a clear error message +- **AND** points to the specific syntax error if possible + +### Requirement: PDF Generation + +The system SHALL convert the markdown body to PDF using Pandoc with the Swiss letter template. + +#### Scenario: Successful conversion +- **WHEN** all prerequisites are met +- **AND** the markdown is valid +- **THEN** the system generates a PDF file in the same directory +- **AND** names the file `cover-letter.pdf` +- **AND** displays a success message with the file path + +#### Scenario: Conversion with enclosures +- **WHEN** the frontmatter includes an `enclosures` list +- **THEN** the generated PDF includes an enclosures section after the closing +- **AND** lists each enclosure item on a separate line + +#### Scenario: LaTeX compilation error +- **WHEN** Pandoc generates LaTeX but pdflatex fails to compile +- **THEN** the system displays the LaTeX error output +- **AND** suggests checking for special characters or formatting issues +- **AND** preserves the intermediate .tex file for debugging + +### Requirement: Template Management + +The system SHALL provide and maintain the Swiss letter LaTeX template. + +#### Scenario: Template availability +- **WHEN** the `/convert-cover-letter` command is run +- **THEN** the system uses the template at `src/.claude/templates/swiss-letter.tex` +- **AND** passes it to Pandoc via the `--template` option + +#### Scenario: Template customization +- **WHEN** users need to modify letter styling +- **THEN** they can edit the swiss-letter.tex template +- **AND** changes apply to all subsequent conversions +- **AND** the template includes comments explaining customizable sections + +### Requirement: Error Handling + +The system SHALL provide clear, actionable error messages for common failure scenarios. + +#### Scenario: File permission error +- **WHEN** the PDF cannot be written due to permissions +- **THEN** the system displays a permission error message +- **AND** suggests checking directory write permissions + +#### Scenario: Disk space error +- **WHEN** PDF generation fails due to insufficient disk space +- **THEN** the system displays a disk space error +- **AND** suggests freeing up space or choosing a different output location + +#### Scenario: Process timeout +- **WHEN** LaTeX compilation takes longer than 30 seconds +- **THEN** the system displays a timeout warning +- **AND** suggests checking for complex formatting or large embedded content diff --git a/openspec/changes/add-cover-letter-pdf-conversion/tasks.md b/openspec/changes/add-cover-letter-pdf-conversion/tasks.md new file mode 100644 index 0000000..792cb76 --- /dev/null +++ b/openspec/changes/add-cover-letter-pdf-conversion/tasks.md @@ -0,0 +1,58 @@ +# Implementation Tasks + +## 1. Template Creation +- [ ] 1.1 Create Swiss letter LaTeX template at `src/.claude/templates/swiss-letter.tex` +- [ ] 1.2 Configure scrlttr2 with Swiss Norm (SN) settings +- [ ] 1.3 Add proper encoding (UTF-8, T1 font encoding) for German characters +- [ ] 1.4 Implement hyperlinks for email addresses +- [ ] 1.5 Add Pandoc variable placeholders for all frontmatter fields +- [ ] 1.6 Add inline comments explaining customizable sections +- [ ] 1.7 Test template with sample data to ensure proper formatting + +## 2. Slash Command Implementation +- [ ] 2.1 Create command file at `src/.claude/commands/convert-cover-letter.md` +- [ ] 2.2 Implement cover letter file detection logic +- [ ] 2.3 Implement environment validation checks (Pandoc, LaTeX) +- [ ] 2.4 Add platform-specific installation instructions +- [ ] 2.5 Implement frontmatter parsing and validation +- [ ] 2.6 Build Pandoc command with correct arguments +- [ ] 2.7 Execute conversion and capture output +- [ ] 2.8 Implement error handling for common failure scenarios +- [ ] 2.9 Add success message with file path output + +## 3. Error Handling & Messaging +- [ ] 3.1 Create clear error message for missing cover letter +- [ ] 3.2 Create error message for missing required frontmatter fields +- [ ] 3.3 Create installation guide for Pandoc (apt, brew, winget) +- [ ] 3.4 Create installation guide for LaTeX packages +- [ ] 3.5 Add error handling for YAML parsing failures +- [ ] 3.6 Add error handling for LaTeX compilation failures +- [ ] 3.7 Add error handling for file permission issues +- [ ] 3.8 Add timeout handling for long-running conversions + +## 4. Testing +- [ ] 4.1 Test with complete frontmatter and body content +- [ ] 4.2 Test with minimal required frontmatter only +- [ ] 4.3 Test with optional enclosures list +- [ ] 4.4 Test with missing cover-letter.md file +- [ ] 4.5 Test with invalid YAML frontmatter +- [ ] 4.6 Test with missing required frontmatter fields +- [ ] 4.7 Test with special characters (ä, ö, ü, ß) in German text +- [ ] 4.8 Test environment validation when Pandoc is missing +- [ ] 4.9 Test environment validation when LaTeX is missing +- [ ] 4.10 Test error handling for file permission issues +- [ ] 4.11 Verify Swiss address window positioning with printed output +- [ ] 4.12 Verify date formatting follows Swiss convention + +## 5. Documentation +- [ ] 5.1 Document required frontmatter structure +- [ ] 5.2 Document system requirements (Pandoc, LaTeX) +- [ ] 5.3 Add example cover-letter.md with complete frontmatter +- [ ] 5.4 Document troubleshooting steps for common errors +- [ ] 5.5 Add template customization guide + +## 6. Integration +- [ ] 6.1 Update test directory with new command +- [ ] 6.2 Update test directory with new template +- [ ] 6.3 Ensure compatibility with existing cover letter generation +- [ ] 6.4 Verify workflow integration (step 7 in project.md) diff --git a/src/.claude/commands/convert-cover-letter.md b/src/.claude/commands/convert-cover-letter.md new file mode 100644 index 0000000..e8aab1f --- /dev/null +++ b/src/.claude/commands/convert-cover-letter.md @@ -0,0 +1,504 @@ +Convert a markdown cover letter to a professionally formatted PDF using Swiss business letter standards. + +# Instructions + +You are converting a markdown cover letter to PDF format. The output will follow Swiss business letter standards (scrlttr2 with Swiss Norm) for proper formatting and address window positioning. + +## Step 1: Check for Cover Letter + +### Verify File Exists + +1. Check if `cover-letter.md` exists in the current directory +2. If file exists → proceed to Step 2 +3. If file does not exist → show error and stop + +### Error: Cover Letter Not Found + +``` +❌ Cover letter not found + +Could not find cover-letter.md in the current directory. + +Please either: +1. Navigate to an application folder containing a cover letter: + cd applications/pending/[application-folder]/ + /convert-cover-letter + +2. Generate a cover letter first: + /write-cover-letter + +Current directory: [show current working directory] +``` +STOP. Do not proceed. + +## Step 2: Environment Validation + +**CRITICAL**: Check for required tools before attempting conversion. + +Show progress: `🔍 Checking system requirements...` + +### Check for Pandoc + +Run: `which pandoc` or `pandoc --version` + +**If Pandoc is NOT installed:** + +``` +❌ Pandoc not found + +Pandoc is required for PDF conversion but is not installed on your system. + +## Installation Instructions: + +### Ubuntu/Debian: +sudo apt update +sudo apt install pandoc + +### macOS (Homebrew): +brew install pandoc + +### Arch Linux: +sudo pacman -S pandoc + +### Windows: +winget install pandoc + +### Other Systems: +Download from: https://pandoc.org/installing.html + +--- + +After installation, run: pandoc --version +Then try /convert-cover-letter again. +``` +STOP. Do not proceed with conversion. + +**If Pandoc is installed:** +Show progress: `✓ Pandoc found (version X.X.X)` + +### Check for LaTeX (pdflatex) + +Run: `which pdflatex` or `pdflatex --version` + +**If LaTeX is NOT installed:** + +``` +❌ LaTeX not found + +LaTeX (pdflatex) is required for PDF generation but is not installed. + +## Installation Instructions: + +### Ubuntu/Debian: +sudo apt update +sudo apt install texlive-latex-base texlive-latex-extra + +# For German language support (recommended for proper labels): +sudo apt install texlive-lang-german + +### macOS (Homebrew): +brew install texlive +# Note: This is a large download (~4GB). Alternative: MacTeX from https://www.tug.org/mactex/ + +### Arch Linux: +sudo pacman -S texlive-core texlive-latexextra texlive-langgerman + +### Windows: +# Install MiKTeX from: https://miktex.org/download +# Or TeX Live from: https://www.tug.org/texlive/ + +--- + +**Required packages**: +- texlive-latex-base (core LaTeX) +- texlive-latex-extra (KOMA-Script including scrlttr2) + +**Recommended packages**: +- texlive-lang-german (German labels: "Telefon" instead of "Phone", "Anlagen" instead of "encl") + +After installation, run: pdflatex --version +Then try /convert-cover-letter again. +``` +STOP. Do not proceed with conversion. + +**If LaTeX is installed:** +Show progress: `✓ LaTeX found (pdfTeX X.X.X)` + +**All prerequisites met:** +Show progress: `✅ All requirements satisfied` + +## Step 3: Read and Validate Cover Letter + +Show progress: `📄 Reading cover-letter.md...` + +### Read File Content + +1. Read the entire `cover-letter.md` file +2. Separate frontmatter (YAML between `---` delimiters) from body content +3. Parse the YAML frontmatter +4. Extract the markdown body (everything after the second `---`) + +### Validate Frontmatter Structure + +**Required fields:** +- `from.name` - Sender's full name +- `from.street` - Sender's street address +- `from.city` - Sender's city with postal code (e.g., "CH-8000 Zürich") +- `to` - Array of recipient address lines (at least 2 lines) +- `subject` - Letter subject line +- `opening` - Letter opening salutation +- `closing` - Letter closing phrase +- `signature` - Name for signature + +**Optional fields:** +- `from.phone` - Sender's phone number +- `from.email` - Sender's email address +- `date` - Letter date (defaults to current date if missing) +- `enclosures` - Array of enclosure items + +### Error: Invalid YAML + +**If frontmatter cannot be parsed as YAML:** + +``` +❌ Invalid frontmatter format + +The YAML frontmatter in cover-letter.md could not be parsed. + +Error details: [specific YAML parsing error] + +Please check that: +1. Frontmatter is enclosed between --- markers +2. YAML syntax is correct (proper indentation, colons, hyphens) +3. No special characters are unescaped + +Example of correct frontmatter: +--- +from: + name: Max Mustermann + street: Musterstrasse 42 + city: CH-8000 Zürich + phone: +41 44 123 45 67 + email: max.mustermann@example.ch +to: + - Firma AG + - Personalabteilung + - Hauptstrasse 100 + - CH-3000 Bern +subject: Bewerbung als Software-Entwickler +opening: Sehr geehrte Damen und Herren +closing: Freundliche Grüsse +signature: Max Mustermann +--- +``` +STOP. + +### Error: Missing Required Fields + +**If any required fields are missing:** + +``` +❌ Incomplete frontmatter + +Your cover letter is missing required fields in the frontmatter: + +Missing fields: +[List each missing field with description] + +Required frontmatter structure: +--- +from: + name: [Your full name] + street: [Your street address] + city: [Your city with postal code] + phone: [Your phone] (optional) + email: [Your email] (optional) +to: + - [Company name] + - [Department or contact person] + - [Street address] + - [City with postal code] +date: [DD.MM.YYYY] (optional, defaults to today) +subject: [Letter subject] +opening: [Greeting, e.g., "Sehr geehrte Damen und Herren"] +closing: [Sign-off, e.g., "Freundliche Grüsse"] +signature: [Your name for signature] +enclosures: (optional) + - [Document 1] + - [Document 2] +--- + +[Body content follows] +``` +STOP. + +**If all required fields are present:** +Show progress: `✓ Frontmatter validated` + +## Step 4: Convert to PDF + +Show progress: `🔄 Converting to PDF...` + +### Prepare Pandoc Command + +Build the conversion command: + +```bash +pandoc cover-letter.md \ + --from markdown \ + --to latex \ + --template=[path-to-swiss-letter.tex] \ + --pdf-engine=pdflatex \ + --output=cover-letter.pdf +``` + +**Template path**: Use the template at `src/.claude/templates/swiss-letter.tex` relative to the framework root. + +### Execute Conversion + +1. Run the Pandoc command +2. Capture stdout and stderr +3. Check exit code + +### Handle Conversion Errors + +**If pdflatex fails to compile:** + +``` +❌ PDF compilation failed + +LaTeX encountered an error while compiling your cover letter. + +Error output: +[Show relevant error lines from stderr] + +Common causes: +1. Special characters not properly escaped (e.g., &, %, $, #, _) +2. Formatting issues in the markdown body +3. Very long lines or complex formatting +4. Missing LaTeX packages + +Troubleshooting: +1. Check for special characters in your cover letter text +2. Try simplifying complex formatting +3. Verify that all required LaTeX packages are installed: + - texlive-latex-base + - texlive-lang-german + - texlive-latex-extra + +The intermediate .tex file has been preserved at: [path-to-.tex-file] +You can inspect this file to identify the issue. + +Need help? Share the error output above for assistance. +``` +STOP. + +**If file permissions error:** + +``` +❌ Permission denied + +Could not write cover-letter.pdf to the current directory. + +Please check: +1. You have write permissions in: [current directory] +2. The file is not open in another application +3. Sufficient disk space is available + +Current directory permissions: +[Show output of: ls -ld .] +``` +STOP. + +**If disk space error:** + +``` +❌ Insufficient disk space + +Could not create PDF file due to insufficient disk space. + +Please: +1. Free up disk space +2. Or choose a different output location + +Available disk space: +[Show output of: df -h .] +``` +STOP. + +**If conversion times out (> 30 seconds):** + +``` +❌ Conversion timeout + +PDF generation took longer than expected (> 30 seconds). + +This might indicate: +1. Very long or complex document +2. LaTeX compilation stuck on an error +3. System resource constraints + +Please try: +1. Simplifying the cover letter content +2. Checking system resources +3. Running pdflatex manually for debugging + +Manual debugging: +pandoc cover-letter.md --from markdown --to latex --template=[template-path] -o cover-letter.tex +pdflatex cover-letter.tex +``` +STOP. + +## Step 5: Success Output + +**If conversion succeeded:** + +``` +✅ PDF generated successfully: cover-letter.pdf + +## Conversion Summary: + +📄 Input: cover-letter.md +📑 Output: cover-letter.pdf +📐 Format: Swiss business letter (scrlttr2, Swiss Norm) + +## Document Details: + +✓ Sender: [from.name] +✓ Recipient: [to[0]] (first line of address) +✓ Subject: [subject] +✓ Date: [date] +$if(enclosures)$ +✓ Enclosures: [N] items +$endif$ + +## Formatting Applied: + +- Swiss address window positioning (compatible with standard Swiss envelopes) +- Swiss German hyphenation and spelling +- Professional business letter layout +- Clickable email links +- Proper margins and spacing + +## Next Steps: + +1. **Review the PDF**: Open cover-letter.pdf and verify: + - All information is correct + - Layout looks professional + - Address fits in envelope window (if printing) + - No formatting issues or typos + +2. **Print test** (if mailing): + - Print the PDF + - Check address position with a Swiss envelope window + - Verify text is clear and readable + +3. **Digital submission**: + - Ready to attach to email applications + - Filename: cover-letter.pdf + +4. **Rename for organization** (optional): + - Consider: [YourName]_Cover_Letter_[Company]_[Date].pdf + - Example: Max_Mustermann_Cover_Letter_TechCorp_2025-11-03.pdf + +--- + +**Tip**: The generated PDF follows Swiss standards (SN) for business correspondence. +The address positioning is optimized for standard Swiss envelope windows. +``` + +## Step 6: Cleanup (Optional) + +Pandoc may create intermediate files during conversion: +- `cover-letter.tex` - Intermediate LaTeX file +- `cover-letter.aux`, `cover-letter.log` - LaTeX compilation files + +**If conversion was successful**: These files can be deleted (they're not needed) +**If conversion failed**: Preserve the .tex file for debugging + +## Additional Features + +### Custom Template + +Users can customize the Swiss letter template: + +**Location**: `src/.claude/templates/swiss-letter.tex` + +**Customizable elements** (documented in template): +- Font size (currently 11pt) +- Margins and spacing +- Sender address alignment +- Header/footer content +- Color scheme (currently black/white) + +**To customize**: +1. Edit `src/.claude/templates/swiss-letter.tex` +2. Re-run `/convert-cover-letter` to apply changes +3. Template comments explain each section + +### Multiple Conversions + +Users can run `/convert-cover-letter` multiple times: +- Overwrites existing `cover-letter.pdf` (no prompt needed) +- Use this after editing `cover-letter.md` +- Quick iteration on formatting and content + +## Error Handling Summary + +| Error Condition | User Action Required | +|-----------------|---------------------| +| No cover-letter.md | Navigate to application folder or run /write-cover-letter | +| Pandoc missing | Install Pandoc via package manager | +| LaTeX missing | Install texlive-latex-base, texlive-lang-german, texlive-latex-extra | +| Invalid YAML | Fix frontmatter syntax in cover-letter.md | +| Missing required fields | Add missing fields to frontmatter | +| LaTeX compilation error | Check for special characters, inspect .tex file | +| Permission denied | Check directory write permissions | +| Disk space | Free up disk space | +| Timeout | Simplify content or debug manually | + +## Important Notes + +### Swiss Letter Standards + +The conversion follows Swiss Norm (SN) for business letters: +- **Address window**: Positioned for standard Swiss envelope windows +- **Date format**: DD.MM.YYYY (Swiss convention) +- **Layout**: KOMA-Script scrlttr2 with Swiss configuration +- **Language support**: Swiss German hyphenation and special characters (ä, ö, ü, ß) + +### File Compatibility + +**Input format**: Markdown with YAML frontmatter +**Output format**: PDF (via LaTeX) +**Template engine**: Pandoc with custom LaTeX template + +### System Requirements + +**Minimum**: +- Pandoc 2.0+ +- LaTeX (TeX Live or MiKTeX) +- Basic LaTeX packages (texlive-latex-base, texlive-lang-german, texlive-latex-extra) + +**Recommended**: +- Latest Pandoc version +- Full TeX Live installation (includes all packages) +- ~500MB disk space for full LaTeX installation + +### Troubleshooting + +**Common issues**: +1. **"File not found"** → Run command from application directory +2. **"Pandoc not found"** → Install Pandoc first +3. **"LaTeX error"** → Check for special characters in text +4. **"Missing font"** → Install texlive-fonts-recommended +5. **"Address doesn't fit window"** → Verify Swiss envelope type, check template settings + +**For advanced users**: +- Intermediate .tex file shows LaTeX source +- Run `pdflatex cover-letter.tex` manually for detailed error output +- Edit swiss-letter.tex template for custom layouts + +--- + +**Remember**: The goal is to produce a professional, Swiss-standard business letter PDF that is ready for submission with job applications. Quality and formatting accuracy are paramount. diff --git a/src/.claude/templates/swiss-letter.tex b/src/.claude/templates/swiss-letter.tex new file mode 100644 index 0000000..1485180 --- /dev/null +++ b/src/.claude/templates/swiss-letter.tex @@ -0,0 +1,143 @@ +% Swiss Business Letter Template for Pandoc +% This template follows Swiss standards (SN) for business correspondence +% Compatible with KOMA-Script scrlttr2 class + +\documentclass[ + fontsize=11pt, + paper=a4, + parskip=half, % Half line spacing between paragraphs + fromalign=right, % Sender address aligned right + fromphone, % Include phone number + fromemail, % Include email address + pagenumber=false, % Disable page numbers + version=last % Use latest KOMA-Script features +]{scrlttr2} + +% ==================== ENCODING & FONTS ==================== +% UTF-8 input encoding for special characters (ä, ö, ü, ß) +\usepackage[utf8]{inputenc} +% T1 font encoding for proper hyphenation and special characters +\usepackage[T1]{fontenc} + +% ==================== HYPERLINKS ==================== +% Enable clickable email links in PDF +\usepackage{hyperref} +\hypersetup{ + colorlinks=true, + urlcolor=black, + pdfborder={0 0 0} +} + +% ==================== PANDOC COMPATIBILITY ==================== +% Define tightlist command for Pandoc-generated lists +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} + +% ==================== LANGUAGE SUPPORT ==================== +% Try to load German language support if available +% This provides proper German labels (Telefon, Anlagen) and hyphenation +% +% If german.ldf is found: Labels will be in German +% If not found: Labels will be in English (Phone, encl) +% +% To install German support: +% Ubuntu/Debian: sudo apt install texlive-lang-german +% Arch: sudo pacman -S texlive-langgerman +% macOS/Windows: Included in full TeX Live installation +\IfFileExists{ngerman.ldf}{% + \usepackage[ngerman]{babel} +}{% + \IfFileExists{german.ldf}{% + \usepackage[german]{babel} + }{% + % No German language files found + % Labels will be in English (Phone, encl) without language package + } +} + +% ==================== SWISS LETTER CONFIGURATION ==================== +% Load Swiss Norm (SN) for proper address window positioning +% This ensures the recipient address fits in standard Swiss envelope windows +\LoadLetterOption{SN} + +% ==================== SENDER INFORMATION ==================== +% Customize these fields by editing the markdown frontmatter +\setkomavar{fromname}{$from.name$} +\setkomavar{fromaddress}{$from.street$\\$from.city$} + +$if(from.phone)$ +\setkomavar{fromphone}{$from.phone$} +$endif$ + +$if(from.email)$ +% Email is rendered as a clickable hyperlink +\setkomavar{fromemail}{\href{mailto:$from.email$}{$from.email$}} +$endif$ + +% ==================== LETTER METADATA ==================== +$if(subject)$ +\setkomavar{subject}{$subject$} +$endif$ + +$if(date)$ +\setkomavar{date}{$date$} +$endif$ + +$if(signature)$ +\setkomavar{signature}{$signature$} +$endif$ + +% ==================== ENCLOSURES ==================== +$if(enclosures)$ +% Separator between "Enclosures" label and list (e.g., "Anlagen:") +\setkomavar{enclseparator}{:} +$endif$ + +% ==================== CUSTOMIZATION OPTIONS ==================== +% Remove backaddress line in envelope window (uncomment to enable) +\setkomavar{backaddress}{} + +% You can customize additional elements here: +% - \setkomavar{location}{} - Text in the upper right corner +% - \setkomavar{place}{} - Place of writing (if different from address) +% - Font sizes, margins, spacing can be adjusted via KOMA-Script options + +% ==================== DOCUMENT BODY ==================== +\begin{document} + +\begin{letter}{% +% Recipient address - each line from the 'to' frontmatter array +$for(to)$ +$to$\\ +$endfor$ +} + +% ==================== OPENING ==================== +$if(opening)$ +\opening{$opening$} +$else$ +% Default opening if not specified +\opening{Sehr geehrte Damen und Herren} +$endif$ + +% ==================== LETTER BODY ==================== +% The main content from your markdown file is inserted here +$body$ + +% ==================== CLOSING ==================== +$if(closing)$ +\closing{$closing$} +$else$ +% Default closing if not specified +\closing{Freundliche Grüsse} +$endif$ + +% ==================== ENCLOSURES LIST ==================== +$if(enclosures)$ +% List of attached documents (e.g., CV, certificates) +\encl{$for(enclosures)$$enclosures$$sep$\\$endfor$} +$endif$ + +\end{letter} + +\end{document}