Skip to contents

Introduction

thoth provides tools to create and manage custom Quarto templates that maintain consistent branding and styling across your organization’s reports. These templates can be easily created, customized, and applied to any Quarto document.

Creating Templates

Basic Template

Create a new template with your organization’s branding:

library(thoth)

create_quarto_template(
  template_name = "company_template",
  primary_color = "#0054AD",
  secondary_color = "#00B4E0",
  font_family = "Source Sans Pro"
)

Template Structure

The template generator creates a complete set of files:

reports/
└── templates/
    └── company_template/
        ├── _template.yml     # Quarto configuration
        ├── custom.css       # Styling
        └── assets/         # Images and resources

Template Components

1. YAML Configuration

format:
  html:
    theme: cosmo
    css: custom.css
    toc: true
    code-fold: true
    code-tools: true
    fig-width: 8
    fig-height: 6
    fig-dpi: 300

2. CSS Styling

:root {
  --primary-color: #0054AD;
  --secondary-color: #00B4E0;
}

.navbar {
  background-color: var(--primary-color);
}

.title {
  color: var(--primary-color);
}

body {
  font-family: 'Source Sans Pro', sans-serif;
}

Using Templates

Applying to Reports

# Apply template to a single report
apply_template_to_report(
  "reports/analysis.qmd",
  "company_template"
)

# Apply to multiple reports
apply_template_to_report(
  c("reports/analysis.qmd", "reports/summary.qmd"),
  "company_template"
)

Customizing Templates

# Create template with custom settings
create_quarto_template(
  template_name = "technical_report",
  primary_color = "#2E5EAA",
  secondary_color = "#30B8BE",
  font_family = "JetBrains Mono",
  code_font = "Fira Code",
  toc_depth = 3,
  code_fold = "show"
)

Best Practices

1. Design Principles

  • Use consistent color schemes
  • Choose readable fonts
  • Maintain clear hierarchy
  • Ensure accessibility

2. Organization

  • Keep templates in version control
  • Document customizations
  • Use meaningful template names
  • Share templates across team

3. Usage

# Create project with template
create_analytics_project(
  "analysis",
  use_quarto = TRUE,
  template = "company_template"
)

# Apply template to existing report
apply_template_to_report(
  "report.qmd",
  "company_template",
  overwrite = FALSE  # Preview changes first
)

Template Types

1. Executive Summary

format:
  html:
    toc: false
    code-fold: true
    code-tools: false
    fig-width: 10

2. Technical Report

format:
  html:
    toc: true
    toc-depth: 3
    code-fold: show
    code-tools: true
    df-print: paged

Next Steps