{"id":22144024,"url":"https://github.com/pytask-dev/pytask-latex","last_synced_at":"2025-07-26T01:31:02.614Z","repository":{"id":40558888,"uuid":"280895438","full_name":"pytask-dev/pytask-latex","owner":"pytask-dev","description":"Compile LaTeX documents with pytask.","archived":false,"fork":false,"pushed_at":"2024-11-18T19:45:09.000Z","size":178,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-18T20:44:38.231Z","etag":null,"topics":["pytask"],"latest_commit_sha":null,"homepage":"","language":"Python","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/pytask-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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-07-19T15:34:06.000Z","updated_at":"2024-08-02T14:26:30.000Z","dependencies_parsed_at":"2023-12-25T20:24:50.568Z","dependency_job_id":"2460b1c2-cc27-4d48-9957-4d4fdd65177f","html_url":"https://github.com/pytask-dev/pytask-latex","commit_stats":{"total_commits":52,"total_committers":4,"mean_commits":13.0,"dds":"0.34615384615384615","last_synced_commit":"eef375cf3ce2652963de74ed447f58a700957c8f"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytask-dev%2Fpytask-latex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytask-dev%2Fpytask-latex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytask-dev%2Fpytask-latex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytask-dev%2Fpytask-latex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pytask-dev","download_url":"https://codeload.github.com/pytask-dev/pytask-latex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227635409,"owners_count":17796972,"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":["pytask"],"created_at":"2024-12-01T22:18:08.025Z","updated_at":"2024-12-01T22:18:08.649Z","avatar_url":"https://github.com/pytask-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytask-latex\n\n[![PyPI](https://img.shields.io/pypi/v/pytask-latex?color=blue)](https://pypi.org/project/pytask-latex)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytask-latex)](https://pypi.org/project/pytask-latex)\n[![image](https://img.shields.io/conda/vn/conda-forge/pytask-latex.svg)](https://anaconda.org/conda-forge/pytask-latex)\n[![image](https://img.shields.io/conda/pn/conda-forge/pytask-latex.svg)](https://anaconda.org/conda-forge/pytask-latex)\n[![PyPI - License](https://img.shields.io/pypi/l/pytask-latex)](https://pypi.org/project/pytask-latex)\n[![image](https://img.shields.io/github/actions/workflow/status/pytask-dev/pytask-latex/main.yml?branch=main)](https://github.com/pytask-dev/pytask-latex/actions?query=branch%3Amain)\n[![image](https://codecov.io/gh/pytask-dev/pytask-latex/branch/main/graph/badge.svg)](https://codecov.io/gh/pytask-dev/pytask-latex)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/pytask-latex/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/pytask-latex/main)\n[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n______________________________________________________________________\n\npytask-latex allows you to compile LaTeX documents with pytask\n\nIt also uses\n[latex-dependency-scanner](https://github.com/pytask-dev/latex-dependency-scanner) to\nautomatically infer the dependencies of the LaTeX document such as images,\nbibliographies and other `.tex` files which are necessary to compile the LaTeX document.\n\n## Installation\n\npytask-latex is available on [PyPI](https://pypi.org/project/pytask-latex) and\n[Anaconda.org](https://anaconda.org/conda-forge/pytask-latex). Install it with\n\n```console\n$ pip install pytask-latex\n\n# or\n\n$ conda install -c conda-forge pytask-latex\n```\n\nYou also need to have `latexmk` installed which determines the necessary number of\ncompilation steps ([here](https://tex.stackexchange.com/a/249243/194826) is an\nexplanation for what latexmk achieves). To test whether it is installed, type the\nfollowing on the command line\n\n```console\n$ latexmk --help\n```\n\nIf an error is shown instead of a help page, you can install `latexmk` with one of the\npopular LaTeX distributions, like [TeX Live](https://www.tug.org/texlive/),\n[MiKTeX](https://miktex.org/), [MacTeX](http://www.tug.org/mactex/) or others.\n\n## Usage\n\nCompiling your PDF can be as simple as writing the following task.\n\n```python\nfrom pathlib import Path\nfrom pytask import mark\n\n\n@mark.latex(script=Path(\"document.tex\"), document=Path(\"document.pdf\"))\ndef task_compile_latex_document():\n    pass\n```\n\nUse `@mark.latex` to indicate that this task compiles a LaTeX document. The `script` and\nthe `document` keywords provide absolute paths or paths relative to the task module to\nthe LaTeX file and the compiled document.\n\n### Dependencies and Products\n\nDependencies and products can be added as usual. Read this\n[tutorial](https://pytask-dev.readthedocs.io/en/stable/tutorials/defining_dependencies_products.html).\n\nFor example, with the `@task` decorator. (The choice of the kwarg name, here `path`, is\narbitrary.)\n\n```python\nfrom pytask import mark\nfrom pytask import task\nfrom pathlib import Path\n\n\n@task(kwargs={\"path\": Path(\"path_to_another_dependency.tex\")})\n@mark.latex(script=Path(\"document.tex\"), document=Path(\"document.pdf\"))\ndef task_compile_latex_document():\n    pass\n```\n\n### Customizing the compilation\n\npytask-latex uses latexmk by default to compile the document because it handles most\nuse-cases automatically. The following is equivalent to a bare `@mark.latex` decorator.\n\n```python\n@mark.latex(\n    script=Path(\"document.tex\"),\n    document=Path(\"document.pdf\"),\n    compilation_steps=\"latexmk\",\n)\ndef task_compile_latex_document(): ...\n```\n\nThe `@mark.latex` decorator has a keyword argument called `compilation_steps` which\naccepts which accepts strings or list of strings pointing to internally implemented\ncompilation steps. Using strings will use the default configuration of this compilation\nstep. It is equivalent to the following.\n\n```python\nfrom pytask_latex import compilation_steps as cs\n\n\n@mark.latex(\n    script=Path(\"document.tex\"),\n    document=Path(\"document.pdf\"),\n    compilation_steps=cs.latexmk(\n        options=(\"--pdf\", \"--interaction=nonstopmode\", \"--synctex=1\", \"--cd\")\n    ),\n)\ndef task_compile_latex_document(): ...\n```\n\nIn this example, `compilation_steps.latexmk` is a compilation step constructor which\naccepts a set of options and creates a compilation step function.\n\nYou can pass different options to change the compilation process with latexmk. Here is\nan example for generating a `.dvi`.\n\n```python\n@mark.latex(\n    script=Path(\"document.tex\"),\n    document=Path(\"document.pdf\"),\n    compilation_steps=cs.latexmk(\n        options=(\"--dvi\", \"--interaction=nonstopmode\", \"--synctex=1\", \"--cd\")\n    ),\n)\ndef task_compile_latex_document(): ...\n```\n\n`compilation_step.latexmk(options)` generates a compilation step which is a function\nwith the following signature:\n\n```python\nfrom pathlib import Path\nimport subprocess\n\n\ndef custom_compilation_step(path_to_tex: Path, path_to_document: Path) -\u003e None:\n    ...\n    subproces.run(..., check=True)\n```\n\nYou can also pass your custom compilation step with the same signature to the\n`compilation_steps` keyword argument of the decorator.\n\nEach compilation step receives the path to the LaTeX source file and the path to the\nfinal document which it uses to call some program on the command line to run another\nstep in the compilation process.\n\nIn the future, pytask-latex will provide more compilation steps for compiling\nbibliographies, glossaries and the like.\n\n### Repeating tasks with different scripts or inputs\n\nYou can compile multiple LaTeX documents as well as compiling a single `.tex` document\nwith different command line arguments.\n\nThe following task compiles two latex documents.\n\n```python\nfor i in range(2):\n\n    @task\n    @mark.latex(script=Path(f\"document_{i}.tex\"), document=Path(f\"document_{i}.pdf\"))\n    def task_compile_latex_document():\n        pass\n```\n\nIf you want to compile the same document with different command line options, you have\nto include the latex decorator in the parametrization. Pass a dictionary for possible\ncompilation steps and their options.\n\n```python\nfor format_ in (\"pdf\", \"dvi\"):\n\n    @task\n    @mark.latex(\n        script=Path(\"document.tex\"),\n        document=Path(f\"document.{format_}\"),\n        compilation_steps=cs.latexmk(\n            (f\"--{format_}\", \"--interaction=nonstopmode\", \"--synctex=1\", \"--cd\")\n        ),\n    )\n    def task_compile_latex_document():\n        pass\n```\n\n## Configuration\n\n*`infer_latex_dependencies`*\n\npytask-latex tries to scan your LaTeX document for included files with the help of\n[latex-dependency-scanner](https://github.com/pytask-dev/latex-dependency-scanner) if\nthe following configuration value is true which is also the default.\n\n```toml\n[tool.pytask.ini_options]\ninfer_latex_dependencies = true\n```\n\nSince the package is in its early development phase and LaTeX provides a myriad of ways\nto include files as well as providing shortcuts for paths (e.g., `\\graphicspath`), there\nare definitely some rough edges left. File an issue here or in the other project in case\nof a problem.\n\n## Changes\n\nConsult the [release notes](CHANGES.md) to find out about what is new.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpytask-dev%2Fpytask-latex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpytask-dev%2Fpytask-latex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpytask-dev%2Fpytask-latex/lists"}