{"id":16703830,"url":"https://github.com/leeper/htlatex-example","last_synced_at":"2025-10-20T06:26:44.587Z","repository":{"id":70769673,"uuid":"144288358","full_name":"leeper/htlatex-example","owner":"leeper","description":"Demo of htlatex for LaTeX to Word (.docx) file conversion","archived":false,"fork":false,"pushed_at":"2019-02-11T13:40:14.000Z","size":180,"stargazers_count":27,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T06:12:02.989Z","etag":null,"topics":["docx","htlatex","latex","make","pandoc"],"latest_commit_sha":null,"homepage":null,"language":"TeX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leeper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-08-10T13:17:32.000Z","updated_at":"2025-01-30T16:00:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"93f0604e-a7be-43cc-a6c2-61b743fa20ab","html_url":"https://github.com/leeper/htlatex-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fhtlatex-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fhtlatex-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fhtlatex-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fhtlatex-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leeper","download_url":"https://codeload.github.com/leeper/htlatex-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161280,"owners_count":21057554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["docx","htlatex","latex","make","pandoc"],"created_at":"2024-10-12T19:09:52.078Z","updated_at":"2025-10-20T06:26:44.523Z","avatar_url":"https://github.com/leeper.png","language":"TeX","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Demo of `htlatex` build cycle\n\nThis repository demonstrates how to get a word (.docx) document from a LaTeX (.tex) source file, preserving tables, equations, and references.\n\n(This demo uses make. So just type `make` on the command line. For a basic `make` demo, see [https://github.com/leeper/make-example](https://github.com/leeper/make-example).)\n\nThere are a couple of strategies available here.\n\n## `htlatex`\n\nI like `htlatex`. I works well, preserves cross-references, section numbers, citations, and equations. Other options include installing additional software, which might work better, but you already have `htlatex` installed with your TeX distribution.\n\nThe build workflow - using `make` is two steps:\n\n```bash\nhtlatex manuscript \"html,fn-in\"\nbibtex manuscript\nhtlatex manuscript \"html,fn-in\"\nhtlatex manuscript \"html,fn-in\"\npandoc manuscript.html -o manuscript-htlatex.docx\n```\n\nNote the second argument to `htlatex`, which delivers footnotes. For whatever reason they're not included in the HTML by default.\n\nThis workflow, in my experience, is the best one available. Basically, you're buiding an HTML file and using `pandoc` to convert the well-formatted HTML into a word document.\n\n## Basic `pandoc`\n\nAn alternative is to call `pandoc` directly on the `.tex` file, but the result misses a lot:\n\n```bash\npandoc manuscript.tex -o manuscript-pandoc.docx\n```\n\nNote that cross-references and citations are messed up. An advantage is that equations are actually typeset in Word, rather than being images of the LaTeX equations (as above). If you have an equation-heavy document, this may be the way to go. Basically figure out which is better to resolve manually - equations or cross-references.\n\n## `pandoc` with a CSL file\n\nUpdate: John McFarlane points out that the simple `pandoc` command is not appropriate. Instead, to preserve citations you need to specify a \"citation style language\" file and call a more verbose `pandoc` command. We'll use [this CSL file from the official CSL repo](https://github.com/citation-style-language/styles/blob/master/american-political-science-association.csl).\n\n```bash\npandoc manuscript.tex -o manuscript-pandoc.docx --filter pandoc-citeproc --csl american-political-science-association.csl\n```\n\nThis gets references working quite well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeper%2Fhtlatex-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleeper%2Fhtlatex-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeper%2Fhtlatex-example/lists"}