Skip to content

feat(cli): Add papi bibtex command for citation export #8

@hummat

Description

@hummat

Problem or Motivation

No easy way to export BibTeX for LaTeX workflows. Users need to manually construct citations or copy from external sources. This complements existing papi add --from-file library.bib (import) to complete the import/export story.

Proposed Solution

Add papi bibtex command:

# Print to stdout
papi bibtex paper1 paper2

# Export to file
papi bibtex paper1 paper2 --to library.bib

# Export all papers
papi bibtex --all --to library.bib

# Customize citation keys
papi bibtex paper1 --key-style doi

Options

  • PAPER...: Paper names (positional, multiple allowed)
  • --all: Export all papers in the database
  • --to FILE: Write to file instead of stdout (append if exists)
  • --key-style {name,doi,arxiv,slug}: BibTeX key format
    • name: Use paperpipe name (default)
    • doi: Use DOI (e.g., 10.1234/example)
    • arxiv: Use arXiv ID (e.g., 2301.12345)
    • slug: Auto-generate from first author + year + title

Implementation

Complexity: LOW — metadata already stored, just formatting

  1. Read meta.json for each paper
  2. Format as BibTeX entries:
    • @article or @misc based on venue
    • Required fields: author, title, year
    • Optional: journal, doi, arxiv, url, abstract
  3. Handle missing metadata gracefully (e.g., no DOI → use arXiv URL)
  4. Ensure valid BibTeX (escape special chars, wrap long lines)

Example output

@article{lora,
  author = {Hu, Edward J. and Shen, Yelong and Wallis, Phillip and ...},
  title = {LoRA: Low-Rank Adaptation of Large Language Models},
  year = {2021},
  journal = {arXiv preprint arXiv:2106.09685},
  arxiv = {2106.09685},
  url = {https://arxiv.org/abs/2106.09685}
}

Alternatives Considered

  • Export via papi show --format bibtex — conflates display with export, awkward for multiple papers
  • External tools (e.g., Zotero) — adds dependency, doesn't use paperpipe metadata

Area

CLI commands

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions