{"id":16489732,"url":"https://github.com/phfaist/latexpp","last_synced_at":"2026-03-01T08:34:31.232Z","repository":{"id":39372845,"uuid":"198214823","full_name":"phfaist/latexpp","owner":"phfaist","description":"Latex preprocessor — apply macro definitions, remove comments, and more","archived":false,"fork":false,"pushed_at":"2025-08-02T17:31:27.000Z","size":578,"stargazers_count":13,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-02T19:32:59.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://latexpp.readthedocs.io/","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/phfaist.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"License.txt","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,"zenodo":null}},"created_at":"2019-07-22T12:00:41.000Z","updated_at":"2025-08-02T17:31:30.000Z","dependencies_parsed_at":"2025-06-05T15:49:37.761Z","dependency_job_id":null,"html_url":"https://github.com/phfaist/latexpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phfaist/latexpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phfaist%2Flatexpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phfaist%2Flatexpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phfaist%2Flatexpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phfaist%2Flatexpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phfaist","download_url":"https://codeload.github.com/phfaist/latexpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phfaist%2Flatexpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29965406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T06:55:38.174Z","status":"ssl_error","status_checked_at":"2026-03-01T06:53:04.810Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-11T13:45:12.645Z","updated_at":"2026-03-01T08:34:31.210Z","avatar_url":"https://github.com/phfaist.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"latexpp\n=======\n\nLatex preprocessor — apply macro definitions, remove comments, and more\n\n*Disclaimer: latexpp is still at an experimental development stage.*\n\n.. image:: https://img.shields.io/github/license/phfaist/latexpp.svg?style=flat\n   :target: https://github.com/phfaist/latexpp/blob/master/LICENSE.txt\n   \n\nInstallation\n------------\n\nYou can install `latexpp` using `pip`:\n\n.. code-block:: sh\n\n    \u003e pip install latexpp\n\nHow it works\n------------\n\nThe latex preprocessor ``latexpp`` reads your main latex document and copies it\nto an output directory while applying a series of \"fixes\" that you can\nconfigure.  For instance, you can remove comments, you can include files that\nyou input with ``\\input`` macros, or you can replace custom macros by their\nLaTeX expansion.\n\nYou run ``latexpp`` in a folder with a ``lppconfig.yml`` file that specifies the\nnecessary information such as the main LaTeX document, the output directory, and\nwhich fixes to apply.\n\nSample ``lppconfig.yml``:\n\n.. code-block:: yaml\n\n  # latexpp config for MyDocument.tex\n  #\n  # This is YAML syntax -- google \"YAML tutorial\" to get a quick intro.  Be\n  # careful with spaces since indentation is important.\n\n  # the master LaTeX document -- this file will not be modified, all output will\n  # be produced in the output_dir\n  fname: 'MyDocument.tex'\n\n  # output file(s) will be created in this directory, originals will not be\n  # modified\n  output_dir: 'latexpp_output'\n  \n  # main document file name in the output directory\n  output_fname: 'paper.tex'\n\n  # specify list of fixes to apply, in the given order\n  fixes:\n\n    # replace \\input{...} directives by the contents of the included file\n    - 'latexpp.fixes.input.EvalInput'\n  \n    # remove all comments\n    - 'latexpp.fixes.comments.RemoveComments'\n\n    # copy any style files (.sty) that are used in the document and that\n    # are present in the current directory to the output directory\n    - 'latexpp.fixes.usepackage.CopyLocalPkgs'\n  \n    # copy figure files to the output directory and rename them fig-1.xxx,\n    # fig-2.xxx, etc.\n    - 'latexpp.fixes.figures.CopyAndRenameFigs'\n\n    # Replace \\bibliography{...} by \\input{xxx.bbl} and copy the bbl file to the\n    # output directory.  Make sure you run (pdf)latex on the main docuemnt\n    # before running latexpp\n    - 'latexpp.fixes.bib.CopyAndInputBbl'\n  \n    # Expand some macros. Latexpp doesn't parse \\newcommand's, so you need to\n    # specify here the LaTeX code that the macro should be expanded to. If the\n    # macro has arguments, specify the nature of the arguments here in the\n    # 'argspec:' key (a '*' is an optional * character, a '[' one optional\n    # square-bracket-delimited argument, and a '{' is a mandatory argument). The\n    # argument values are available via the placeholders %(1)s, %(2)s, etc. Make\n    # sure to use single quotes for strings that contain \\ backslashes.\n    - name: 'latexpp.fixes.macro_subst.Subst'\n      config:\n        macros:\n          # \\tr         --\u003e  \\operatorname{tr}\n          tr: '\\operatorname{tr}'\n          # \\ket{\\psi}  --\u003e  \\lvert{\\psi}\\rangle\n          ket:\n            argspec: '{'\n            repl: '\\lvert{%(1)s}\\rangle'\n          # \\braket{\\psi}{\\phi}  --\u003e  \\langle{\\psi}\\vert{\\phi}\\rangle\n          braket:\n            argspec: '{{'\n            repl: '\\langle{%(1)s}\\vert{%(2)s}\\rangle'\n\nThe config file follows standard YAML syntax (if you're in doubt, google a YAML\ntutorial).\n\nDocumentation is available at `latexpp.readthedocs.io\n\u003chttps://latexpp.readthedocs.io/\u003e`_. You can also explore the ``latexpp/fixes/``\ndirectory for the list of possible fixes.  The documentation is still a little\nsparse at the moment (I wrote this preprocessor in the\nmatter of a few days, and I won't have tons of time to devote to it). But the\npython source is fairly short and should be relatively decipherable.\n\nEach fix is specified by a qualified python class name.  For instance,\n``latexpp.fixes.comments.RemoveComments`` invokes class ``RemoveComments`` from\nthe python module ``latexpp.fixes.comments``.  You can specify custom arguments\nto the class constructor by using the syntax with the 'name:' and 'config:' keys\nas shown above.  The keys in each 'config:' section are directly passed on to\nthe class constructor as corresponding keyword arguments.\n\nThe fixes in the ``latexpp/fixes/pkg/`` directory are those fixes that are\nsupposed to apply all definitions of the corresponding package in order to\nremove a dependency on that package.\n\nIt's also straightforward to write your own fix classes to do more complicated\nstuff.  Create a python package (a new folder ``mypackage`` with an empty\n``__init__.py`` file) and create a python module (e.g. ``myfixmodule.py``) in\nthat package that defines your fix class (e.g. ``MyFix``).  You can get\ninspiration from one of the simple examples in the ``latexpp/fixes/`` folder.\nSet up your ``$PYTHONPATH`` so that your python package is exposed to python.\nThen simply specify the pacakge/module your fix is located in in the YAML file,\ne.g., ``mypackage.myfixmodule.MyFix`` instead of\n``latexpp.fixes.xxxxx.YYYY``.\n\nHow it actually works\n---------------------\n\nThe ``latexpp`` preprocessor relies on `pylatexenc 2.0\n\u003chttps://github.com/phfaist/pylatexenc\u003e`_ to parse the latex document into an\ninternal node structure.  For instance, the chunk of latex code::\n  \n  Hello, \\textit{world}! % show a greeting\n\nwill be parsed into a list of four nodes, a ‘normal characters node’ ``\"Hello,\n\"``, a ‘macro node’ ``\\textit`` with argument a ‘group node’ ``{world}`` which\nitself contains a ‘normal characters node’ ``world``, a ‘normal characters node’\n``\"! \"``, and a ‘latex comment node’ ``% show a greeting``.  The structure is\nrecursive, with e.g. macro arguments and environment contents themselves\nrepresented as nodes which can contain further macros and environments.  See\n`pylatexenc.latexwalker\n\u003chttps://pylatexenc.readthedocs.io/en/latest/latexwalker/\u003e`_ for more\ninformation.  The `pylatexenc` library has a list of some known macros and\nenvironments, and knows how to parse their arguments.  Some fixes in `latexpp`\nadd their own macro and environment definitions.\n\nOnce the latex document is parsed into the node structure, the document is\nprocessed by the given list of fixes. Each fix is called in turn. Each fix\ntraverses the document node structure and applies any relevant changes.\n\n\nLicense\n-------\n\n\\ (C) 2019 Philippe Faist, philippe dot faist \u003cat@at\u003e bluewin dot ch\n\nMIT Licence, see License.txt\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphfaist%2Flatexpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphfaist%2Flatexpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphfaist%2Flatexpp/lists"}