{"id":22927586,"url":"https://github.com/kpym/latex-fast-compile","last_synced_at":"2025-05-13T01:50:33.307Z","repository":{"id":60245291,"uuid":"320581856","full_name":"kpym/latex-fast-compile","owner":"kpym","description":"A small executable that pre-compile the preamble to speed up future compilations (with pdflatex).","archived":false,"fork":false,"pushed_at":"2023-04-25T16:06:28.000Z","size":116,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T05:51:04.026Z","etag":null,"topics":["go","golang","latex","tex"],"latest_commit_sha":null,"homepage":"","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/kpym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-11T13:28:37.000Z","updated_at":"2025-02-06T18:38:00.000Z","dependencies_parsed_at":"2024-06-20T05:46:39.113Z","dependency_job_id":"b0cf2461-a32c-49cf-9199-f5975e784cf0","html_url":"https://github.com/kpym/latex-fast-compile","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpym%2Flatex-fast-compile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpym%2Flatex-fast-compile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpym%2Flatex-fast-compile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpym%2Flatex-fast-compile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpym","download_url":"https://codeload.github.com/kpym/latex-fast-compile/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856616,"owners_count":21974576,"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":["go","golang","latex","tex"],"created_at":"2024-12-14T09:15:08.071Z","updated_at":"2025-05-13T01:50:33.288Z","avatar_url":"https://github.com/kpym.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# latex-fast-compile\r\n\r\nA small executable that pre-compile the preamble to speed up future compilations (with `pdflatex`). Then, it watches for file changes, and automatically recompile the source `.tex` file using this precompiled preamble.\r\n\r\n## Usage\r\n\r\n```\r\n\u003e latex-fast-compile -h\r\nlatex-fast-compile (version: --): compile latex source using precompiled header.\r\n\r\nUsage: latex-fast-compile [options] filename[.tex].\r\n  If filename.fmt is missing it is build before the compilation.\r\n  The available options are:\r\n\r\n      --precompile              Force to create .fmt file even if it exists.\r\n      --skip-fmt                Skip .fmt file and compile all.\r\n      --no-synctex              Do not build .synctex file.\r\n      --no-watch                Do not watch for file changes in the .tex file.\r\n  -x, --xelatex                 Use xelatex in place of pdflatex.\r\n      --compiles-at-start int   Number of compiles before to start watching. (default 1)\r\n      --info string             The info level [no|errors|errors+log|actions|debug]. (default \"actions\")\r\n      --log-sanitize string     Match the log against this regex before display, or display all if empty.\r\n                                 (default \"(?ms)^(?:! |l\\\\.|\u003crecently read\u003e ).*?$(?:\\\\s^.*?$){0,2}\")\r\n      --split string            The regex that defines the end of the preamble.\r\n                                 (default \"(?m)^\\\\s*(?:%\\\\s*end\\\\s*preamble|\\\\\\\\begin{document})\")\r\n      --temp-folder string      Folder to store all temp files, .fmt included.\r\n      --clear string            Clear auxiliary files and .fmt at end [auto|yes|no].\r\n                                 When watching auto=true, else auto=false.\r\n                                In debug mode clear is false. (default \"auto\")\r\n      --aux-extensions string   Extensions to remove in clear at the end procedure.\r\n                                 (default \"aux,bbl,blg,fmt,fff,glg,glo,gls,idx,ilg,ind,lof,lot,nav,out,ptc,snm,sta,stp,toc\")\r\n      --no-normalize            Keep accents and spaces in intermediate file names.\r\n      --option strings          Additional option to pass to the compiler. Can be used multiple times.\r\n  -v, --version                 Print the version number.\r\n  -h, --help                    Print this help message.\r\n```\r\n\r\n## Example\r\n\r\nTo compile `cylinder.tex` you can simply use:\r\n\r\n```bash\r\n\u003e latex-fast-compile cylinder.tex\r\n create cylinder.body.tex\r\n create cylinder.preamble.tex\r\n::::::: Precompile...done [2.0s]\r\n::::::: Compile (use precompiled cylinder.fmt)...done [1.1s]\r\nWatching for file changes...(to exit press Ctrl/Cmd-C).\r\n```\r\n1. The source `cylinder.tex` is split to `cylinder.preamble.tex` and `cylinder.body.tex`.\r\n1. Then if the precompiled header is missing (`cylinder.fmt` is missing in our case) it is precompiled from `cylinder.preamble.tex`.\r\n1. The file is compiled using this precompiled header (`cylinder.fmt` in our case) from `cylinder.body.tex`.\r\n1. The program waits (except if `--no-watch` is used) for new changes in the `.tex` file. At every change the source is re-split and the body part is re-compiled using the precompiled header.\r\n\r\n### How it works\r\n\r\nThe `.tex` file is split into two files `.preamble.tex` and `.body.tex`. The file is split at `% end preamble` comment or at `\\begin{document}` (which comes first). The file `.preamble.tex` is precompiled to `.fmt` only if needed. The file `.body.tex` is compiled using this `.fmt` file to `.pdf`.\r\n\r\nThe split point is controlled by the regular expression defined in the `--split` flag. This regular expression follows the [go re2 syntax](https://github.com/google/re2/wiki/Syntax).\r\n\r\n### Printed information\r\n\r\nThe output information is controlled by the string flags `--info` and `--log-sanitize`. The regular expression set in `--log-sanitize`, used to sanitize the log file, follows the [go re2 syntax](https://github.com/google/re2/wiki/Syntax).\r\n\r\n### Temp folder\r\n\r\nTo keep your folder clean of temporary files, precompiled `.fmt` included, a temp folder can be set with the `--temp-folders` flag.\r\nIn the case of MiKTeX `-aux-directory` is used, but in TeX Live this option is not available so `-output-directory` is used, but then the resulting `pdf` and the corresponding `synctex` should be moved back to the main folder.\r\n\r\n### Bizarre file names\r\n\r\nIf the filename has non ascii symbols and/or spaces, it is normalized (except if `-no-normalize` is used). For example `Très étrange.tex` will be normalized to `Tresetrange.tex` and at the end the resulting `Tresetrange.pdf` will be renamed back to `Très étrange.pdf`.\r\n\r\n```bash\r\nlatex-fast-compile Très\\ étrange.tex --no-watch --compiles-at-start=2\r\n create Tresetrange.body.tex\r\n create Tresetrange.preamble.tex\r\n::::::: Precompile...done [3.3s]\r\n::::::: Compile draft (use precompiled Tresetrange.fmt)...done [1.9s]\r\n::::::: Compile (use precompiled Tresetrange.fmt)...done [2.3s]\r\n copy Tresetrange.pdf to Très étrange.pdf\r\n delete Tresetrange.pdf\r\n move Tresetrange.synctex to Très étrange.synctex\r\n remove Tresetrange.preamble.tex\r\n remove Tresetrange.body.tex\r\n```\r\nThis is necessary because this kind of filenames do not work well for precompiled `.fmt` files.\r\n\r\n### XeLaTex\r\n\r\nWe can use `xelatex` in place of `pdflatex` by specifying the `-x` (`--xelatex`) option. But it is good to know that `fontspec` and `polyglossia` (and any other package that access `ttf` or `otf` fonts) can't be in the precompiled header. If these two libraries are present in the preamble they are moved outside. But if they are included indirectly, the compilation will fail.\r\n\r\n## Installation\r\n\r\n### Precompiled executables\r\n\r\nYou can download the executable for your platform from the [releases](https://github.com/kpym/latex-fast-compile/releases).\r\n\r\n### Compile it yourself\r\n\r\n#### Using Go\r\n\r\nThis method will compile to executable named `latex-fast-compile`.\r\n\r\n```shell\r\n$ go get github.com/kpym/latex-fast-compile\r\n```\r\n\r\n#### Using goreleaser\r\n\r\nAfter cloning this repo you can compile the sources with [goreleaser](https://github.com/goreleaser/goreleaser/) for all available platforms:\r\n\r\n```shell\r\ngit clone https://github.com/kpym/latex-fast-compile.git .\r\ngoreleaser --snapshot --skip-publish --clean\r\n```\r\n\r\nYou will find the resulting binaries in the `dist/` sub-folder.\r\n\r\n## License\r\n\r\n[MIT](LICENSE) License\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpym%2Flatex-fast-compile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpym%2Flatex-fast-compile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpym%2Flatex-fast-compile/lists"}