{"id":51043751,"url":"https://github.com/floatpane/go-term-latex","last_synced_at":"2026-06-22T12:02:25.943Z","repository":{"id":361621740,"uuid":"1255011405","full_name":"floatpane/go-term-latex","owner":"floatpane","description":"Displaying LaTex equations in the terminal","archived":false,"fork":false,"pushed_at":"2026-06-18T22:08:33.000Z","size":5310,"stargazers_count":0,"open_issues_count":9,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-19T00:10:50.677Z","etag":null,"topics":["cli","command-line","console","dvipng","equations","go","golang","golang-library","latex","latex-renderer","math","mathematics","pdflatex","rendering","tectonic","terminal","terminal-graphics","tex","tui","typesetting"],"latest_commit_sha":null,"homepage":"https://go-latex.floatpane.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floatpane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"floatpane"}},"created_at":"2026-05-31T09:34:05.000Z","updated_at":"2026-06-01T17:55:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/floatpane/go-term-latex","commit_stats":null,"previous_names":["floatpane/go-term-latex"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/floatpane/go-term-latex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-term-latex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-term-latex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-term-latex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-term-latex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatpane","download_url":"https://codeload.github.com/floatpane/go-term-latex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-term-latex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34647750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","console","dvipng","equations","go","golang","golang-library","latex","latex-renderer","math","mathematics","pdflatex","rendering","tectonic","terminal","terminal-graphics","tex","tui","typesetting"],"created_at":"2026-06-22T12:02:25.028Z","updated_at":"2026-06-22T12:02:25.929Z","avatar_url":"https://github.com/floatpane.png","language":"Go","funding_links":["https://github.com/sponsors/floatpane"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# go-term-latex\n\n**Render LaTeX math equations in the terminal — Kitty, Sixel, or Unicode half-block fallback.**\n\n[![Go Version](https://img.shields.io/github/go-mod/go-version/floatpane/go-term-latex)](https://golang.org)\n[![Go Reference](https://pkg.go.dev/badge/github.com/floatpane/go-term-latex.svg)](https://pkg.go.dev/github.com/floatpane/go-term-latex)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/floatpane/go-term-latex)](https://github.com/floatpane/go-term-latex/releases)\n[![CI](https://github.com/floatpane/go-term-latex/actions/workflows/ci.yml/badge.svg)](https://github.com/floatpane/go-term-latex/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n\u003c/div\u003e\n\n`go-term-latex` turns a LaTeX math equation into terminal graphics in one call.\nIt shells out to a TeX backend installed on the host — `pdflatex`, `tectonic`,\nor `latex`+`dvipng` — to produce a tight-cropped PNG, recolors it to match the\nterminal theme, and writes it directly using the best protocol the terminal\nsupports (Kitty graphics, Sixel, or Unicode half-block). No external display\ndependency — protocol detection and encoding are built in.\n\n## Install\n\n```bash\ngo get github.com/floatpane/go-term-latex\n```\n\nRequires Go 1.26+ and one of the following TeX backends:\n\n| Backend | Packages needed |\n|---------|----------------|\n| **pdflatex** (recommended) | `texlive-latex-base` + `poppler-utils` (Linux) / MacTeX (macOS) |\n| **tectonic** | `tectonic` (downloads TeX packages on first run) |\n| **latex + dvipng** | `texlive-latex-base` + `dvipng` |\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"os\"\n\n    termlatex \"github.com/floatpane/go-term-latex\"\n)\n\nfunc main() {\n    // Block (display) math — \\[\\displaystyle …\\]\n    _ = termlatex.Display(os.Stdout, `\\int_0^\\infty e^{-x^2}\\,dx = \\frac{\\sqrt{\\pi}}{2}`, termlatex.Options{})\n\n    // Inline math — $…$\n    _ = termlatex.Inline(os.Stdout, `E = mc^2`, termlatex.Options{})\n\n    // Verbatim — you control all markup\n    _ = termlatex.Render(os.Stdout, `\\[\\begin{pmatrix}a\u0026b\\\\c\u0026d\\end{pmatrix}\\]`, termlatex.Options{})\n}\n```\n\n### Options\n\n```go\ntermlatex.Options{\n    Backend:    termlatex.PDFLaTeX, // pin a backend; default Auto-detects\n    Protocol:   termlatex.Kitty,    // pin a protocol; default Auto-detects\n    DPI:        200,                // render resolution (default 150)\n    MaxWidth:   800,                // pixel cap before scaling (0 = fit terminal)\n    MaxHeight:  400,\n    Packages:   []string{\"physics\", \"siunitx\"}, // extra \\usepackage entries\n    Foreground: color.NRGBA{0, 200, 255, 255},  // glyph color; nil = auto-detect\n    Background: color.NRGBA{20, 20, 20, 255},    // bg color; nil = auto-detect\n    NoTheme:    false,              // true = raw black-on-white, no recolor\n}\n```\n\n### Theme matching\n\nThe backend renders black glyphs on white. Before display the PNG is recolored\nto match your terminal — glyphs take the terminal foreground, the paper takes\nthe background — so there's no white box on a dark terminal. Colors are detected\nby querying the terminal (OSC 10 / OSC 11), falling back to `$COLORFGBG` and\nthen light-on-dark. Override with `Foreground`/`Background`, or set\n`NoTheme: true` to keep the raw black-on-white render.\n\n### Backend detection\n\n```go\nb, err := termlatex.Detect()\nif err != nil {\n    log.Fatal(\"no TeX backend found:\", err)\n}\nfmt.Println(\"using\", b) // \"pdflatex\", \"tectonic\", or \"latex+dvipng\"\n```\n\n## How it works\n\n1. The equation is wrapped in a minimal `standalone` class document with\n   `amsmath`, `amssymb`, and `amsfonts`.\n2. The document is written to a temp dir and compiled by the chosen TeX backend\n   (no `--shell-escape`, so the document cannot run arbitrary shell commands).\n3. The PDF or DVI is converted to a tight-cropped PNG via `pdftoppm` or\n   `dvipng`.\n4. The black-on-white PNG is recolored to match the terminal theme (detected\n   via OSC 10 / OSC 11), so glyphs use the terminal foreground and the\n   background blends in.\n5. The PNG is scaled to fit the terminal and written using the best available\n   protocol (Kitty → Sixel → HalfBlock), detected from `$TERM` /\n   `$TERM_PROGRAM`. Encoding is built in — no external display dependency.\n\n## Documentation\n\nFull API reference: [pkg.go.dev/github.com/floatpane/go-term-latex](https://pkg.go.dev/github.com/floatpane/go-term-latex)\n\n## Contributing\n\nPRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Security\n\nDo not pass untrusted LaTeX to this library without additional sanitization —\nsee [SECURITY.md](SECURITY.md).\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatpane%2Fgo-term-latex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatpane%2Fgo-term-latex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatpane%2Fgo-term-latex/lists"}