A modern, reproducible workflow for creating NIH grant applications using Typst, with integrated support for R and Python data analysis via Quarto.
# Clone the repository
git clone https://github.com/brainworkup/nih-grant-typst.git
cd nih-grant-typst
# Set up the environment (choose one)
conda env create -f environment.yml # Recommended: includes everything
# OR
pip install -r requirements.txt # Python only
# OR
Rscript -e "install.packages(c('tidyverse', 'ggplot2', 'patchwork', 'viridis'))" # R only
# Compile example templates
./scripts/compile_templates.sh- β NIH-compliant formatting - Automated margins, fonts, and page limits
- β Multiple grant types - R01, R03, with more coming soon
- β Integrated data analysis - Seamless R and Python integration
- β Reproducible research - Quarto-based progress reports
- β Smart reference management - BibTeX with NIH-style formatting
- β Version control friendly - Clean text-based format
- β Automated compilation - GitHub Actions for PDF generation
- β Modular components - Reusable sections across grants
nih-grant-typst/
βββ templates/ # Typst templates for grant applications
β βββ R01/ # R01 grant template
β βββ R03/ # R03 grant template
β βββ shared/ # Shared components (aims, budget)
βββ scripts/ # Helper scripts and analysis code
β βββ analysis/ # Data analysis scripts
β β βββ figures/ # R/Python scripts for figures
β β βββ tables/ # R scripts for tables
β βββ helpers/ # Utility scripts
βββ quarto/ # Progress report templates
βββ data/ # Data organization structure
β βββ raw/ # Original, unmodified data
β βββ cleaned/ # Processed, analysis-ready data
β βββ scripts/ # Data processing scripts
βββ examples/ # Example outputs and figures
βββ outputs/ # Compiled PDFs (generated)
# For an R01 grant
cp -r templates/R01 my_r01_grant
# For an R03 grant
cp -r templates/R03 my_r03_grantEdit the main file (e.g., my_r01_grant/R01.typ):
#import "config.typ": *
#import "../shared/specific_aims.typ": specific_aims_example
#import "../shared/budget.typ": budget_example
// Update with your information
#show: nih-grant.with(
title: "Your Grant Title Here",
pi: "Dr. Your Name",
institution: "Your Institution"
)
// Add your content
#specific_aims[
Your specific aims content here...
]# Using the helper script
./scripts/compile_templates.sh
# Or compile directly with correct root setting
typst compile --root . my_r01_grant/R01.typ outputs/my_r01_grant.pdfCreate a Quarto document for your analysis:
---
title: "Data Analysis for NIH Grant"
format:
html: default
typst: default
---
```{r}
#| label: fig-results
#| fig-cap: "Primary outcome analysis"
library(ggplot2)
data <- read.csv("data/cleaned/results.csv")
ggplot(data, aes(x = time, y = outcome, color = group)) +
geom_line() +
theme_minimal() +
labs(title = "Treatment Effect Over Time")
ggsave("outputs/figures/primary_outcome.png", dpi = 300)
Reference in your Typst document:
```typst
#figure(
image("outputs/figures/primary_outcome.png"),
caption: [Treatment effect over time showing significant improvement in the intervention group.]
)
# scripts/analysis/figures/generate_figures.py
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load and analyze data
data = pd.read_csv('data/cleaned/results.csv')
sns.set_style("whitegrid")
# Create publication-quality figure
fig, ax = plt.subplots(figsize=(8, 6))
sns.lineplot(data=data, x='time', y='outcome', hue='group', ax=ax)
ax.set_title('Treatment Effect Over Time')
plt.savefig('outputs/figures/python_analysis.png', dpi=300, bbox_inches='tight')Follow our structured approach for reproducible research:
data/
βββ raw/ # Never modify these files
β βββ behavioral/ # Original behavioral data
β βββ neuroimaging/ # MRI/fMRI data
β βββ clinical/ # Clinical assessments
βββ cleaned/ # Processed data with documentation
β βββ behavioral/ # Analysis-ready datasets
β βββ processing_logs/ # Document all transformations
βββ scripts/ # Processing scripts
βββ preprocessing/ # Data cleaning code
Add references to references.bib:
@article{smith2023example,
title = {Example Study Title},
author = {Smith, Jane and Doe, John},
journal = {Journal of Example Studies},
volume = {42},
pages = {123--456},
year = {2023},
doi = {10.1234/example}
}Cite in Typst:
Previous research has shown significant effects @smith2023example.# Convert to NIH style
python scripts/helpers/reference_formatter.py references.bib --format nih
# Check for duplicates
python scripts/helpers/reference_formatter.py references.bib --check-duplicatesGenerate professional progress reports using Quarto:
cd quarto
quarto render progress-report.qmd --to pdf
quarto render progress-report.qmd --to html- Purpose: Major research projects
- Research Strategy: 12 pages
- Budget: Modular or detailed
- Duration: Up to 5 years
- View template
- Purpose: Limited research projects
- Research Strategy: 6 pages
- Budget: $50,000/year maximum
- Duration: Up to 2 years
- View template
- R21 - Exploratory/Developmental Research
- K99/R00 - Pathway to Independence
- F31 - Predoctoral Fellowship
We include configurations for optimal development:
- Typst syntax highlighting and preview
- Integrated compilation tasks (Ctrl+Shift+B)
- Recommended extensions for R, Python, and Quarto
Ensure your grant meets NIH requirements:
# Check page limits (coming soon)
python scripts/helpers/validate_grant.py outputs/my_grant.pdf --type R01
# Validate formatting
python scripts/helpers/check_formatting.py outputs/my_grant.pdfCreate reusable components for your grants:
// templates/shared/my_custom_section.typ
#let my_section(content) = {
heading(level: 1, [MY CUSTOM SECTION])
set par(first-line-indent: 0.5in)
content
}We welcome contributions! See our Contributing Guidelines.
- Add new grant templates
- Improve existing templates
- Share helper scripts
- Enhance documentation
- Report issues
This project is licensed under the MIT License - see the LICENSE file for details.
- Typst community for the excellent typesetting system
- NIH for grant formatting guidelines
- Contributors who have improved these templates
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Remember: Always check the latest NIH guidelines as requirements may change.